private static function getCategoryTree(XmapDisplayer &$xmap, stdClass &$parent, array &$params, $parent_id) { $db = JFactory::getDbo(); $query = $db->getQuery(true)->select(array('c.id', 'c.alias', 'c.title', 'c.parent_id'))->from('#__categories AS c')->where('c.parent_id = ' . $db->quote($parent_id ? $parent_id : 1))->where('c.extension = ' . $db->quote('com_garyscookbook'))->where('c.published = 1')->order('c.lft'); if (!$params['show_unauth']) { $query->where('c.access IN(' . $params['groups'] . ')'); } if ($params['language_filter']) { $query->where('c.language IN(' . $db->quote(JFactory::getLanguage()->getTag()) . ', ' . $db->quote('*') . ')'); } $db->setQuery($query); $rows = $db->loadObjectList(); if (empty($rows)) { return; } $xmap->changeLevel(1); foreach ($rows as $row) { $node = new stdclass(); $node->id = $parent->id; $node->name = $row->title; $node->uid = $parent->uid . '_cid_' . $row->id; $node->browserNav = $parent->browserNav; $node->priority = $params['category_priority']; $node->changefreq = $params['category_changefreq']; $node->pid = $row->parent_id; $node->link = GaryscookbookHelperRoute::getCategoryRoute($row->id); if ($xmap->printNode($node) !== false) { self::getRecipes($xmap, $parent, $params, $row->id); } } $xmap->changeLevel(-1); }
/** * @param XmapDisplayer $xmap * @param $parent * @param $params * @param $subnodes */ protected static function printNodes(XmapDisplayer $xmap, $parent, &$params, &$subnodes) { $xmap->changeLevel(1); $i = 0; foreach ($subnodes as $subnode) { $i++; $subnode->id = $parent->id; $subnode->uid = $parent->uid . 'p' . $i; $subnode->browserNav = $parent->browserNav; $subnode->priority = $params['art_priority']; $subnode->changefreq = $params['art_changefreq']; $subnode->secure = $parent->secure; $xmap->printNode($subnode); } $xmap->changeLevel(-1); }