Fixed colors in tags pagination

Each page had recalculated tag opacity on its own. Now it's calculated against
global maximum.
This commit is contained in:
Marcin Kurczewski 2014-02-25 13:08:41 +01:00
parent c29a002c06
commit 06cdebaccb
3 changed files with 14 additions and 1 deletions

View file

@ -34,6 +34,7 @@ class TagController
}
else
{
$this->context->highestUsage = TagSearchService::getMostUsedTag()['post_count'];
$this->context->transport->paginator = new StdClass;
$this->context->transport->paginator->page = $page;
$this->context->transport->paginator->pageCount = $pageCount;

View file

@ -5,4 +5,16 @@ class TagSearchService extends AbstractSearchService
{
$stmt->addColumn(new SqlAliasFunctor(new SqlCountFunctor('post_tag.post_id'), 'post_count'));
}
public static function getMostUsedTag()
{
$stmt = new SqlSelectStatement();
$stmt->setTable('post_tag');
$stmt->addColumn('tag_id');
$stmt->addColumn(new SqlAliasFunctor(new SqlCountFunctor('post_tag.post_id'), 'post_count'));
$stmt->setGroupBy('post_tag.tag_id');
$stmt->setOrderBy('post_count', SqlSelectStatement::ORDER_DESC);
$stmt->setLimit(1, 0);
return Database::fetchOne($stmt);
}
}

View file

@ -25,7 +25,7 @@
<?php if (empty($this->context->transport->tags)): ?>
<p class="alert alert-warning">No tags to show.</p>
<?php else: ?>
<?php $max = max([0]+array_map(function($x) { return $x['post_count']; }, $this->context->transport->tags)); ?>
<?php $max = $this->context->highestUsage ?>
<?php $add = 0. ?>
<?php $mul = 10. / max(1, log(max(1, $max))) ?>
<?php $url = \Chibi\UrlHelper::route('post', 'list', ['query' => '_query_']) ?>