1: <?php
2: /**
3: * Display Tag Cloud
4: *
5: * Copyright 2007-2012 Horde LLC (http://www.horde.org/)
6: *
7: * See the enclosed file COPYING for license information (GPL). If you
8: * did not receive this file, see http://www.horde.org/licenses/gpl.
9: *
10: * @author Michael Rubinsky <mrubinsk@horde.org>
11: */
12: class Ansel_Block_Cloud extends Horde_Core_Block
13: {
14: /**
15: */
16: public function __construct($app, $params = array())
17: {
18: parent::__construct($app, $params);
19:
20: $this->_name = _("Tag Cloud");
21: }
22:
23: /**
24: */
25: protected function _params()
26: {
27: return array(
28: 'count' => array(
29: 'name' => _("Number of tags to display"),
30: 'type' => 'int',
31: 'default' => 20
32: )
33: );
34: }
35:
36: /**
37: */
38: protected function _content()
39: {
40: /* Get the tags */
41: $tags = $GLOBALS['injector']->getInstance('Ansel_Tagger')->getCloud(null, $this->_params['count']);
42: if (count($tags)) {
43: $cloud = new Horde_Core_Ui_TagCloud();
44: foreach ($tags as $id => $tag) {
45: $link = Ansel::getUrlFor('view', array('view' => 'Results',
46: 'tag' => $tag['tag_name']));
47: $cloud->addElement($tag['tag_name'], $link, $tag['count']);
48: }
49: $html = $cloud->buildHTML();
50: } else {
51: $html = '';
52: }
53: return $html;
54: }
55:
56: }
57: