Lines wrapped again

This commit is contained in:
Marcin Kurczewski 2014-04-30 00:11:13 +02:00
parent 396ea97cad
commit c18c9ec680
22 changed files with 277 additions and 92 deletions

View file

@ -84,7 +84,8 @@ class CommentController
if (InputHelper::get('sender') != 'preview') if (InputHelper::get('sender') != 'preview')
{ {
CommentModel::save($comment); CommentModel::save($comment);
LogHelper::log('{user} edited comment in {post}', ['post' => TextHelper::reprPost($comment->getPost())]); LogHelper::log('{user} edited comment in {post}', [
'post' => TextHelper::reprPost($comment->getPost())]);
} }
$context->transport->textPreview = $comment->getText(); $context->transport->textPreview = $comment->getText();
StatusHelper::success(); StatusHelper::success();
@ -101,7 +102,8 @@ class CommentController
CommentModel::remove($comment); CommentModel::remove($comment);
LogHelper::log('{user} removed comment from {post}', ['post' => TextHelper::reprPost($comment->getPost())]); LogHelper::log('{user} removed comment from {post}', [
'post' => TextHelper::reprPost($comment->getPost())]);
StatusHelper::success(); StatusHelper::success();
} }
} }

View file

@ -502,7 +502,11 @@ class PostController
$newSafety = $post->safety; $newSafety = $post->safety;
if ($oldSafety != $newSafety) if ($oldSafety != $newSafety)
LogHelper::log('{user} changed safety of {post} to {safety}', ['post' => TextHelper::reprPost($post), 'safety' => PostSafety::toString($post->safety)]); {
LogHelper::log('{user} changed safety of {post} to {safety}', [
'post' => TextHelper::reprPost($post),
'safety' => PostSafety::toString($post->safety)]);
}
} }
/* tags */ /* tags */
@ -517,10 +521,18 @@ class PostController
$newTags = array_map(function($tag) { return $tag->name; }, $post->getTags()); $newTags = array_map(function($tag) { return $tag->name; }, $post->getTags());
foreach (array_diff($oldTags, $newTags) as $tag) foreach (array_diff($oldTags, $newTags) as $tag)
LogHelper::log('{user} untagged {post} with {tag}', ['post' => TextHelper::reprPost($post), 'tag' => TextHelper::reprTag($tag)]); {
LogHelper::log('{user} untagged {post} with {tag}', [
'post' => TextHelper::reprPost($post),
'tag' => TextHelper::reprTag($tag)]);
}
foreach (array_diff($newTags, $oldTags) as $tag) foreach (array_diff($newTags, $oldTags) as $tag)
LogHelper::log('{user} tagged {post} with {tag}', ['post' => TextHelper::reprPost($post), 'tag' => TextHelper::reprTag($tag)]); {
LogHelper::log('{user} tagged {post} with {tag}', [
'post' => TextHelper::reprPost($post),
'tag' => TextHelper::reprTag($tag)]);
}
} }
/* source */ /* source */
@ -535,7 +547,11 @@ class PostController
$newSource = $post->source; $newSource = $post->source;
if ($oldSource != $newSource) if ($oldSource != $newSource)
LogHelper::log('{user} changed source of {post} to {source}', ['post' => TextHelper::reprPost($post), 'source' => $post->source]); {
LogHelper::log('{user} changed source of {post} to {source}', [
'post' => TextHelper::reprPost($post),
'source' => $post->source]);
}
} }
/* relations */ /* relations */
@ -550,10 +566,18 @@ class PostController
$newRelatedIds = array_map(function($post) { return $post->id; }, $post->getRelations()); $newRelatedIds = array_map(function($post) { return $post->id; }, $post->getRelations());
foreach (array_diff($oldRelatedIds, $newRelatedIds) as $post2id) foreach (array_diff($oldRelatedIds, $newRelatedIds) as $post2id)
LogHelper::log('{user} removed relation between {post} and {post2}', ['post' => TextHelper::reprPost($post), 'post2' => TextHelper::reprPost($post2id)]); {
LogHelper::log('{user} removed relation between {post} and {post2}', [
'post' => TextHelper::reprPost($post),
'post2' => TextHelper::reprPost($post2id)]);
}
foreach (array_diff($newRelatedIds, $oldRelatedIds) as $post2id) foreach (array_diff($newRelatedIds, $oldRelatedIds) as $post2id)
LogHelper::log('{user} added relation between {post} and {post2}', ['post' => TextHelper::reprPost($post), 'post2' => TextHelper::reprPost($post2id)]); {
LogHelper::log('{user} added relation between {post} and {post2}', [
'post' => TextHelper::reprPost($post),
'post2' => TextHelper::reprPost($post2id)]);
}
} }
/* thumbnail */ /* thumbnail */

View file

@ -108,7 +108,11 @@ class PostEntity extends AbstractEntity
continue; continue;
if (count($relatedPosts) > $config->browsing->maxRelatedPosts) if (count($relatedPosts) > $config->browsing->maxRelatedPosts)
throw new SimpleException('Too many related posts (maximum: %d)', $config->browsing->maxRelatedPosts); {
throw new SimpleException(
'Too many related posts (maximum: %d)',
$config->browsing->maxRelatedPosts);
}
$relatedPosts []= PostModel::findById($relatedId); $relatedPosts []= PostModel::findById($relatedId);
} }
@ -372,7 +376,11 @@ class PostEntity extends AbstractEntity
$duplicatedPost = PostModel::findByHash($this->fileHash, false); $duplicatedPost = PostModel::findByHash($this->fileHash, false);
if ($duplicatedPost !== null and (!$this->id or $this->id != $duplicatedPost->id)) if ($duplicatedPost !== null and (!$this->id or $this->id != $duplicatedPost->id))
throw new SimpleException('Duplicate upload: %s', TextHelper::reprPost($duplicatedPost)); {
throw new SimpleException(
'Duplicate upload: %s',
TextHelper::reprPost($duplicatedPost));
}
$dstPath = $this->getFullPath(); $dstPath = $this->getFullPath();
@ -407,7 +415,11 @@ class PostEntity extends AbstractEntity
$duplicatedPost = PostModel::findByHash($youtubeId, false); $duplicatedPost = PostModel::findByHash($youtubeId, false);
if ($duplicatedPost !== null and (!$this->id or $this->id != $duplicatedPost->id)) if ($duplicatedPost !== null and (!$this->id or $this->id != $duplicatedPost->id))
throw new SimpleException('Duplicate upload: %s' . TextHelper::reprPost($duplicatedPost)); {
throw new SimpleException(
'Duplicate upload: %s',
TextHelper::reprPost($duplicatedPost));
}
return; return;
} }
@ -436,7 +448,11 @@ class PostEntity extends AbstractEntity
throw new SimpleException('Cannot write into file'); throw new SimpleException('Cannot write into file');
fflush($srcFP); fflush($srcFP);
if (ftell($srcFP) > $maxBytes) if (ftell($srcFP) > $maxBytes)
throw new SimpleException('File is too big (maximum size: %s)', TextHelper::useBytesUnits($maxBytes)); {
throw new SimpleException(
'File is too big (maximum size: %s)',
TextHelper::useBytesUnits($maxBytes));
}
} }
} }
finally finally

View file

@ -3,7 +3,12 @@ Assets::setSubTitle('authentication form');
Assets::addStylesheet('auth.css'); Assets::addStylesheet('auth.css');
?> ?>
<form action="<?= \Chibi\Router::linkTo(['AuthController', 'loginAction']) ?>" class="auth" method="post"> <form
method="post"
action="<?= \Chibi\Router::linkTo(
['AuthController', 'loginAction']) ?>"
class="auth">
<p> <p>
If you don't have an account yet,<br/> If you don't have an account yet,<br/>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'registrationAction']); ?>">click here</a> to create a new one. <a href="<?= \Chibi\Router::linkTo(['UserController', 'registrationAction']); ?>">click here</a> to create a new one.

View file

@ -4,8 +4,10 @@ Assets::addScript('comment-edit.js');
?> ?>
<form <form
action="<?= \Chibi\Router::linkTo(['CommentController', 'addAction'], ['postId' => $this->context->transport->post->id]) ?>"
method="post" method="post"
action="<?= \Chibi\Router::linkTo(
['CommentController', 'addAction'],
['postId' => $this->context->transport->post->id]) ?>"
class="add-comment"> class="add-comment">
<h1>add comment</h1> <h1>add comment</h1>

View file

@ -4,8 +4,10 @@ Assets::addScript('comment-edit.js');
?> ?>
<form <form
action="<?= \Chibi\Router::linkTo(['CommentController', 'editAction'], ['id' => $this->context->transport->comment->id]) ?>"
method="post" method="post"
action="<?= \Chibi\Router::linkTo(
['CommentController', 'editAction'],
['id' => $this->context->transport->comment->id]) ?>"
class="edit-comment"> class="edit-comment">
<h1>edit comment</h1> <h1>edit comment</h1>

View file

@ -31,7 +31,9 @@ Assets::setSubTitle('comments');
<?php endforeach ?> <?php endforeach ?>
<?php if (count($comments) > count($commentsToDisplay)): ?> <?php if (count($comments) > count($commentsToDisplay)): ?>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'viewAction'], ['id' => $this->context->post->id]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['PostController', 'viewAction'],
['id' => $this->context->post->id]) ?>">
<span class="hellip">(more&hellip;)</span> <span class="hellip">(more&hellip;)</span>
</a> </a>
<?php endif ?> <?php endif ?>

View file

@ -22,7 +22,9 @@ Assets::addScript('comment-edit.js');
<div class="header"> <div class="header">
<span class="nickname"> <span class="nickname">
<?php if ($commenter): ?> <?php if ($commenter): ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $commenter->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $commenter->name]) ?>">
<?= $commenter->name ?> <?= $commenter->name ?>
</a> </a>
<?php else: ?> <?php else: ?>
@ -38,7 +40,9 @@ Assets::addScript('comment-edit.js');
Privilege::EditComment, Privilege::EditComment,
Access::getIdentity($commenter))): ?> Access::getIdentity($commenter))): ?>
<span class="edit"> <span class="edit">
<a href="<?= \Chibi\Router::linkTo(['CommentController', 'editAction'], ['id' => $this->context->comment->id]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['CommentController', 'editAction'],
['id' => $this->context->comment->id]) ?>">
edit edit
</a> </a>
</span> </span>
@ -48,9 +52,11 @@ Assets::addScript('comment-edit.js');
Access::check(Privilege::DeleteComment, Access::check(Privilege::DeleteComment,
Access::getIdentity($commenter))): ?> Access::getIdentity($commenter))): ?>
<span class="delete"> <span class="delete">
<a href="<?= \Chibi\Router::linkTo(['CommentController', 'deleteAction'], ['id' => $this->context->comment->id]) ?>" <a class="simple-action confirmable"
class="simple-action confirmable" data-confirm-text="Are you sure you want to delete this comment?"
data-confirm-text="Are you sure you want to delete this comment?"> href="<?= \Chibi\Router::linkTo(
['CommentController', 'deleteAction'],
['id' => $this->context->comment->id]) ?>">
delete delete
</a> </a>
</span> </span>

View file

@ -16,7 +16,9 @@ $showTabs = count($tabs) > 1;
<?php else: ?> <?php else: ?>
<li class="<?= $tab ?>"> <li class="<?= $tab ?>">
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['IndexController', 'helpAction'], $tab == $firstTab ? [] : ['tab' => $tab]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['IndexController', 'helpAction'],
$tab == $firstTab ? [] : ['tab' => $tab]) ?>">
<?= $text ?> <?= $text ?>
</a> </a>
</li> </li>

View file

@ -41,7 +41,9 @@ Assets::addStylesheet('index-index.css');
Featured Featured
<?php if ($this->context->featuredPostUser): ?> <?php if ($this->context->featuredPostUser): ?>
by by
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $this->context->featuredPostUser->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $this->context->featuredPostUser->name]) ?>">
<?= $this->context->featuredPostUser->name ?> <?= $this->context->featuredPostUser->name ?>
</a>, </a>,
<?php endif ?> <?php endif ?>

View file

@ -13,7 +13,9 @@ Assets::setSubTitle('logs (' . $this->context->transport->name . ')');
?> ?>
<form method="get" <form method="get"
action="<?= \Chibi\Router::linkTo(['LogController', 'viewAction'], ['name' => $this->context->transport->name]) ?>"> action="<?= \Chibi\Router::linkTo(
['LogController', 'viewAction'],
['name' => $this->context->transport->name]) ?>">
Keep only lines that contain: Keep only lines that contain:

View file

@ -1,5 +1,7 @@
<form method="post" <form method="post"
action="<?= \Chibi\Router::linkTo(['PostController', 'editAction'], ['id' => $this->context->transport->post->id]) ?>" action="<?= \Chibi\Router::linkTo(
['PostController', 'editAction'],
['id' => $this->context->transport->post->id]) ?>"
enctype="multipart/form-data" enctype="multipart/form-data"
class="edit-post"> class="edit-post">

View file

@ -1,5 +1,9 @@
<?php Assets::setPageThumb(\Chibi\Router::linkTo(['PostController', 'thumbAction'], ['name' => $this->context->transport->post->name])) ?> <?php
<?php $post = $this->context->transport->post ?> Assets::setPageThumb(\Chibi\Router::linkTo(
['PostController', 'thumbAction'],
['name' => $this->context->transport->post->name]));
$post = $this->context->transport->post;
?>
<?php if ($post->type == PostType::Image): ?> <?php if ($post->type == PostType::Image): ?>
@ -7,7 +11,10 @@
<a href="<?= $this->context->imageLink ?>"> <a href="<?= $this->context->imageLink ?>">
<?php endif ?> <?php endif ?>
<img src="<?= \Chibi\Router::linkTo(['PostController', 'retrieveAction'], ['name' => $post->name]) ?>" alt="<?= $post->name ?>"/> <img alt="<?= $post->name ?>"
src="<?= \Chibi\Router::linkTo(
['PostController', 'retrieveAction'],
['name' => $post->name]) ?>"/>
<?php if (!empty($this->context->imageLink)): ?> <?php if (!empty($this->context->imageLink)): ?>
</a> </a>
@ -19,10 +26,14 @@
type="<?= $post->mimeType ?>" type="<?= $post->mimeType ?>"
width="<?= $post->imageWidth ?>" width="<?= $post->imageWidth ?>"
height="<?= $post->imageHeight ?>" height="<?= $post->imageHeight ?>"
data="<?= \Chibi\Router::linkTo(['PostController', 'retrieveAction'], ['name' => $post->name]) ?>"> data="<?= \Chibi\Router::linkTo(
['PostController', 'retrieveAction'],
['name' => $post->name]) ?>">
<param name="movie" value="<?= \Chibi\Router::linkTo(['PostController', 'retrieveAction'], ['name' => $post->name]) ?>"/>
<param name="wmode" value="opaque"/> <param name="wmode" value="opaque"/>
<param name="movie" value="<?= \Chibi\Router::linkTo(
['PostController', 'retrieveAction'],
['name' => $post->name]) ?>"/>
</object> </object>
@ -40,7 +51,9 @@
<video style="max-width: 100%" controls> <video style="max-width: 100%" controls>
<source <source
type="<?= $post->mimeType ?>" type="<?= $post->mimeType ?>"
src="<?= \Chibi\Router::linkTo(['PostController', 'retrieveAction'], ['name' => $post->name]) ?>"> src="<?= \Chibi\Router::linkTo(
['PostController', 'retrieveAction'],
['name' => $post->name]) ?>">
Your browser doesn't support HTML5 &lt;video&gt; tag. Your browser doesn't support HTML5 &lt;video&gt; tag.
</video> </video>

View file

@ -30,7 +30,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<nav id="around"> <nav id="around">
<div class="left"> <div class="left">
<?php if ($this->context->transport->nextPostId): ?> <?php if ($this->context->transport->nextPostId): ?>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'viewAction'], ['id' => $this->context->transport->nextPostId]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['PostController', 'viewAction'],
['id' => $this->context->transport->nextPostId]) ?>">
<?php else: ?> <?php else: ?>
<a class="disabled"> <a class="disabled">
<?php endif ?> <?php endif ?>
@ -41,7 +43,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<div class="right"> <div class="right">
<?php if ($this->context->transport->prevPostId): ?> <?php if ($this->context->transport->prevPostId): ?>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'viewAction'], ['id' => $this->context->transport->prevPostId]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['PostController', 'viewAction'],
['id' => $this->context->transport->prevPostId]) ?>">
<?php else: ?> <?php else: ?>
<a class="disabled"> <a class="disabled">
<?php endif ?> <?php endif ?>
@ -55,8 +59,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<?php if (!empty($this->context->transport->lastSearchQuery)): ?> <?php if (!empty($this->context->transport->lastSearchQuery)): ?>
<div class="text"> <div class="text">
Current&nbsp;search:<br/> Current&nbsp;search:<br/>
<a href="<?= \Chibi\Router::linkTo(['PostController', 'listAction'], [ <a href="<?= \Chibi\Router::linkTo(
'query' => $this->context->transport->lastSearchQuery]) ?>"> ['PostController', 'listAction'],
['query' => $this->context->transport->lastSearchQuery]) ?>">
<?= $this->context->transport->lastSearchQuery ?> <?= $this->context->transport->lastSearchQuery ?>
</a> </a>
</div> </div>
@ -70,7 +75,11 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?> <?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
<?php foreach ($tags as $tag): ?> <?php foreach ($tags as $tag): ?>
<li title="<?= $tag->name ?>"> <li title="<?= $tag->name ?>">
<a href="<?= \Chibi\Router::linkTo(['PostController', 'listAction'], ['query' => $tag->name]) ?>"><?= $tag->name ?></a> <a href="<?= \Chibi\Router::linkTo(
['PostController', 'listAction'],
['query' => $tag->name]) ?>"
><?= $tag->name ?>
</a>
<span class="count"><?= TextHelper::useDecimalUnits($tag->getPostCount()) ?></span> <span class="count"><?= TextHelper::useDecimalUnits($tag->getPostCount()) ?></span>
</li> </li>
<?php endforeach ?> <?php endforeach ?>
@ -84,33 +93,39 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<?php $uploader = $this->context->transport->post->getUploader() ?> <?php $uploader = $this->context->transport->post->getUploader() ?>
<?php if ($uploader): ?> <?php if ($uploader): ?>
<span class="value" title="<?= $val = $uploader->name ?>"> <span class="value" title="<?= $val = $uploader->name ?>">
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $uploader->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $uploader->name]) ?>">
<img src="<?= htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?= $uploader->name ?>"/> <img src="<?= htmlentities($uploader->getAvatarUrl(24)) ?>" alt="<?= $uploader->name ?>"/>
<?= $val ?> <?= $val ?>
</a> </a>
</span> </span>
<?php else: ?> <?php else: ?>
<span class="value" title="<?= UserModel::getAnonymousName() ?>"> <span class="value" title="<?= UserModel::getAnonymousName() ?>">
<img src="<?= \Chibi\Util\Url::makeAbsolute('/media/img/pixel.gif') ?>" alt="<?= UserModel::getAnonymousName() ?>"/> <img src="<?= \Chibi\Util\Url::makeAbsolute('/media/img/pixel.gif') ?>"
alt="<?= UserModel::getAnonymousName() ?>"/>
<?= UserModel::getAnonymousName() ?> <?= UserModel::getAnonymousName() ?>
</span> </span>
<?php endif ?> <?php endif ?>
<br> <br>
<span class="date" title="<?= TextHelper::formatDate($this->context->transport->post->uploadDate, true) ?>"> <span class="date"
title="<?= TextHelper::formatDate($this->context->transport->post->uploadDate, true) ?>">
<?= TextHelper::formatDate($this->context->transport->post->uploadDate, false) ?> <?= TextHelper::formatDate($this->context->transport->post->uploadDate, false) ?>
</span> </span>
</div> </div>
<div class="key-value safety"> <div class="key-value safety">
<span class="key">Safety:</span> <span class="key">Safety:</span>
<span class="value safety-<?= $val = PostSafety::toDisplayString($this->context->transport->post->safety) ?>" title="<?= $val ?>"> <span class="value safety-<?= $val = PostSafety::toDisplayString($this->context->transport->post->safety) ?>"
title="<?= $val ?>">
<?= $val ?> <?= $val ?>
</span> </span>
</div> </div>
<div class="key-value source"> <div class="key-value source">
<span class="key">Source:</span> <span class="key">Source:</span>
<span class="value" title="<?= $val = htmlspecialchars($this->context->transport->post->source ?: 'unknown') ?>"> <span class="value"
title="<?= $val = htmlspecialchars($this->context->transport->post->source ?: 'unknown') ?>">
<?php if (preg_match('/^((https?|ftp):|)\/\//', $this->context->transport->post->source)): ?> <?php if (preg_match('/^((https?|ftp):|)\/\//', $this->context->transport->post->source)): ?>
<a href="<?= $val ?>"><?= $val ?></a> <a href="<?= $val ?>"><?= $val ?></a>
<?php else: ?> <?php else: ?>
@ -135,8 +150,17 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<span class="value"> <span class="value">
<?= $this->context->transport->post->score ?> <?= $this->context->transport->post->score ?>
<?php $scoreLink = function($score) { return \Chibi\Router::linkTo(['PostController', 'scoreAction'], ['id' => $this->context->transport->post->id, 'score' => $score]); } ?> <?php
<?php if (Access::check(Privilege::ScorePost, Access::getIdentity($this->context->transport->post->getUploader()))): ?> $scoreLink = function($score)
{
return \Chibi\Router::linkTo(
['PostController', 'scoreAction'],
['id' => $this->context->transport->post->id, 'score' => $score]);
}
?>
<?php if (Access::check(
Privilege::ScorePost,
Access::getIdentity($this->context->transport->post->getUploader()))): ?>
<?php if ($this->context->score === 1): ?> <?php if ($this->context->score === 1): ?>
<a class="simple-action selected" href="<?= $scoreLink(0) ?>"> <a class="simple-action selected" href="<?= $scoreLink(0) ?>">
<?php else: ?> <?php else: ?>
@ -162,7 +186,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<div class="unit hl-options"> <div class="unit hl-options">
<?php if ($this->context->transport->post->type != PostType::Youtube): ?> <?php if ($this->context->transport->post->type != PostType::Youtube): ?>
<div class="hl-option"> <div class="hl-option">
<a href="<?= \Chibi\Router::linkTo(['PostController', 'retrieveAction'], ['name' => $this->context->transport->post->name]) ?>" title="Download"> <a title="Download" href="<?= \Chibi\Router::linkTo(
['PostController', 'retrieveAction'],
['name' => $this->context->transport->post->name]) ?>">
<i class="icon-dl"></i> <i class="icon-dl"></i>
<span> <span>
<?php <?php
@ -176,15 +202,23 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
</div> </div>
<?php endif ?> <?php endif ?>
<?php if (Access::check(Privilege::FavoritePost, Access::getIdentity($this->context->transport->post->getUploader()))): ?> <?php if (Access::check(
Privilege::FavoritePost,
Access::getIdentity($this->context->transport->post->getUploader()))): ?>
<div class="hl-option"> <div class="hl-option">
<?php if (!$this->context->favorite): ?> <?php if (!$this->context->favorite): ?>
<a class="add-fav icon simple-action" href="<?= \Chibi\Router::linkTo(['PostController', 'addFavoriteAction'], ['id' => $this->context->transport->post->id]) ?>"> <a class="add-fav icon simple-action"
href="<?= \Chibi\Router::linkTo(
['PostController', 'addFavoriteAction'],
['id' => $this->context->transport->post->id]) ?>">
<i class="icon-fav"></i> <i class="icon-fav"></i>
<span>Add to favorites</span> <span>Add to favorites</span>
</a> </a>
<?php else: ?> <?php else: ?>
<a class="rem-fav icon simple-action" href="<?= \Chibi\Router::linkTo(['PostController', 'removeFavoriteAction'], ['id' => $this->context->transport->post->id]) ?>"> <a class="rem-fav icon simple-action"
href="<?= \Chibi\Router::linkTo(
['PostController', 'removeFavoriteAction'],
['id' => $this->context->transport->post->id]) ?>">
<i class="icon-fav"></i> <i class="icon-fav"></i>
<span>Remove from favorites</span> <span>Remove from favorites</span>
</a> </a>
@ -208,7 +242,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<ul> <ul>
<?php foreach ($this->context->transport->post->getFavorites() as $user): ?> <?php foreach ($this->context->transport->post->getFavorites() as $user): ?>
<li> <li>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $user->name]) ?>" title="<?= $user->name ?>"> <a title="<?= $user->name ?>" href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $user->name]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?= $user->name ?>"> <img src="<?= htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?= $user->name ?>">
</a> </a>
</li> </li>
@ -235,19 +271,25 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
<?php <?php
$options = []; $options = [];
if (Access::check(Privilege::FeaturePost, Access::getIdentity($this->context->transport->post->getUploader()))) if (Access::check(
Privilege::FeaturePost,
Access::getIdentity($this->context->transport->post->getUploader())))
{ {
$options []= $options []=
[ [
'class' => 'feature', 'class' => 'feature',
'text' => 'Feature on main page', 'text' => 'Feature on main page',
'simple-action' => \Chibi\Router::linkTo(['PostController', 'featureAction'], ['id' => $this->context->transport->post->id]), 'simple-action' => \Chibi\Router::linkTo(
['PostController', 'featureAction'],
['id' => $this->context->transport->post->id]),
'data-confirm-text' => 'Are you sure you want to feature this post on the main page?', 'data-confirm-text' => 'Are you sure you want to feature this post on the main page?',
'data-redirect-url' => \Chibi\Router::linkTo(['IndexController', 'indexAction']), 'data-redirect-url' => \Chibi\Router::linkTo(['IndexController', 'indexAction']),
]; ];
} }
if (Access::check(Privilege::FlagPost, Access::getIdentity($this->context->transport->post->getUploader()))) if (Access::check(
Privilege::FlagPost,
Access::getIdentity($this->context->transport->post->getUploader())))
{ {
if ($this->context->flagged) if ($this->context->flagged)
{ {
@ -264,13 +306,17 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
[ [
'class' => 'flag', 'class' => 'flag',
'text' => 'Flag for moderator attention', 'text' => 'Flag for moderator attention',
'simple-action' => \Chibi\Router::linkTo(['PostController', 'flagAction'], ['id' => $this->context->transport->post->id]), 'simple-action' => \Chibi\Router::linkTo(
['PostController', 'flagAction'],
['id' => $this->context->transport->post->id]),
'data-confirm-text' => 'Are you sure you want to flag this post?', 'data-confirm-text' => 'Are you sure you want to flag this post?',
]; ];
} }
} }
if (Access::check(Privilege::HidePost, Access::getIdentity($this->context->transport->post->getUploader()))) if (Access::check(
Privilege::HidePost,
Access::getIdentity($this->context->transport->post->getUploader())))
{ {
if ($this->context->transport->post->hidden) if ($this->context->transport->post->hidden)
{ {
@ -278,7 +324,9 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
[ [
'class' => 'unhide', 'class' => 'unhide',
'text' => 'Unhide', 'text' => 'Unhide',
'simple-action' => \Chibi\Router::linkTo(['PostController', 'unhideAction'], ['id' => $this->context->transport->post->id]), 'simple-action' => \Chibi\Router::linkTo(
['PostController', 'unhideAction'],
['id' => $this->context->transport->post->id]),
]; ];
} }
else else
@ -287,18 +335,24 @@ $canEditAnything = count(array_filter($editPostPrivileges)) > 0;
[ [
'class' => 'hide', 'class' => 'hide',
'text' => 'Hide', 'text' => 'Hide',
'simple-action' => \Chibi\Router::linkTo(['PostController', 'hideAction'], ['id' => $this->context->transport->post->id]), 'simple-action' => \Chibi\Router::linkTo(
['PostController', 'hideAction'],
['id' => $this->context->transport->post->id]),
]; ];
} }
} }
if (Access::check(Privilege::DeletePost, Access::getIdentity($this->context->transport->post->getUploader()))) if (Access::check(
Privilege::DeletePost,
Access::getIdentity($this->context->transport->post->getUploader())))
{ {
$options []= $options []=
[ [
'class' => 'delete', 'class' => 'delete',
'text' => 'Delete', 'text' => 'Delete',
'simple-action' => \Chibi\Router::linkTo(['PostController', 'deleteAction'], ['id' => $this->context->transport->post->id]), 'simple-action' => \Chibi\Router::linkTo(
['PostController', 'deleteAction'],
['id' => $this->context->transport->post->id]),
'data-confirm-text' => 'Are you sure you want to delete this post?', 'data-confirm-text' => 'Are you sure you want to delete this post?',
'data-redirect-url' => \Chibi\Router::linkTo(['PostController', 'listAction']), 'data-redirect-url' => \Chibi\Router::linkTo(['PostController', 'listAction']),
]; ];

View file

@ -35,7 +35,8 @@
<?php $name = $tag['name'] ?> <?php $name = $tag['name'] ?>
<?php $count = $tag['post_count'] ?> <?php $count = $tag['post_count'] ?>
<li class="tag" title="<?= $name ?> (<?= $count ?>)"> <li class="tag" title="<?= $name ?> (<?= $count ?>)">
<a href="<?= str_replace('_query_', $name, $url) ?>" class="frequency<?php printf('%1.0f', $add + $mul * log($count)) ?>"> <a href="<?= str_replace('_query_', $name, $url) ?>"
class="frequency<?php printf('%1.0f', $add + $mul * log($count)) ?>">
<?= $name . ' (' . $count . ')' ?> <?= $name . ' (' . $count . ')' ?>
</a> </a>
</li> </li>

View file

@ -112,11 +112,20 @@
Privilege::ListPosts, Privilege::ListPosts,
PostSafety::toString($safety))): ?> PostSafety::toString($safety))): ?>
<li class="safety-<?= TextCaseConverter::convert(PostSafety::toString($safety), TextCaseConverter::CAMEL_CASE, TextCaseConverter::SPINAL_CASE) ?>"> <li class="safety-<?= TextCaseConverter::convert(
PostSafety::toString($safety),
TextCaseConverter::CAMEL_CASE,
TextCaseConverter::SPINAL_CASE) ?>">
<a class="<?= $this->context->user->hasEnabledSafety($safety) ? 'enabled' : 'disabled' ?>" <a class="<?= $this->context->user->hasEnabledSafety($safety) ? 'enabled' : 'disabled' ?>"
href="<?= \Chibi\Router::linkTo(['UserController', 'toggleSafetyAction'], ['safety' => $safety]) ?>" href="<?= \Chibi\Router::linkTo(
title="Searching <?= PostSafety::toDisplayString($safety) ?> posts: <?= $this->context->user->hasEnabledSafety($safety) ? 'enabled' : 'disabled' ?>"> ['UserController', 'toggleSafetyAction'],
['safety' => $safety]) ?>"
title="<?= sprintf('Searching %s posts: %s',
PostSafety::toDisplayString($safety),
$this->context->user->hasEnabledSafety($safety)
? 'enabled'
: 'disabled') ?>">
<span><?= ucfirst(PostSafety::toDisplayString($safety)) ?></span> <span><?= ucfirst(PostSafety::toDisplayString($safety)) ?></span>
@ -137,7 +146,9 @@
type="search" type="search"
name="query" name="query"
placeholder="Search&hellip;" placeholder="Search&hellip;"
value="<?= isset($this->context->transport->searchQuery) ? htmlspecialchars($this->context->transport->searchQuery) : '' ?>"/> value="<?= isset($this->context->transport->searchQuery)
? htmlspecialchars($this->context->transport->searchQuery)
: '' ?>"/>
</form> </form>
</li> </li>

View file

@ -1,5 +1,7 @@
<form <form
action="<?= \Chibi\Router::linkTo(['UserController', 'deleteAction'], ['name' => $this->context->transport->user->name]) ?>" action="<?= \Chibi\Router::linkTo(
['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name]) ?>"
method="post" method="post"
class="delete confirmable" class="delete confirmable"
autocomplete="off" autocomplete="off"

View file

@ -1,4 +1,11 @@
<form action="<?= \Chibi\Router::linkTo(['UserController', 'editAction'], ['name' => $this->context->transport->user->name]) ?>" method="post" class="edit" autocomplete="off"> <form
action="<?= \Chibi\Router::linkTo(
['UserController', 'editAction'],
['name' => $this->context->transport->user->name]) ?>"
method="post"
class="edit"
autocomplete="off">
<?php if ($this->context->user->id == $this->context->transport->user->id): ?> <?php if ($this->context->user->id == $this->context->transport->user->id): ?>
<div class="form-row current-password"> <div class="form-row current-password">
<label for="current-password">Current password:</label> <label for="current-password">Current password:</label>

View file

@ -27,7 +27,9 @@ if ($this->context->user->hasEnabledEndlessScrolling())
<?php else: ?> <?php else: ?>
<li> <li>
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'listAction'], ['filter' => $key]) ?>"><?= $text ?></a> <a href="<?= \Chibi\Router::linkTo(['UserController', 'listAction'], ['filter' => $key]) ?>">
<?= $text ?>
</a>
</li> </li>
<?php endforeach ?> <?php endforeach ?>
</ul> </ul>
@ -40,12 +42,16 @@ if ($this->context->user->hasEnabledEndlessScrolling())
<div class="users paginator-content"> <div class="users paginator-content">
<?php foreach ($this->context->transport->users as $user): ?> <?php foreach ($this->context->transport->users as $user): ?>
<div class="user"> <div class="user">
<a class="avatar" href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $user->name]) ?>"> <a class="avatar" href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $user->name]) ?>">
<img src="<?= htmlspecialchars($user->getAvatarUrl(100)) ?>" alt="<?= $user->name ?>"/> <img src="<?= htmlspecialchars($user->getAvatarUrl(100)) ?>" alt="<?= $user->name ?>"/>
</a> </a>
<div class="details"> <div class="details">
<h1> <h1>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $user->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $user->name]) ?>">
<?= $user->name ?> <?= $user->name ?>
</a> </a>
</h1> </h1>

View file

@ -9,7 +9,11 @@ Assets::setSubTitle('registration form');
Assets::addStylesheet('auth.css'); Assets::addStylesheet('auth.css');
?> ?>
<form action="<?= \Chibi\Router::linkTo(['UserController', 'registrationAction']) ?>" class="auth register" method="post"> <form
action="<?= \Chibi\Router::linkTo(['UserController', 'registrationAction']) ?>"
class="auth register"
method="post">
<p>Registered users can view more content,<br/>upload files and add posts to favorites.</p> <p>Registered users can view more content,<br/>upload files and add posts to favorites.</p>
<div class="form-row"> <div class="form-row">

View file

@ -1,4 +1,10 @@
<form action="<?= \Chibi\Router::linkTo(['UserController', 'settingsAction'], ['name' => $this->context->transport->user->name]) ?>" method="post" class="settings"> <form
action="<?= \Chibi\Router::linkTo(
['UserController', 'settingsAction'],
['name' => $this->context->transport->user->name]) ?>"
method="post"
class="settings">
<div class="form-row safety"> <div class="form-row safety">
<label>Safety:</label> <label>Safety:</label>
<div class="input-wrapper"> <div class="input-wrapper">

View file

@ -5,7 +5,10 @@ Assets::addStylesheet('user-view.css');
<div id="sidebar"> <div id="sidebar">
<div class="avatar-wrapper"> <div class="avatar-wrapper">
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], ['name' => $this->context->transport->user->name]) ?>"> <a href="<?= \Chibi\Router::linkTo(
['UserController', 'viewAction'],
['name' => $this->context->transport->user->name]) ?>">
<img <img
src="<?= htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>" src="<?= htmlspecialchars($this->context->transport->user->getAvatarUrl(140)) ?>"
alt="<?= $this->context->transport->user->name ?>"/> alt="<?= $this->context->transport->user->name ?>"/>
@ -93,8 +96,9 @@ Assets::addStylesheet('user-view.css');
[ [
'class' => 'edit', 'class' => 'edit',
'text' => 'Edit account settings', 'text' => 'Edit account settings',
'link' => \Chibi\Router::linkTo(['UserController', 'editAction'], [ 'link' => \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name, 'tab' => 'edit']), ['UserController', 'editAction'],
['name' => $this->context->transport->user->name, 'tab' => 'edit']),
]; ];
} }
@ -106,8 +110,9 @@ Assets::addStylesheet('user-view.css');
[ [
'class' => 'accept-registration', 'class' => 'accept-registration',
'text' => 'Accept registration', 'text' => 'Accept registration',
'simple-action' => \Chibi\Router::linkTo(['UserController', 'acceptRegistrationAction'], [ 'simple-action' => \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]), ['UserController', 'acceptRegistrationAction'],
['name' => $this->context->transport->user->name]),
]; ];
} }
@ -130,8 +135,9 @@ Assets::addStylesheet('user-view.css');
[ [
'class' => 'flag', 'class' => 'flag',
'text' => 'Flag for moderator attention', 'text' => 'Flag for moderator attention',
'simple-action' => \Chibi\Router::linkTo(['UserController', 'flagAction'], [ 'simple-action' => \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]), ['UserController', 'flagAction'],
['name' => $this->context->transport->user->name]),
'data-confirm-text' => 'Are you sure you want to flag this user?', 'data-confirm-text' => 'Are you sure you want to flag this user?',
]; ];
} }
@ -147,8 +153,9 @@ Assets::addStylesheet('user-view.css');
[ [
'class' => 'ban', 'class' => 'ban',
'text' => 'Ban user', 'text' => 'Ban user',
'simple-action' => \Chibi\Router::linkTo(['UserController', 'banAction'], [ 'simple-action' => \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]), ['UserController', 'banAction'],
['name' => $this->context->transport->user->name]),
'data-confirm-text' => 'Are you sure you want to ban this user?', 'data-confirm-text' => 'Are you sure you want to ban this user?',
]; ];
} }
@ -158,8 +165,9 @@ Assets::addStylesheet('user-view.css');
[ [
'class' => 'unban', 'class' => 'unban',
'text' => 'Unban user', 'text' => 'Unban user',
'simple-action' => \Chibi\Router::linkTo(['UserController', 'unbanAction'], [ 'simple-action' => \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]), ['UserController', 'unbanAction'],
['name' => $this->context->transport->user->name]),
'data-confirm-text' => 'Are you sure you want to unban this user?', 'data-confirm-text' => 'Are you sure you want to unban this user?',
]; ];
} }
@ -173,8 +181,9 @@ Assets::addStylesheet('user-view.css');
[ [
'class' => 'delete', 'class' => 'delete',
'text' => 'Delete account', 'text' => 'Delete account',
'link' => \Chibi\Router::linkTo(['UserController', 'deleteAction'], [ 'link' => \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name, 'tab' => 'delete']), ['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name, 'tab' => 'delete']),
]; ];
} }
@ -191,8 +200,9 @@ Assets::addStylesheet('user-view.css');
<?php else: ?> <?php else: ?>
<li class="favs"> <li class="favs">
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], [ <a href="<?= \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name, ['UserController', 'viewAction'],
['name' => $this->context->transport->user->name,
'tab' => 'favs', 'tab' => 'favs',
'page' => 1]) ?>"> 'page' => 1]) ?>">
Favs Favs
@ -204,8 +214,9 @@ Assets::addStylesheet('user-view.css');
<?php else: ?> <?php else: ?>
<li class="uploads"> <li class="uploads">
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'viewAction'], [ <a href="<?= \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name, ['UserController', 'viewAction'],
['name' => $this->context->transport->user->name,
'tab' => 'uploads', 'tab' => 'uploads',
'page' => 1]) ?>"> 'page' => 1]) ?>">
Uploads Uploads
@ -221,8 +232,9 @@ Assets::addStylesheet('user-view.css');
<?php else: ?> <?php else: ?>
<li class="settings"> <li class="settings">
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'settingsAction'], [ <a href="<?= \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]) ?>"> ['UserController', 'settingsAction'],
['name' => $this->context->transport->user->name]) ?>">
Browsing settings Browsing settings
</a> </a>
</li> </li>
@ -234,8 +246,9 @@ Assets::addStylesheet('user-view.css');
<?php else: ?> <?php else: ?>
<li class="edit"> <li class="edit">
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'editAction'], [ <a href="<?= \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]) ?>"> ['UserController', 'editAction'],
['name' => $this->context->transport->user->name]) ?>">
Account settings Account settings
</a> </a>
</li> </li>
@ -249,8 +262,9 @@ Assets::addStylesheet('user-view.css');
<?php else: ?> <?php else: ?>
<li class="delete"> <li class="delete">
<?php endif ?> <?php endif ?>
<a href="<?= \Chibi\Router::linkTo(['UserController', 'deleteAction'], [ <a href="<?= \Chibi\Router::linkTo(
'name' => $this->context->transport->user->name]) ?>"> ['UserController', 'deleteAction'],
['name' => $this->context->transport->user->name]) ?>">
Delete account Delete account
</a> </a>
</li> </li>