From: ikawhero Date: Thu, 23 Mar 2006 07:48:49 +0000 (+0000) Subject: Tidied up the class size assignments X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=e8964639ce9f8cc3ee69eb4f13f322471803705b;p=moodle.git Tidied up the class size assignments --- diff --git a/blocks/blog_tags/block_blog_tags.php b/blocks/blog_tags/block_blog_tags.php index 855787480d..a7852aa268 100644 --- a/blocks/blog_tags/block_blog_tags.php +++ b/blocks/blog_tags/block_blog_tags.php @@ -51,27 +51,44 @@ class block_blog_tags extends block_base { if ($tags = get_records_sql($sql)) { - $size = 20; $lasttagcount = -1; $sizecount = 1; + /// There are 2 things to do: + /// 1. tags with the same count should have the same size class + /// 2. however many tags we have should be spread evenly over the + /// 20 size classes + + $totaltags = count($tags); + $currenttag = 0; + + $size = 20; + $lasttagct = -1; + $etags = array(); foreach ($tags as $tag) { + + $currenttag++; + + if ($currenttag == 1) { + $lasttagct = $tag->ct; + $size = 20; + } else if ($tag->ct != $lasttagct) { + $lasttagct = $tag->ct; + $size = 20 - ( (int)((($currenttag - 1) / $totaltags) * 20) ); + } + $tag->class = "$tag->type s$size"; $etags[] = $tag; - /// Set the size class - if ($tag->ct != $lasttagcount) { - $size -= $sizecount; - $lasttagcount = $tag->ct; - $sizecount = 1; - } else { - $sizecount++; - } } + /// Now we sort the tag display order usort($etags, "blog_tags_sort"); + /// Finally we create the output foreach ($etags as $tag) { - $link = $CFG->wwwroot.'/blog/index.php?filtertype=site&tagid='.$tag->id; - $this->content->text .= ''.$tag->text.' '; + $link = $CFG->wwwroot.'/blog/index.php?courseid='. + $this->instance->pageid.'&filtertype=site&tagid='.$tag->id; + $this->content->text .= ''.$tag->text.' '; } }