Added tag sorting here and there

- Title attribute in post thumbnail
- Page title in post view
- Footer in featured post
This commit is contained in:
Marcin Kurczewski 2013-12-14 16:55:07 +01:00
parent 1c6b10f966
commit 95961fe7d5
4 changed files with 20 additions and 9 deletions

View file

@ -483,7 +483,7 @@ class PostController
$this->context->stylesheets []= 'post-view.css'; $this->context->stylesheets []= 'post-view.css';
$this->context->stylesheets []= 'comment-small.css'; $this->context->stylesheets []= 'comment-small.css';
$this->context->scripts []= 'post-view.js'; $this->context->scripts []= 'post-view.js';
$this->context->subTitle = 'showing @' . $post->id . ' – ' . join(', ', array_map(function($x) { return $x['name']; }, $post->sharedTag)); $this->context->subTitle = 'showing ' . TextHelper::reprPost($post) . ' – ' . TextHelper::reprTags($post->sharedTag);
$this->context->favorite = $favorite; $this->context->favorite = $favorite;
$this->context->score = $score; $this->context->score = $score;
$this->context->flagged = $flagged; $this->context->flagged = $flagged;

View file

@ -197,6 +197,15 @@ class TextHelper
return '#' . $tag->name; return '#' . $tag->name;
} }
public static function reprTags($tags)
{
$x = [];
foreach ($tags as $tag)
$x []= self::reprTag($tag);
natcasesort($x);
return join(', ', $x);
}
public static function encrypt($text) public static function encrypt($text)
{ {
$salt = \Chibi\Registry::getConfig()->main->salt; $salt = \Chibi\Registry::getConfig()->main->salt;

View file

@ -16,7 +16,9 @@
<div class="left"> <div class="left">
Tags:&nbsp; Tags:&nbsp;
<ul class="tags"> <ul class="tags">
<?php foreach ($this->context->featuredPost->sharedTag as $tag): ?> <?php $tags = $this->context->featuredPost->sharedTag ?>
<?php uasort($tags, function($a, $b) { return strnatcasecmp($a->name, $b->name); }) ?>
<?php foreach ($tags as $tag): ?>
<li> <li>
<a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tag->name]) ?>"> <a href="<?php echo \Chibi\UrlHelper::route('post', 'list', ['query' => $tag->name]) ?>">
<?php echo $tag->name ?> <?php echo $tag->name ?>

View file

@ -15,7 +15,7 @@
<?php endif ?> <?php endif ?>
<?php if ($this->context->user->hasEnabledPostTagTitles()): ?> <?php if ($this->context->user->hasEnabledPostTagTitles()): ?>
<a title="<?php echo join(', ', array_map(['TextHelper', 'reprTag'], $this->context->post->sharedTag)) ?>" class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>"> <a title="<?php echo TextHelper::reprTags($this->context->post->sharedTag) ?>" class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>">
<?php else: ?> <?php else: ?>
<a class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>"> <a class="link" href="<?php echo \Chibi\UrlHelper::route('post', 'view', ['id' => $this->context->post->id]) ?>">
<?php endif ?> <?php endif ?>