File: cloud.php

package info (click to toggle)
horde3 3.3.8%2Bdebian0-3
  • links: PTS, VCS
  • area: main
  • in suites: squeeze
  • size: 34,220 kB
  • ctags: 28,224
  • sloc: php: 115,191; xml: 4,247; sql: 2,417; sh: 147; makefile: 140
file content (96 lines) | stat: -rw-r--r-- 2,424 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php

$block_name = _("Tag Cloud");

/**
 * $Horde: horde/lib/Block/cloud.php,v 1.3.2.1 2007/12/20 15:01:35 jan Exp $
 *
 * @author Michael J. Rubinsky <mrubinsk@horde.org>
 * @package Horde_Block
 */
class Horde_Block_Horde_cloud extends Horde_Block {

    /**
     * Whether this block has changing content.
     */
    var $updateable = false;

    /**
     * @var string
     */
    var $_app = 'horde';

    var $_tagapis = array('images', 'news');

    function Horde_Block_Horde_cloud($params = array())
    {
        parent::Horde_Block($params);
    }

    function _params()
    {

    }

    /**
     * The title to go in this block.
     *
     * @return string   The title text.
     */
    function _title()
    {
        return _("Tag Cloud");
    }

    /**
     * The content to go in this block.
     *
     * @return string   The content.
     */
    function _content()
    {
        global $registry;
        require_once 'Horde/UI/TagCloud.php';
        Horde::addScriptFile('prototype.js', 'horde', true);

        $cloud = new Horde_UI_TagCloud();
        if (!is_a($cloud, 'PEAR_Error')) {
            $tags = $this->_getTags();
            foreach ($tags as $tag) {
                $cloud->addElement($tag['tag_name'], '#', $tag['total'],
                                   null,
                                   'doSearch(\'' . $tag['tag_name'] . '\');');
            }
                $html = Util::bufferOutput('include',
                                           HORDE_TEMPLATES . '/block/cloud.inc');

                $html .= '<div>&nbsp;' .
                         Horde::img('loading.gif', '', array('style' => 'display:none;', 'id' => 'cloudloadingimg')) .
                         '</div>' . $cloud->buildHTML() .
                         '<div id="cloudsearch"></div>';
        } else {
           $html = $cloud->getMessage();
        }

        return $html;
    }


    function _getTags()
    {
        global $registry;
        $results = array();

        foreach ($this->_tagapis as $api) {
            $methods = $registry->listMethods($api);
            if (array_search($api . '/listTagInfo', $methods)) {
                $result = $registry->call($api . '/listTagInfo', array());
                if (!is_a($result, 'PEAR_Error')) {
                    $results = array_merge($results, $result);
                }
            }
        }
        return $results;
    }

}