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); } }
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); } }