Commit 3ecffa5e by Scott

Refactor qa-tag-cloud.php

parent f7b60026
...@@ -24,15 +24,17 @@ class qa_tag_cloud ...@@ -24,15 +24,17 @@ class qa_tag_cloud
{ {
public function option_default($option) public function option_default($option)
{ {
if ($option === 'tag_cloud_count_tags') switch ($option) {
case 'tag_cloud_count_tags':
return 100; return 100;
if ($option === 'tag_cloud_font_size') case 'tag_cloud_font_size':
return 24; return 24;
if ($option === 'tag_cloud_minimal_font_size') case 'tag_cloud_minimal_font_size':
return 10; return 10;
if ($option === 'tag_cloud_size_popular') case 'tag_cloud_size_popular':
return true; return true;
} }
}
public function admin_form() public function admin_form()
...@@ -131,17 +133,21 @@ class qa_tag_cloud ...@@ -131,17 +133,21 @@ 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)) {
continue;
}
if ($scale) { if ($scale) {
$size = number_format($maxsize * $count / $maxcount, 1); $size = number_format($maxsize * $count / $maxcount, 1);
if ($size < $minsize) if ($size < $minsize) {
$size = $minsize; $size = $minsize;
} else }
} else {
$size = $maxsize; $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(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