Ansel::getTagLinks PHP Method

    public static function getTagLinks($tags, $action = 'add', $owner = null)
    {
        $results = array();
        foreach ($tags as $id => $taginfo) {
            $params = array('view' => 'Results', 'tag' => $taginfo['tag_name']);
            if (!empty($owner)) {
                $params['owner'] = $owner;
            }
            if ($action != 'add') {
                $params['actionID'] = $action;
            }
            $link = Ansel::getUrlFor('view', $params, true);
            $results[$id] = $link;
        }
        return $results;
    }

Usage Example

Example #1
0
 /**
  * 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;
 }
All Usage Examples Of Ansel::getTagLinks