diff options
-rw-r--r-- | mod/tagcloud/start.php | 38 | ||||
-rw-r--r-- | mod/tagcloud/views/default/tagcloud/extend.php | 5 | ||||
-rw-r--r-- | views/default/output/tagcloud.php | 18 |
3 files changed, 41 insertions, 20 deletions
diff --git a/mod/tagcloud/start.php b/mod/tagcloud/start.php index d026163a0..9cd9164f6 100644 --- a/mod/tagcloud/start.php +++ b/mod/tagcloud/start.php @@ -1,18 +1,28 @@ <?php - function tagcloud_init() { - add_widget_type('tagcloud', elgg_echo('tagcloud:widget:title'), elgg_echo('tagcloud:widget:description')); - - // Extend CSS +/** + * + */ + + +function tagcloud_init() { + add_widget_type('tagcloud', elgg_echo('tagcloud:widget:title'), elgg_echo('tagcloud:widget:description')); + elgg_extend_view('css','tagcloud/css'); + register_page_handler('tagcloud', 'tagcloud_page_handler'); +} + +function tagcloud_page_handler($page) { + global $CONFIG; - if(is_plugin_enabled('blog')) { - // extend blog sidebar with a tag-cloud - } - if(is_plugin_enabled('bookmarks')) { - // extend bkmrks sidebar with a tag-cloud - } - - } + switch ($page[0]) { + default: + $title = elgg_view_title(elgg_echo('tagcloud:site:title')); + $tags = display_tagcloud(0, 100, 'tags'); + $body = elgg_view_layout('one_column', $title . $tags); - register_elgg_event_handler('init', 'system', 'tagcloud_init'); -?> + page_draw(elgg_echo('tagcloud:site:title'), $body); + break; + } +} + +register_elgg_event_handler('init', 'system', 'tagcloud_init'); diff --git a/mod/tagcloud/views/default/tagcloud/extend.php b/mod/tagcloud/views/default/tagcloud/extend.php new file mode 100644 index 000000000..d70fa77ad --- /dev/null +++ b/mod/tagcloud/views/default/tagcloud/extend.php @@ -0,0 +1,5 @@ +<?php + +echo '<div>'; +echo "<a href=\"{$vars['url']}pg/tagcloud\">All site tags</a>"; +echo '</div>';
\ No newline at end of file diff --git a/views/default/output/tagcloud.php b/views/default/output/tagcloud.php index 2296c01fe..ced3f2f30 100644 --- a/views/default/output/tagcloud.php +++ b/views/default/output/tagcloud.php @@ -34,26 +34,32 @@ if (!empty($vars['tagcloud']) && is_array($vars['tagcloud'])) { $cloud = ""; $max = 0; - $cloud .= "<h3>".elgg_echo('tagcloud')."</h3><div class='tagcloud'>"; + $cloud .= '<h3>'.elgg_echo('tagcloud').'</h3>'; + $cloud .= '<div class="tagcloud">'; foreach($vars['tagcloud'] as $tag) { if ($tag->total > $max) { $max = $tag->total; } } + + $list = ''; foreach($vars['tagcloud'] as $tag) { - if (!empty($cloud)) { - $cloud .= ", "; + if ($list != '') { + $list .= ', '; } // protecting against division by zero warnings $size = round((log($tag->total) / log($max + .0001)) * 100) + 30; if ($size < 100) { $size = 100; } - $url = $vars['url'] . "pg/search/?q=". urlencode($tag->tag) . "&search_type=tags{$type}{$subtype}"; - $cloud .= "<a href=\"{$url}\" style=\"font-size: {$size}%\" title=\"".addslashes($tag->tag)." ({$tag->total})\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>"; + $url = "{$vars['url']}pg/search/?q=". urlencode($tag->tag) . "&search_type=tags$type$subtype"; + $list .= "<a href=\"$url\" style=\"font-size: $size%\" title=\"".addslashes($tag->tag)." ($tag->total)\" style=\"text-decoration:none;\">" . htmlentities($tag->tag, ENT_QUOTES, 'UTF-8') . "</a>"; } - $cloud .= "</div>"; + $cloud .= "$list</div>"; + + $cloud .= elgg_view('tagcloud/extend'); + echo $cloud; }
\ No newline at end of file |