Exemplo n.º 1
0
 public static function getCategoryPath($catid, &$array = array())
 {
     if (isset(self::$paths[$catid])) {
         return self::$paths[$catid];
     }
     $mainframe = JFactory::getApplication();
     $user = JFactory::getUser();
     $aid = (int) $user->get('aid');
     $catid = (int) $catid;
     $db = JFactory::getDBO();
     $query = "SELECT * FROM #__k2_categories WHERE id={$catid} AND published=1 AND trash=0 ";
     if (K2_JVERSION != '15') {
         $query .= " AND access IN(" . implode(',', $user->getAuthorisedViewLevels()) . ") ";
         if ($mainframe->getLanguageFilter()) {
             $languageTag = JFactory::getLanguage()->getTag();
             $query .= " AND language IN (" . $db->Quote($languageTag) . ", " . $db->Quote('*') . ") ";
         }
     } else {
         $query .= " AND access <= {$aid}";
     }
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if ($db->getErrorNum()) {
         echo $db->stderr();
         return false;
     }
     foreach ($rows as $row) {
         array_push($array, '<a href="' . urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->id . ':' . urlencode($row->alias)))) . '">' . $row->name . '</a>');
         modK2ToolsHelper::getCategoryPath($row->parent, $array);
     }
     $return = array_reverse($array);
     self::$paths[$catid] = $return;
     return $return;
 }
Exemplo n.º 2
0
 function getCategoryPath($catid)
 {
     static $array = array();
     $user =& JFactory::getUser();
     $aid = (int) $user->get('aid');
     $catid = (int) $catid;
     $db =& JFactory::getDBO();
     $query = "SELECT * FROM #__k2_categories WHERE id={$catid} AND published=1 AND trash=0 AND access<={$aid}";
     $db->setQuery($query);
     $rows = $db->loadObjectList();
     if ($db->getErrorNum()) {
         echo $db->stderr();
         return false;
     }
     foreach ($rows as $row) {
         array_push($array, '<a href="' . urldecode(JRoute::_(K2HelperRoute::getCategoryRoute($row->id . ':' . urlencode($row->alias)))) . '">' . $row->name . '</a>');
         modK2ToolsHelper::getCategoryPath($row->parent);
     }
     return array_reverse($array);
 }