Example #1
0
 function getCategoryTree(&$xmap, &$parent, &$params, $catid)
 {
     $db =& JFactory::getDBO();
     if (!$catid) {
         // view=categories
         $query = ' SELECT a.id,a.title' . ' ,CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug' . ' FROM #__categories a ' . ' WHERE a.published=1 and a.section=\'com_weblinks\' and  a.access<=' . $xmap->gid . ' ORDER by a.ordering ';
         $db->setQuery($query);
         $cats = $db->loadObjectList();
         $xmap->changeLevel(1);
         foreach ($cats as $cat) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = $parent->uid . 'c' . $cat->id;
             $node->name = $cat->title;
             $node->link = 'index.php?option=com_weblinks&amp;view=category&amp;id=' . $cat->slug;
             $node->priority = $params['cat_priority'];
             $node->changefreq = $params['cat_changefreq'];
             $node->expandible = true;
             if ($xmap->printNode($node) !== FALSE) {
                 xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $cat->id);
             }
         }
         $xmap->changeLevel(-1);
     } elseif ($params['include_links']) {
         //view=category&catid=...
         $query = ' SELECT a.id,a.title' . ' ,CASE WHEN CHAR_LENGTH(a.alias) THEN CONCAT_WS(":", a.id, a.alias) ELSE a.id END as slug' . ' ,CASE WHEN CHAR_LENGTH(c.alias) THEN CONCAT_WS(":", c.id, c.alias) ELSE c.id END as catslug' . ' FROM #__weblinks a,#__categories c ' . ' WHERE a.catid = c.id AND c.published=1 and c.access<=' . $xmap->gid . ' AND ' . ' a.published=1 AND a.archived=0 AND a.approved=1' . ($catid ? ' AND a.catid=' . $catid . ' ' : ' ') . ' ORDER by a.ordering ' . $params['limit'];
         $db->setQuery($query);
         $links = $db->loadObjectList();
         $xmap->changeLevel(1);
         foreach ($links as $link) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = $parent->uid . 'i' . $link->id;
             $node->name = $link->title;
             $node->link = 'index.php?option=com_weblinks&amp;view=weblink&amp;id=' . $link->slug . "&amp;catid=" . $link->catslug;
             $node->priority = $params['link_priority'];
             $node->changefreq = $params['link_changefreq'];
             $node->expandible = false;
             $xmap->printNode($node);
         }
         $xmap->changeLevel(-1);
     }
 }
 static function getCategoryTree($xmap, $parent, &$params, $category)
 {
     $db = JFactory::getDBO();
     $children = $category->getChildren();
     $xmap->changeLevel(1);
     foreach ($children as $cat) {
         $node = new stdclass();
         $node->id = $parent->id;
         $node->uid = $parent->uid . 'c' . $cat->id;
         $node->name = $cat->title;
         $node->link = WeblinksHelperRoute::getCategoryRoute($cat);
         $node->priority = $params['cat_priority'];
         $node->changefreq = $params['cat_changefreq'];
         $node->expandible = true;
         if ($xmap->printNode($node) !== FALSE) {
             xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $cat);
         }
     }
     $xmap->changeLevel(-1);
     if ($params['include_links']) {
         //view=category&catid=...
         $linksModel = new WeblinksModelCategory();
         $linksModel->getState();
         // To force the populate state
         $linksModel->setState('list.limit', JArrayHelper::getValue($params, 'max_links', NULL));
         $linksModel->setState('list.start', 0);
         $linksModel->setState('list.ordering', 'ordering');
         $linksModel->setState('list.direction', 'ASC');
         $linksModel->setState('category.id', $category->id);
         $links = $linksModel->getItems();
         $xmap->changeLevel(1);
         foreach ($links as $link) {
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = $parent->uid . 'i' . $link->id;
             $node->name = $link->title;
             $node->link = WeblinksHelperRoute::getWeblinkRoute($link->id, $category->id);
             $node->priority = $params['link_priority'];
             $node->changefreq = $params['link_changefreq'];
             $node->expandible = false;
             $xmap->printNode($node);
         }
         $xmap->changeLevel(-1);
     }
 }
Example #3
0
 static function getCategoryTree($xmap, $parent, &$params, $category)
 {
     $db = JFactory::getDBO();
     $children = $category->getChildren();
     $xmap->changeLevel(1);
     foreach ($children as $cat) {
         $node = new stdclass();
         $node->id = $parent->id;
         $node->uid = $parent->uid . 'c' . $cat->id;
         $node->name = $cat->title;
         $node->link = WeblinksHelperRoute::getCategoryRoute($cat);
         $node->priority = $params['cat_priority'];
         $node->changefreq = $params['cat_changefreq'];
         $node->expandible = true;
         if ($xmap->printNode($node) !== FALSE) {
             xmap_com_weblinks::getCategoryTree($xmap, $parent, $params, $cat);
         }
     }
     $xmap->changeLevel(-1);
     if ($params['include_links']) {
         //view=category&catid=...
         $linksModel = new WeblinksModelCategory();
         $linksModel->getState();
         // To force the populate state
         $linksModel->setState('list.limit', JArrayHelper::getValue($params, 'max_links', NULL));
         $linksModel->setState('list.start', 0);
         $linksModel->setState('list.ordering', 'ordering');
         $linksModel->setState('list.direction', 'ASC');
         $linksModel->setState('category.id', $category->id);
         $links = $linksModel->getItems();
         $xmap->changeLevel(1);
         foreach ($links as $link) {
             $item_params = new JRegistry();
             $item_params->loadString($link->params);
             $node = new stdclass();
             $node->id = $parent->id;
             $node->uid = $parent->uid . 'i' . $link->id;
             $node->name = $link->title;
             // Find the Itemid
             $Itemid = intval(preg_replace('/.*Itemid=([0-9]+).*/', '$1', WeblinksHelperRoute::getWeblinkRoute($link->id, $category->id)));
             if ($item_params->get('count_clicks', $params['count_clicks']) == 1) {
                 $node->link = 'index.php?option=com_weblinks&task=weblink.go&id=' . $link->id . '&Itemid=' . ($Itemid ? $Itemid : $parent->id);
             } else {
                 $node->link = $link->url;
             }
             $node->priority = $params['link_priority'];
             $node->changefreq = $params['link_changefreq'];
             $node->expandible = false;
             $xmap->printNode($node);
         }
         $xmap->changeLevel(-1);
     }
 }