2013-10-12 22:37:18 +02:00
< 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 = "inactive" >
<?php endif ?>
< i class = "icon-next" > < / i >
< span > next post< / span >
< / a >
< / div >
2013-10-12 10:46:15 +02:00
2013-10-12 22:37:18 +02:00
< 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 = "inactive" >
<?php endif ?>
< span > prev post< / span >
< i class = "icon-prev" > < / i >
< / a >
< / div >
2013-10-12 10:46:15 +02:00
2013-10-12 22:37:18 +02:00
< div class = "clear" > < / div >
< / nav >
< div class = "sidebar-unit tags" >
< h1 > tags (<?php echo count ( $this -> context -> transport -> post -> sharedTag ) ?> )</ h1 >
< ul >
<?php foreach ( $this -> context -> transport -> post -> sharedTag as $tag ) : ?>
< li >
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'list' , [ 'query' => $tag -> name ]) ?> " >
<?php echo $tag -> name ?>
< / a >
< span class = "count" >
<?php echo TextHelper :: useDecimalUnits ( $this -> context -> transport -> tagDistribution [ $tag -> name ]) ?>
< / span >
< / li >
<?php endforeach ?>
< / ul >
< / div >
< div class = "sidebar-unit details" >
< h1 > details< / h1 >
< div class = "safety" >
< span class = "key" > Safety:< / span >
< span class = "value" > <?php echo PostSafety :: toString ( $this -> context -> transport -> post -> safety ) ?> </ span >
< / div >
< div class = "uploader" >
< span class = "key" > Uploader:< / span >
< span class = "value" >
2013-10-14 10:22:53 +02:00
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'user' , 'view' , [ 'name' => $this -> context -> transport -> post -> uploader -> name ]) ?> " >
2013-10-12 22:37:18 +02:00
<?php echo $this -> context -> transport -> post -> uploader -> name ?>
2013-10-12 10:46:15 +02:00
< / a >
2013-10-12 22:37:18 +02:00
< / span >
< / div >
< div class = "date" >
< span class = "key" > Date:< / span >
< span class = "value" > <?php echo date ( 'Y-m-d H:i' , $this -> context -> transport -> post -> upload_date ) ?> </ span >
< / div >
<?php if ( $this -> context -> transport -> post -> image_width > 0 ) : ?>
< div class = "dim" >
< span class = "key" > Dimensions:< / span >
< span class = "value" > <?php printf ( '%dx%d' ,
$this->context->transport->post->image_width,
$this->context->transport->post->image_height) ?>< / span >
2013-10-12 10:46:15 +02:00
< / div >
2013-10-12 22:37:18 +02:00
<?php endif ?>
2013-10-12 10:46:15 +02:00
2013-10-12 22:37:18 +02:00
< div class = "permalink" >
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'retrieve' , [ 'name' => $this -> context -> transport -> post -> name ]) ?> " alt = " <?php echo $this -> context -> transport -> post -> name ?> " >
< i class = "icon-dl" > < / i >
< span class = "ext" >
<?php echo strtoupper ( substr ( $this -> context -> transport -> post -> orig_name , strrpos ( $this -> context -> transport -> post -> orig_name , '.' ) + 1 )) ?>
< / span >
< span class = "size" >
<?php echo TextHelper :: useBytesUnits ( $this -> context -> transport -> post -> file_size ) ?>
< / span >
< / a >
< / div >
< / div >
2013-10-12 10:46:15 +02:00
2013-10-12 22:37:18 +02:00
< div class = "sidebar-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 >
2013-10-12 10:46:15 +02:00
< ul >
2013-10-12 22:37:18 +02:00
<?php foreach ( $this -> context -> transport -> post -> via ( 'favoritee' ) -> sharedUser as $user ) : ?>
2013-10-12 10:46:15 +02:00
< li >
2013-10-12 22:37:18 +02:00
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'user' , 'view' , [ 'name' => $user -> name ]) ?> " >
2013-10-14 00:25:40 +02:00
< img src = " <?php echo $user -> getAvatarUrl () ?> " alt = " <?php echo $user -> name ?> " >
2013-10-12 10:46:15 +02:00
< / a >
< / li >
<?php endforeach ?>
< / ul >
2013-10-12 22:37:18 +02:00
<?php endif ?>
< / div >
2013-10-12 12:38:49 +02:00
2013-10-12 22:37:18 +02:00
< div class = "sidebar-unit options" >
< h1 > options< / h1 >
2013-10-12 12:38:49 +02:00
2013-10-13 12:28:16 +02:00
< ul >
<?php if ( PrivilegesHelper :: confirm ( $this -> context -> user , Privilege :: FavoritePost )) : ?>
<?php if ( ! $this -> context -> favorite ) : ?>
< li class = "add-fav" >
< a 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 href = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'rem-favorite' , [ 'id' => $this -> context -> transport -> post -> id ]) ?> " >
Remove from favorites
< / a >
< / li >
2013-10-12 22:37:18 +02:00
<?php endif ?>
2013-10-13 12:28:16 +02:00
<?php endif ?>
2013-10-12 10:46:15 +02:00
2013-10-13 12:28:16 +02:00
<?php
$secondary = $this->context->transport->post->uploader->id == $this->context->user->id ? 'own' : 'all';
$editPostPrivileges = [
Privilege::EditPostSafety,
Privilege::EditPostTags,
Privilege::EditPostThumb,
];
$editPostPrivileges = array_fill_keys($editPostPrivileges, false);
foreach (array_keys($editPostPrivileges) as $privilege)
{
if (PrivilegesHelper::confirm($this->context->user, $privilege, $secondary))
$editPostPrivileges[$privilege] = true;
}
$canEditAnything = count(array_filter($editPostPrivileges)) > 0;
?>
<?php if ( $canEditAnything ) : ?>
< li class = "edit" >
2013-10-12 22:37:18 +02:00
< a href = "#" >
2013-10-13 12:28:16 +02:00
Edit
2013-10-12 22:37:18 +02:00
< / a >
< / li >
2013-10-13 12:28:16 +02:00
<?php endif ?>
2013-10-12 14:53:47 +02:00
2013-10-13 12:28:16 +02:00
<?php if ( PrivilegesHelper :: confirm ( $this -> context -> user , Privilege :: HidePost , $secondary )) : ?>
<?php if ( $this -> context -> transport -> post -> hidden ) : ?>
< li class = "unhide" >
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'unhide' , [ 'id' => $this -> context -> transport -> post -> id ]) ?> " >
Unhide
< / a >
< / li >
<?php else : ?>
< li class = "hide" >
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'hide' , [ 'id' => $this -> context -> transport -> post -> id ]) ?> " >
Hide
< / a >
< / li >
<?php endif ?>
<?php endif ?>
2013-10-12 14:53:47 +02:00
2013-10-13 12:28:16 +02:00
<?php if ( PrivilegesHelper :: confirm ( $this -> context -> user , Privilege :: DeletePost , $secondary )) : ?>
< li class = "delete" >
< a href = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'delete' , [ 'id' => $this -> context -> transport -> post -> id ]) ?> " data-confirm-text = "Are you sure?" data-redirect-url = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'list' ) ?> " >
Delete
2013-10-12 22:37:18 +02:00
< / a >
< / li >
2013-10-13 12:28:16 +02:00
<?php endif ?>
< / ul >
2013-10-12 10:46:15 +02:00
2013-10-12 22:37:18 +02:00
< script type = "text/javascript" >
if (!$('.options ul li').length)
$('.options').hide();
< / script >
2013-10-12 10:46:15 +02:00
< / div >
2013-10-12 22:37:18 +02:00
< / div >
< div id = "inner-content" >
< div class = "post-wrapper" >
<?php if ( $this -> context -> transport -> post -> type == 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 elseif ( $this -> context -> transport -> post -> type == 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 endif ?>
< / div >
2013-10-13 12:28:16 +02:00
<?php if ( $canEditAnything ) : ?>
< form action = " <?php echo \Chibi\UrlHelper :: route ( 'post' , 'edit' , [ 'id' => $this -> context -> transport -> post -> id ]) ?> " method = "post" enctype = "multiplart/form-data" class = "edit" >
< h1 > edit post< / h1 >
<?php if ( $editPostPrivileges [ Privilege :: EditPostSafety ]) : ?>
< div class = "safety" >
< label class = "left" > Safety:< / label >
<?php foreach ( PostSafety :: getAll () as $safety ) : ?>
< label >
< input type = "radio" name = "safety" value = " <?php echo $safety ?> " <?php if ( $this -> context -> transport -> post -> safety == $safety ) echo 'checked="checked"' ?> />
<?php echo PostSafety :: toString ( $safety ) ?>
< / label >
<?php endforeach ?>
< / div >
<?php endif ?>
<?php if ( $editPostPrivileges [ Privilege :: EditPostTags ]) : ?>
< div class = "tags" >
< label class = "left" for = "tags" > Tags:< / label >
< input type = "text" name = "tags" id = "tags" placeholder = "enter some tags…" value = " <?php echo join ( ',' , array_map ( function ( $tag ) { return $tag -> name ; }, $this -> context -> transport -> post -> sharedTag )) ?> " />
< / div >
< input type = "hidden" name = "tags-token" id = "tags-token" value = " <?php echo $this -> context -> transport -> tagsToken ?> " />
<?php endif ?>
<?php if ( $editPostPrivileges [ Privilege :: EditPostThumb ]) : ?>
< div class = "thumb" >
< label class = "left" for = "thumb" > Thumb:< / label >
< input type = "file" name = "thumb" id = "thumb" / >
< / div >
<?php endif ?>
< div >
< label class = "left" > < / label >
< button type = "submit" > Submit< / button >
< / div >
< / form >
<?php endif ?>
2013-10-12 22:37:18 +02:00
< / div >