/** * 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; }
<?php /** * Copyright 2001-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. */ require_once __DIR__ . '/lib/Application.php'; Horde_Registry::appInit('ansel'); $layout = new Horde_Core_Block_Layout_View($injector->getInstance('Horde_Core_Factory_BlockCollection')->create(array('ansel'), 'myansel_layout')->getLayout(), Horde::url('browse_edit.php'), Horde::url('browse.php', true)); $layout_html = $layout->toHtml(); $tag_browser = new Ansel_TagBrowser($injector->getInstance('Ansel_Tagger')); $tag_browser->clearSearch(); Ansel::initJSVariables(); $page_output->header(array('title' => _("Photo Galleries"))); $notification->notify(array('listeners' => 'status')); include ANSEL_TEMPLATES . '/browse/new.inc'; echo $layout_html; $page_output->footer();