summaryrefslogtreecommitdiff
path: root/modules/tag/helpers
diff options
context:
space:
mode:
authorBharat Mediratta <bharat@menalto.com>2008-11-27 05:37:20 +0000
committerBharat Mediratta <bharat@menalto.com>2008-11-27 05:37:20 +0000
commit72d16756b169e1f751470670eececf76e88b2bd7 (patch)
tree7e49f000e23a7ae54c69d081f264bc378903a0d3 /modules/tag/helpers
parent5447b8321080afd09387d837a4acfa9c90ddfa16 (diff)
Refactor cloud generation into a helper so that we can call it from
Tags_Controller::_index(). This enables our Ajax code to reload the tags block after we submit a new tag, so update the JS to do that properly.
Diffstat (limited to 'modules/tag/helpers')
-rw-r--r--modules/tag/helpers/tag.php17
-rw-r--r--modules/tag/helpers/tag_block.php16
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;