New version of tag_print_cloud(). The old one ranked all tags and allocated class based on position in the sequence so it was stuck for instances with only a small number of positions in the hierarchy. This one allocates based on (tag count / count of most used tag * 20), so it still works for a very flat hierarchy.
Sorry its not a proper patch!
function tag_print_cloud($nr_of_tags=150, $return=false) {
global $CFG;
$can_manage_tags = has_capability('moodle/tag:manage', get_context_instance(CONTEXT_SYSTEM));
if ( !$tagcloud = get_records_sql('SELECT tg.rawname, tg.id, tg.name, tg.tagtype, COUNT(ti.id) AS count, tg.flag '.
'FROM '. $CFG->prefix .'tag_instance ti INNER JOIN '. $CFG->prefix .'tag tg ON tg.id = ti.tagid '.
'WHERE ti.itemtype != \'tag\' '.
'GROUP BY tg.id, tg.rawname, tg.name, tg.flag, tg.tagtype '.
'ORDER BY count DESC, tg.name ASC', 0, $nr_of_tags) ) {
$tagcloud = array();
}
$tagkeys = array_keys($tagcloud);
$firsttagkey = $tagkeys[0];
$maxcount = $tagcloud[$firsttagkey]->count;
$etags = array();
foreach ($tagcloud as $tag) {
$size = ((int)((($tag->count) / $maxcount) * 20));
$tag->class = "$tag->tagtype s$size";
$etags[] = $tag;
}
usort($etags, "tag_cloud_sort");
$output = '';
$output .= "\n<ul class='tag_cloud inline-list'>\n";
foreach ($etags as $tag) {
if ($tag->flag > 0 && $can_manage_tags) {
$tagname = '<span class="flagged-tag">'. tag_display_name($tag) .'</span>';
} else {
$tagname = tag_display_name($tag);
}
$link = $CFG->wwwroot .'/tag/index.php?tag='. rawurlencode($tag->name);
$output .= '<li><a href="'. $link .'" class="'. $tag->class .'" '.
'title="'. get_string('numberofentries', 'blog', $tag->count) .'">'.
$tagname .'</a></li> ';
}
$output .= "\n</ul>\n";
if ($return) {
return $output;
} else {
echo $output;
}
}
This is very theme-specific. You can (easily?) change the size of each of the 20 sizes to what you want by overriding the css for ".content .tag_cloud" (to specifiy the base font size) and ".tag_cloud .s??" (for each tag size). The default size range goes from 0.82em to 1.2em.
The default size might not be optimal, but I am really not the best one for this. I think the default size haven't really changed.. Though, both tag blocks have been made to use the same css styles, for consistency reasons (and to make it easier the day they get merged).
I'm adding Urs to this discussion, he'll have a better idea than me of what the default css should be like.