332 lines
12 KiB
PHTML
332 lines
12 KiB
PHTML
<div id="sidebar">
|
|
<nav>
|
|
<div class="left">
|
|
<?php if ($this->context->transport->nextPostId): ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->transport->nextPostId]) ?>">
|
|
<?php else: ?>
|
|
<a class="disabled">
|
|
<?php endif ?>
|
|
<i class="icon-next"></i>
|
|
<span>next post</span>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="right">
|
|
<?php if ($this->context->transport->prevPostId): ?>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->transport->prevPostId]) ?>">
|
|
<?php else: ?>
|
|
<a class="disabled">
|
|
<?php endif ?>
|
|
<span>prev post</span>
|
|
<i class="icon-prev"></i>
|
|
</a>
|
|
</div>
|
|
|
|
<div class="clear"></div>
|
|
</nav>
|
|
|
|
<div class="unit tags">
|
|
<h1>tags (<?php echo count($this->context->transport->post->sharedTag) ?>)</h1>
|
|
<ul>
|
|
<?php $tags = $this->context->transport->post->sharedTag ?>
|
|
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
|
|
<?php foreach ($tags as $tag): ?>
|
|
<li title="<?php echo $tag->name ?>">
|
|
<a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tag->name]) ?>">
|
|
<?php echo $tag->name ?>
|
|
</a>
|
|
<span class="count">
|
|
<?php echo TextHelper::useDecimalUnits($tag->getPostCount()) ?>
|
|
</span>
|
|
</li>
|
|
<?php endforeach ?>
|
|
</ul>
|
|
</div>
|
|
|
|
<div class="unit details">
|
|
<h1>details</h1>
|
|
|
|
<div class="key-value uploader">
|
|
<span class="key">Uploader:</span>
|
|
<?php if ($this->context->transport->post->uploader): ?>
|
|
<span class="value" title="<?php echo $val = $this->context->transport->post->uploader->name ?>">
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $this->context->transport->post->uploader->name]) ?>">
|
|
<img src="<?php echo htmlentities($this->context->transport->post->uploader->getAvatarUrl(16)) ?>" alt="<?php echo $this->context->transport->post->uploader->name ?>"/>
|
|
<?php echo $val ?>
|
|
</a>
|
|
</span>
|
|
<?php else: ?>
|
|
<span class="value" title="[unknown user]">
|
|
<img src="<?php echo \Chibi\UrlHelper::absoluteUrl('/media/img/pixel.gif') ?>" alt="[unknown user]"/>
|
|
[unknown user]
|
|
</span>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<div class="key-value safety">
|
|
<span class="key">Safety:</span>
|
|
<span class="value safety-<?php echo $val = TextHelper::camelCaseToHumanCase(PostSafety::toString($this->context->transport->post->safety)) ?>" title="<?php echo $val ?>">
|
|
<?php echo $val ?>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="key-value score">
|
|
<span class="key">Score:</span>
|
|
<span class="value">
|
|
<?php echo $this->context->transport->post->score ?>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::ScorePost)): ?>
|
|
[
|
|
<?php $scoreLink = function($score) { return \Chibi\UrlHelper::route('post', 'score', ['id' => $this->context->transport->post->id, 'score' => $score]); } ?>
|
|
|
|
<?php if ($this->context->score === 1): ?>
|
|
<a class="simple-action selected" href="<?php echo $scoreLink(0) ?>">
|
|
<?php else: ?>
|
|
<a class="simple-action" href="<?php echo $scoreLink(1) ?>">
|
|
<?php endif ?>
|
|
vote up
|
|
</a>
|
|
|
|
,
|
|
|
|
<?php if ($this->context->score === -1): ?>
|
|
<a class="simple-action selected" href="<?php echo $scoreLink(0) ?>">
|
|
<?php else: ?>
|
|
<a class="simple-action" href="<?php echo $scoreLink(-1) ?>">
|
|
<?php endif ?>
|
|
down
|
|
</a>]
|
|
<?php endif ?>
|
|
</span>
|
|
</div>
|
|
|
|
<div class="key-value date">
|
|
<span class="key">Date:</span>
|
|
<span class="value" title="<?php echo $val = date('Y-m-d H:i', $this->context->transport->post->upload_date) ?>">
|
|
<?php echo $val ?>
|
|
</span>
|
|
</div>
|
|
|
|
<?php if ($this->context->transport->post->image_width > 0): ?>
|
|
<div class="key-value dim">
|
|
<span class="key">Dimensions:</span>
|
|
<span class="value" title="<?php echo $val = sprintf('%dx%d',
|
|
$this->context->transport->post->image_width,
|
|
$this->context->transport->post->image_height) ?>">
|
|
<?php echo $val ?>
|
|
</span>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<div class="key-value source">
|
|
<span class="key">Source:</span>
|
|
<span class="value" title="<?php echo $val = htmlspecialchars($this->context->transport->post->source ?: 'unknown') ?>">
|
|
<?php if (preg_match('/^((https?|ftp):|)\/\//', $val)): ?>
|
|
<a href="<?php echo $val ?>"><?php echo $val ?></a>
|
|
<?php else: ?>
|
|
<?php echo $val ?>
|
|
<?php endif ?>
|
|
</span>
|
|
</div>
|
|
|
|
<?php if ($this->context->transport->post->type != PostType::Youtube): ?>
|
|
<div class="permalink">
|
|
<a href="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" title="Download">
|
|
<i class="icon-dl"></i>
|
|
<span class="ext">
|
|
<?php $mimes = ['image/jpeg' => 'JPG', 'image/gif' => 'GIF', 'image/png' => 'PNG', 'application/x-shockwave-flash' => 'SWF'] ?>
|
|
<?php $mime = $this->context->transport->post->mimeType ?>
|
|
<?php echo isset($mimes[$mime]) ? $mimes[$mime] : 'unknown' ?>
|
|
</span>
|
|
<span class="size">
|
|
<?php echo TextHelper::useBytesUnits($this->context->transport->post->file_size) ?>
|
|
</span>
|
|
</a>
|
|
</div>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<div class="unit favorites">
|
|
<?php if (count($this->context->transport->post->ownFavoritee) == 0): ?>
|
|
<h1>favorites</h1>
|
|
<p>None yet.</p>
|
|
<?php else: ?>
|
|
<h1>favorites (<?php echo count($this->context->transport->post->ownFavoritee) ?>)</h1>
|
|
<ul>
|
|
<?php foreach ($this->context->transport->post->via('favoritee')->sharedUser as $user): ?>
|
|
<li>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('user', 'view', ['name' => $user->name]) ?>" title="<?php echo $user->name ?>">
|
|
<img src="<?php echo htmlspecialchars($user->getAvatarUrl()) ?>" alt="<?php echo $user->name ?>">
|
|
</a>
|
|
</li>
|
|
<?php endforeach ?>
|
|
</ul>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<?php if (count($this->context->transport->post->via('crossref')->sharedPost)): ?>
|
|
<div class="relations unit">
|
|
<h1>related</h1>
|
|
<ul>
|
|
<?php foreach ($this->context->transport->post->via('crossref')->sharedPost as $relatedPost): ?>
|
|
<li>
|
|
<a href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $relatedPost->id]) ?>">
|
|
@<?php echo $relatedPost->id ?>
|
|
</a>
|
|
</li>
|
|
<?php endforeach ?>
|
|
</ul>
|
|
</div>
|
|
<?php endif ?>
|
|
|
|
<div class="unit options">
|
|
<h1>options</h1>
|
|
|
|
<ul>
|
|
<?php if (PrivilegesHelper::confirm(Privilege::FavoritePost)): ?>
|
|
<?php if (!$this->context->favorite): ?>
|
|
<li class="add-fav">
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'add-favorite', ['id' => $this->context->transport->post->id]) ?>">
|
|
Add to favorites
|
|
</a>
|
|
</li>
|
|
<?php else: ?>
|
|
<li class="rem-fav">
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'rem-favorite', ['id' => $this->context->transport->post->id]) ?>">
|
|
Remove from favorites
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
<?php endif ?>
|
|
|
|
<?php
|
|
$editPostPrivileges = [
|
|
Privilege::EditPostSafety,
|
|
Privilege::EditPostTags,
|
|
Privilege::EditPostThumb,
|
|
Privilege::EditPostSource,
|
|
];
|
|
$editPostPrivileges = array_fill_keys($editPostPrivileges, false);
|
|
foreach (array_keys($editPostPrivileges) as $privilege)
|
|
{
|
|
if (PrivilegesHelper::confirm($privilege, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->uploader)))
|
|
$editPostPrivileges[$privilege] = true;
|
|
}
|
|
$canEditAnything = count(array_filter($editPostPrivileges)) > 0;
|
|
?>
|
|
|
|
<?php if ($canEditAnything): ?>
|
|
<li class="edit">
|
|
<a href="#">
|
|
Edit
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::HidePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->uploader))): ?>
|
|
<?php if ($this->context->transport->post->hidden): ?>
|
|
<li class="unhide">
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'unhide', ['id' => $this->context->transport->post->id]) ?>">
|
|
Unhide
|
|
</a>
|
|
</li>
|
|
<?php else: ?>
|
|
<li class="hide">
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'hide', ['id' => $this->context->transport->post->id]) ?>">
|
|
Hide
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
<?php endif ?>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::FeaturePost)): ?>
|
|
<li class="feature">
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'feature', ['id' => $this->context->transport->post->id]) ?>" data-confirm-text="Are you sure you want to feature this post on the main page?" data-redirect-url="<?php echo \Chibi\UrlHelper::route('index', 'index') ?>">
|
|
Feature on main page
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::FlagPost)): ?>
|
|
<li class="flag">
|
|
<?php if ($this->context->flagged): ?>
|
|
<a class="simple-action inactive" href="#">
|
|
Flagged
|
|
</a>
|
|
<?php else: ?>
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'flag', ['id' => $this->context->transport->post->id]) ?>" data-confirm-text="Are you sure you want to flag this post?">
|
|
Flag for moderator attention
|
|
</a>
|
|
<?php endif ?>
|
|
</li>
|
|
<?php endif ?>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::DeletePost, PrivilegesHelper::getIdentitySubPrivilege($this->context->transport->post->uploader))): ?>
|
|
<li class="delete">
|
|
<a class="simple-action" href="<?php echo \Chibi\UrlHelper::route('post', 'delete', ['id' => $this->context->transport->post->id]) ?>" data-confirm-text="Are you sure you want to delete this post?" data-redirect-url="<?php echo \Chibi\UrlHelper::route('post', 'list') ?>">
|
|
Delete
|
|
</a>
|
|
</li>
|
|
<?php endif ?>
|
|
</ul>
|
|
|
|
<script type="text/javascript">
|
|
if (!$('.options ul li').length)
|
|
$('.options').hide();
|
|
</script>
|
|
</div>
|
|
</div>
|
|
|
|
<div id="inner-content">
|
|
<div class="post-wrapper post-type-<?php echo strtolower(PostType::toString($this->context->transport->post->type)) ?>">
|
|
<?php switch ($this->context->transport->post->type):
|
|
case PostType::Image: ?>
|
|
<img src="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>" alt="<?php echo $this->context->transport->post->name ?>"/>
|
|
<?php break ?>
|
|
<?php case PostType::Flash: ?>
|
|
<embed width="<?php echo $this->context->transport->post->image_width ?>" height="<?php echo $this->context->transport->post->image_height ?>" type="application/x-shockwave-flash" src="<?php echo \Chibi\UrlHelper::route('post', 'retrieve', ['name' => $this->context->transport->post->name]) ?>"/>
|
|
<?php break ?>
|
|
<?php case PostType::Youtube: ?>
|
|
<iframe width="800" height="600" src="//www.youtube.com/embed/<?php echo $this->context->transport->post->orig_name ?>" frameborder="0" allowfullscreen></iframe>
|
|
<?php break ?>
|
|
<?php endswitch ?>
|
|
</div>
|
|
|
|
<?php if ($canEditAnything): ?>
|
|
<?php $this->renderFile('post-edit') ?>
|
|
<?php endif ?>
|
|
|
|
<div class="comments unit">
|
|
<?php if (empty($this->context->transport->post->ownComment)): ?>
|
|
<h1>comments</h1>
|
|
None yet.
|
|
<?php else: ?>
|
|
<h1>comments (<?php echo $this->context->transport->post->countOwn('comment') ?>)</h1>
|
|
<div class="comments">
|
|
<?php foreach ($this->context->transport->post->ownComment as $comment): ?>
|
|
<?php $this->context->comment = $comment ?>
|
|
<?php echo $this->renderFile('comment-small') ?>
|
|
<?php endforeach ?>
|
|
</div>
|
|
<?php endif ?>
|
|
</div>
|
|
|
|
<?php if (PrivilegesHelper::confirm(Privilege::AddComment)): ?>
|
|
<form action="<?php echo \Chibi\UrlHelper::route('comment', 'add', ['postId' => $this->context->transport->post->id]) ?>" method="post" class="add-comment aligned unit">
|
|
<h1>add comment</h1>
|
|
|
|
<div class="preview"></div>
|
|
|
|
<div class="text">
|
|
<div class="input-wrapper"><textarea name="text" cols="50" rows="3"></textarea></div>
|
|
</div>
|
|
|
|
<input type="hidden" name="submit" value="1"/>
|
|
|
|
<div>
|
|
<button name="sender" type="submit" value="preview">Preview</button>
|
|
<button name="sender" type="submit" value="submit">Submit</button>
|
|
</div>
|
|
</form>
|
|
<?php endif ?>
|
|
</div>
|