Back to PhocaGalleryTag class

Method displayTags

public static
displayTags
(mixed $imgId, mixed $popupLink = 0)

Method displayTags - Source code

public static function displayTags($imgId, $popupLink = 0)
{
    $o = '';
    $db = Factory::getDBO();
    $params = ComponentHelper::getParams('com_phocagallery');
    $query = 'SELECT a.id, a.title, a.link_ext, a.link_cat' . ' FROM #__phocagallery_tags AS a' . ' LEFT JOIN #__phocagallery_tags_ref AS r ON r.tagid = a.id' . ' WHERE r.imgid = ' . (int) $imgId;
    $db->setQuery($query);
    $imgObject = $db->loadObjectList();
    /*
    		if ($popupLink == 1) {
    			$tl	= 0;
    		} else  {
    			$tl	= $params->get( 'tags_links', 0 );
    		}*/
    $targetO = '';
    if ($popupLink == 1) {
        $targetO = 'target="_parent"';
    }
    $tl = $params->get('tags_links', 0);
    foreach ($imgObject as $k => $v) {
        $o .= '<span class="ph-tag-' . (int) $v->id . '">';
        if ($tl == 0) {
            $o .= $v->title;
        } else {
            if ($tl == 1) {
                if ($v->link_ext != '') {
                    $o .= '<a href="' . $v->link_ext . '" ' . $targetO . '>' . $v->title . '</a>';
                } else {
                    $o .= $v->title;
                }
            } else {
                if ($tl == 2) {
                    if ($v->link_cat != '') {
                        $query = 'SELECT a.id, a.alias' . ' FROM #__phocagallery_categories AS a' . ' WHERE a.id = ' . (int) $v->link_cat;
                        $db->setQuery($query, 0, 1);
                        $category = $db->loadObject();
                        if (isset($category->id) && isset($category->alias)) {
                            $link = PhocaGalleryRoute::getCategoryRoute($category->id, $category->alias);
                            $o .= '<a href="' . $link . '" ' . $targetO . '>' . $v->title . '</a>';
                        } else {
                            $o .= $v->title;
                        }
                    } else {
                        $o .= $v->title;
                    }
                } else {
                    if ($tl == 3) {
                        $link = PhocaGalleryRoute::getCategoryRouteByTag($v->id);
                        $o .= '<a href="' . $link . '" ' . $targetO . '>' . $v->title . '</a>';
                    }
                }
            }
        }
        $o .= '</span> ';
    }
    return $o;
}