From 91dcc787964671e3e32212214fc1568393c0eb03 Mon Sep 17 00:00:00 2001 From: Thomas Keller Date: Tue, 27 Dec 2011 03:34:53 +0100 Subject: [PATCH] Render tags that are set on many projects larger and tags that are set on only few projects smaller. --- src/IDF/Forge.php | 6 ++++++ src/IDF/templates/idf/listProjects.html | 7 ++++++- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/src/IDF/Forge.php b/src/IDF/Forge.php index 832323d..df199a0 100644 --- a/src/IDF/Forge.php +++ b/src/IDF/Forge.php @@ -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; diff --git a/src/IDF/templates/idf/listProjects.html b/src/IDF/templates/idf/listProjects.html index aa340e6..6359e1e 100644 --- a/src/IDF/templates/idf/listProjects.html +++ b/src/IDF/templates/idf/listProjects.html @@ -19,7 +19,12 @@
{foreach $projectLabels as $class => $labels}
{$class}
{foreach $labels as $idx => $label} -
{$label.name}{if $idx != count($labels) - 1},{/if}
+ {* 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} +
{$label.name}{if $idx != count($labels) - 1},{/if}
{/foreach} {/foreach}
{if $tag}