Example #1
0
 public function __construct()
 {
     self::$enabled = JComponentHelper::isEnabled('com_k2');
     JLoader::register('K2HelperRoute', JPATH_SITE . '/components/com_k2/helpers/route.php');
 }
Example #2
0
 static function processTree($db, &$xmap, &$parent, &$params, $mode, $ids, $tag, $limit)
 {
     $baseQuery = "select id,title,alias,UNIX_TIMESTAMP(created) as created, UNIX_TIMESTAMP(modified) as modified, metakey from  #__k2_items where " . "published = 1 and trash = 0 and (publish_down = \"0000-00-00\" OR publish_down > NOW()) and " . "access in (" . self::$maxAccess . ") and ";
     switch ($mode) {
         case "single user":
             $query = $baseQuery . "created_by = " . $tag . " ";
             if ($ids[0] != "") {
                 $query .= " and catid in (" . implode(",", $ids) . ")";
             }
             $query .= " order by 1 DESC ";
             $db->setQuery($query);
             $rows = $db->loadObjectList();
             break;
         case "tag":
             $query = "SELECT c.id, title, alias, UNIX_TIMESTAMP(c.created) as created, UNIX_TIMESTAMP(c.modified) as modified FROM #__k2_tags a, #__k2_tags_xref b, #__k2_items c where " . "c.published = 1 and c.trash = 0 and (c.publish_down = \"0000-00-00\" OR c.publish_down > NOW()) " . "and a.Name = '" . $tag . "' and a.id =  b.tagId and c.id = b.itemID and c.access in (" . self::$maxAccess . ")";
             if ($ids[0] != "") {
                 $query .= " and c.catid in (" . implode(",", $ids) . ")";
             }
             $query .= " order by 1 DESC ";
             $db->setQuery($query);
             $rows = $db->loadObjectList();
             break;
         case "category":
             $query = $baseQuery . "catid = " . $ids[0] . " order by 1 DESC ";
             $db->setQuery($query);
             $rows = $db->loadObjectList();
             break;
         case "categories":
             if (!self::$suppressSub) {
                 if ($ids) {
                     $query = $baseQuery . "catid in (" . implode(",", $ids) . ") order by 1 DESC ";
                 } else {
                     $query = $baseQuery . "1 order by 1 DESC ";
                 }
                 $db->setQuery($query);
                 $rows = $db->loadObjectList();
             } else {
                 $rows = array();
                 if (is_array($ids)) {
                     foreach ($ids as $id) {
                         $allrows = array();
                         xmap_com_k2::collectByCat($db, $id, $allrows);
                         $rows = array_merge($rows, $allrows);
                     }
                 }
             }
             break;
         case "latest user":
             $rows = array();
             if (is_array($ids)) {
                 foreach ($ids as $id) {
                     $query = $baseQuery . "created_by = " . $id . " order by 1 DESC LIMIT " . $limit;
                     $db->setQuery($query);
                     $res = $db->loadObjectList();
                     if ($res != null) {
                         $rows = array_merge($rows, $res);
                     }
                 }
             }
             break;
         case "latest category":
             $rows = array();
             if (is_array($ids)) {
                 foreach ($ids as $id) {
                     $query = $baseQuery . "catid = " . $id . " order by 1 DESC LIMIT " . $limit;
                     $db->setQuery($query);
                     $res = $db->loadObjectList();
                     if ($res != null) {
                         $rows = array_merge($rows, $res);
                     }
                 }
             }
             break;
         default:
             return;
     }
     $xmap->changeLevel(1);
     $node = new stdclass();
     $node->id = $parent->id;
     if ($rows == null) {
         $rows = array();
     }
     foreach ($rows as $row) {
         if (!(self::$suppressDups && isset($xmap->IDS) && strstr($xmap->IDS, "|" . $row->id))) {
             xmap_com_k2::addNode($xmap, $node, $row, false, $parent, $params);
         }
     }
     if ($mode == "category" && !self::$suppressSub) {
         $query = "select id, name, alias  from #__k2_categories where published = 1 and trash = 0 and parent = " . $ids[0] . " and access in (" . self::$maxAccess . ") order by id";
         $db->setQuery($query);
         $rows = $db->loadObjectList();
         if ($rows == null) {
             $rows = array();
         }
         foreach ($rows as $row) {
             if (!isset($xmap->IDS)) {
                 $xmap->IDS = "";
             }
             if (!(self::$suppressDups && strstr($xmap->IDS, "|c" . $row->id))) {
                 xmap_com_k2::addNode($xmap, $node, $row, true, $parent, $params);
                 $newID = array();
                 $newID[0] = $row->id;
                 xmap_com_k2::processTree($db, $xmap, $parent, $params, $mode, $newID, "", "");
             }
         }
     }
     $xmap->changeLevel(-1);
 }