File: Cloud.php

package info (click to toggle)
php-horde 5.2.13%2Bdebian0-1%2Bdeb9u2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 12,652 kB
  • sloc: php: 11,153; xml: 6,751; javascript: 5,560; sh: 92; makefile: 33; sql: 1
file content (68 lines) | stat: -rw-r--r-- 1,915 bytes parent folder | download | duplicates (4)
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
<?php
/**
 * @author  Michael J. Rubinsky <mrubinsk@horde.org>
 * @package Horde
 */
class Horde_Block_Cloud extends Horde_Core_Block
{
    /**
     */
    public function __construct($app, $params = array())
    {
        parent::__construct($app, $params);
        $this->_name = _("Tag Cloud");
    }

    protected function _escapeJs($string)
    {
        return str_replace("\n", '\n', str_replace('"', '\"', addcslashes(str_replace("\r", '', (string)$string), "\0..\37'\\")));
    }
    /**
     */
    protected function _content()
    {
        $cloud = new Horde_Core_Ui_TagCloud();
        foreach ($this->_getTags() as $tag) {
            $cloud->addElement(
                $tag['tag_name'], '#', $tag['count'], null,
                'doSearch(\'' . htmlspecialchars($this->_escapeJs($tag['tag_name'])) . '\'); return false;');
        }

        Horde::startBuffer();
        include HORDE_TEMPLATES . '/block/cloud.inc';

        return Horde::endBuffer()
            . '<div>&nbsp;'
            . Horde_Themes_Image::tag('loading.gif', array(
                  'attr' => array(
                      'id' => 'cloudloadingimg',
                      'style' => 'display:none;'
                  )
              ))
            . '</div>' . $cloud->buildHTML()
            . '<div id="cloudsearch"></div>';
    }

    /**
     */
    protected function _getTags()
    {
        global $registry;

        $results = array();
        foreach ($registry->listAPIs() as $api) {
            if ($registry->hasMethod($api . '/listTagInfo')) {
                try {
                    $results = array_merge(
                        $results,
                        $registry->call(
                            $api . '/listTagInfo',
                            array(null, $registry->getAuth())));
                } catch (Horde_Exception $e) {}
            }
        }

        return $results;
    }

}