This file is indexed.

/usr/share/horde/ansel/lib/Widget/Tags.php is in php-horde-ansel 3.0.5+debian0-1.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  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
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
<?php
 /**
  * Copyright 2008-2016 Horde LLC (http://www.horde.org/)
  *
  * See the enclosed file COPYING for license information (GPL). If you
  * did not receive this file, see http://www.horde.org/licenses/gpl.
  *
  * @author Michael J Rubinsky <mrubinsk@horde.org>
  * @package Ansel
  */
/**
 * Ansel_Widget_Tags:: class to display a tags widget in the image and gallery
 * views.
 *
 * Copyright 2008-2016 Horde LLC (http://www.horde.org/)
 *
 * See the enclosed file COPYING for license information (GPL). If you
 * did not receive this file, see http://www.horde.org/licenses/gpl.
 *
 * @author Michael J Rubinsky <mrubinsk@horde.org>
 * @package Ansel
*/
class Ansel_Widget_Tags extends Ansel_Widget_Base
{
    /**
     * The type of resource the widget is connected to.
     * i.e., image or gallery
     *
     * @var string
     */
    protected $_resourceType;

    /**
     *
     * @var array $params  The parameters:
     *   - view:  The view we are attaching to (image, gallery).
     */
    public function __construct($params)
    {
        parent::__construct($params);
        $this->_resourceType = $params['view'];
        $this->_title = _("Tags");

        // Handle any incoming tag changes from non-script browsers.
        $tags = Horde_Util::getFormData('addtag');
        if (!is_null($tags) && strlen($tags)) {
            $tagger = $GLOBALS['injector']->getInstance('Ansel_Tagger');
            $this->_view->resource->setTags($tags, $tagger->split($tags));
        } elseif (Horde_Util::getFormData('actionID') == 'deleteTags') {
            $tag = Horde_Util::getFormData('tag');
            $this->_view->resource->removeTag($tag);
        }
    }

    /**
     * Build the HTML for this widget
     *
     * @return string  The HTML representing this widget.
     */
    public function html()
    {
        $view = $GLOBALS['injector']->getInstance('Horde_View');
        $view->addTemplatePath(ANSEL_TEMPLATES . '/widgets');
        $view->title = _("Tags");
        $view->background = $this->_style->background;
        $view->action_url = Horde::url('gallery.php');
        $image_id = ($this->_resourceType == 'image')
            ? $this->_view->resource->id
            : null;

        try {
            $view->tag_html = $this->_getTagHTML();
        } catch (Ansel_Exception $e) {
            $view->error_text = sprintf(_("There was an error fetching tags: %s"), $e->getMessage());
        }

        if ($this->_view->gallery->hasPermission($GLOBALS['registry']->getAuth(), Horde_Perms::EDIT)) {
            $view->have_edit = true;
            $GLOBALS['page_output']->addScriptFile('widgets/tagactions.js');
            $GLOBALS['page_output']->addInlineJsVars(array(
               'AnselTagActions.gallery' => $this->_view->gallery->id,
               'AnselTagActions.image' => $image_id,
               'AnselTagActions.remove_image' => strval(Horde_Themes::img('delete-small.png'))
            ));
        }

        return $view->render('tags');
    }


    /**
     * Helper function to build the list of tags
     *
     * @return string  The HTML representing the tag list.
     */
    protected function _getTagHTML()
    {
        global $registry;

        // Clear the tag cache?
        if (Horde_Util::getFormData('havesearch', 0) == 0) {
            $tag_browser = new Ansel_TagBrowser($GLOBALS['injector']->getInstance('Ansel_Tagger'));
            $tag_browser->clearSearch();
        }

        $tagger = $GLOBALS['injector']->getInstance('Ansel_Tagger');
        $hasEdit = $this->_view->gallery->hasPermission(
            $GLOBALS['registry']->getAuth(),
            Horde_Perms::EDIT);
        $owner = $this->_view->gallery->get('owner');
        $tags = $tagger->getTags((int)$this->_view->resource->id, $this->_resourceType);

        if (count($tags)) {
            $tags = $tagger->getTagInfo(array_keys($tags), 500, $this->_resourceType);
        }
        if ($this->_resourceType != 'image') {
            $removeLink = Horde::url('gallery.php')->add(array(
                'actionID' => 'removeTags',
                'gallery' => $this->_view->gallery->id));
        } else {
            $removeLink = Horde::url('image.php')->add(array(
                'actionID' => 'removeTags',
                'gallery' => $this->_view->gallery->id,
                'image' => $this->_view->resource->id));
        }
        $links = Ansel::getTagLinks($tags, 'add', $owner);
        $html = '<ul class="horde-tags">';
        foreach ($tags as $taginfo) {
            $tag_id = $taginfo['tag_id'];
            $html .= '<li>' . $links[$tag_id]->link(array('title' => sprintf(ngettext("%d photo", "%d photos", $taginfo['count']), $taginfo['count']))) . htmlspecialchars($taginfo['tag_name']) . '</a>' . ($hasEdit ? '<a href="' . strval($removeLink) . '" onclick="return AnselTagActions.remove(' . $tag_id . ');"> ' . Horde::img('delete-small.png', _("Remove Tag")) . '</a>' : '') . '</li>';
        }
        $html .= '</ul>';

        return $html;
    }

}