diff options
Diffstat (limited to 'modules/tag/helpers')
| -rw-r--r-- | modules/tag/helpers/tag.php | 17 | ||||
| -rw-r--r-- | modules/tag/helpers/tag_block.php | 16 |
2 files changed, 20 insertions, 13 deletions
diff --git a/modules/tag/helpers/tag.php b/modules/tag/helpers/tag.php index a1939df7..23edc5f2 100644 --- a/modules/tag/helpers/tag.php +++ b/modules/tag/helpers/tag.php @@ -61,4 +61,21 @@ class tag_Core { ->limit($count) ->find_all(); } + + /** + * Return a rendering of the cloud for the N most popular tags. + * + * @param integer $count the number of tags + * @return View + */ + public static function cloud($count) { + $tags = tag::popular_tags($count)->as_array(); + if ($tags) { + $cloud = new View("tag_block_cloud.html"); + $cloud->max_count = $tags[0]->count; + usort($tags, array("tag_block", "sort_by_name")); + $cloud->tags = $tags; + return $cloud; + } + } } diff --git a/modules/tag/helpers/tag_block.php b/modules/tag/helpers/tag_block.php index c735ee04..02a536ad 100644 --- a/modules/tag/helpers/tag_block.php +++ b/modules/tag/helpers/tag_block.php @@ -28,23 +28,13 @@ class tag_block_Core { $block->id = "gTag"; $block->title = _("Tags"); $block->content = new View("tag_block.html"); - - $tags = tag::popular_tags(30)->as_array(); - if ($tags) { - $block->content->max_count = $tags[0]->count; - - usort($tags, array("tag_block", "sort_by_name")); - $block->content->tags = $tags; - if ($block->content->page_type != "tag") { - $block->content->item = $theme->item(); - } - } else { - $block->content->tags = array(); - } + $block->content->cloud = tag::cloud(30); if ($theme->page_type() != "tag") { $controller = new Tags_Controller(); $block->content->form = $controller->form_add($theme->item()); + } else { + $block->content->form = ""; } return $block; |
