Render tags that are set on many projects larger and tags that are set on

only few projects smaller.
This commit is contained in:
Thomas Keller 2011-12-27 03:34:53 +01:00
parent 5c04c87ff6
commit 91dcc78796
2 changed files with 12 additions and 1 deletions

View File

@ -60,12 +60,18 @@ class IDF_Forge
'order' => 'class ASC, lcname ASC'
));
$maxProjectCount = 0;
foreach ($tagList as $tag) {
$maxProjectCount = max($maxProjectCount, $tag->project_count);
}
$tags = array();
foreach ($tagList as $tag) {
// group by class
if (!array_key_exists($tag->class, $tags)) {
$tags[$tag->class] = array();
}
$tag->rel_project_count = $tag->project_count / (double) $maxProjectCount;
$tags[$tag->class][] = $tag;
}
return $tags;

View File

@ -19,7 +19,12 @@
<dl class="tagscloud smaller">{foreach $projectLabels as $class => $labels}
<dt class="label">{$class}</dt>
{foreach $labels as $idx => $label}
<dd><a href="{url 'IDF_Views::listProjectsByLabel', array($label->id, $order)}" class="label" title="{blocktrans $label.project_count}1 project{plural}{$label.project_count} projects{/blocktrans}">{$label.name}{if $idx != count($labels) - 1},{/if}</a></dd>
{* 0.75 - or 75% - is the minimum font size we'd like to see in this tag cloud *}
{assign $fontScale = round($label.rel_project_count * 100) + 75}
<dd><a href="{url 'IDF_Views::listProjectsByLabel', array($label->id, $order)}"
class="label"
title="{blocktrans $label.project_count}1 project{plural}{$label.project_count} projects{/blocktrans}"
style="font-size: {$fontScale}%">{$label.name}{if $idx != count($labels) - 1},{/if}</a></dd>
{/foreach}
{/foreach}</dl>
{if $tag}