Commit 3ecffa5e by Scott

Refactor qa-tag-cloud.php

parent f7b60026
...@@ -24,14 +24,16 @@ class qa_tag_cloud ...@@ -24,14 +24,16 @@ class qa_tag_cloud
{ {
public function option_default($option) public function option_default($option)
{ {
if ($option === 'tag_cloud_count_tags') switch ($option) {
return 100; case 'tag_cloud_count_tags':
if ($option === 'tag_cloud_font_size') return 100;
return 24; case 'tag_cloud_font_size':
if ($option === 'tag_cloud_minimal_font_size') return 24;
return 10; case 'tag_cloud_minimal_font_size':
if ($option === 'tag_cloud_size_popular') return 10;
return true; case 'tag_cloud_size_popular':
return true;
}
} }
...@@ -131,16 +133,20 @@ class qa_tag_cloud ...@@ -131,16 +133,20 @@ class qa_tag_cloud
foreach ($populartagslog as $tag => $count) { foreach ($populartagslog as $tag => $count) {
$matches = qa_block_words_match_all($tag, $blockwordspreg); $matches = qa_block_words_match_all($tag, $blockwordspreg);
if (empty($matches)) { if (!empty($matches)) {
if ($scale) { continue;
$size = number_format($maxsize * $count / $maxcount, 1); }
if ($size < $minsize)
$size = $minsize; if ($scale) {
} else $size = number_format($maxsize * $count / $maxcount, 1);
$size = $maxsize; if ($size < $minsize) {
$size = $minsize;
$themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag))); }
} else {
$size = $maxsize;
} }
$themeobject->output(sprintf('<a href="%s" style="font-size: %dpx; vertical-align: baseline;">%s</a>', qa_path_html('tag/' . $tag), $size, qa_html($tag)));
} }
$themeobject->output('</div>'); $themeobject->output('</div>');
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment