static function getCategoryTree($xmap, $parent, &$params, $parentCat) { $db = JFactory::getDBO(); // Load categories if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ $catlink = 'index.php?option=com_kunena&view=category&catid=%s&Itemid=' . $parent->id; $toplink = 'index.php?option=com_kunena&view=topic&catid=%s&id=%s&Itemid=' . $parent->id; // kimport('kunena.forum.category.helper'); $categories = KunenaForumCategoryHelper::getChildren($parentCat); } else { $catlink = 'index.php?option=com_kunena&func=showcat&catid=%s&Itemid=' . $parent->id; $toplink = 'index.php?option=com_kunena&func=view&catid=%s&id=%s&Itemid=' . $parent->id; if (self::getKunenaMajorVersion() >= '1.6') { // Kunena 1.6+ kimport('session'); $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $allowed = $session->allowed; $query = "SELECT id, name FROM `#__kunena_categories` WHERE parent={$parentCat} AND id IN ({$allowed}) ORDER BY ordering"; } else { // Kunena 1.0+ $query = "SELECT id, name FROM `{$params['table_prefix']}_categories` WHERE parent={$parentCat} AND published=1 AND pub_access=0 ORDER BY ordering"; } $db->setQuery($query); $categories = $db->loadObjectList(); } /* get list of categories */ $xmap->changeLevel(1); foreach ($categories as $cat) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = 'com_kunenac' . $cat->id; $node->name = $cat->name; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = sprintf($catlink, $cat->id); $node->expandible = true; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->id); } } if ($params['include_topics']) { if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ // kimport('kunena.forum.topic.helper'); // TODO: orderby parameter is missing: $topics = KunenaForumTopicHelper::getLatestTopics($parentCat, 0, $params['limit'], array('starttime', $params['days'])); if (count($topics) == 2 && is_numeric($topics[0])) { $topics = $topics[1]; } } else { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold(self::$profile, $parentCat); // Kunena 1.0+ $query = "SELECT t.id, t.catid, t.subject, max(m.time) as time, count(m.id) as msgcount\n FROM {$params['table_prefix']}_messages t\n INNER JOIN {$params['table_prefix']}_messages AS m ON t.id = m.thread\n WHERE t.catid={$parentCat} AND t.parent=0\n AND t.hold in ({$hold})\n GROUP BY m.`thread`\n ORDER BY {$params['topics_order']} DESC"; if ($params['days']) { $query = "SELECT * FROM ({$query}) as topics WHERE time >= {$params['days']}"; } #echo str_replace('#__','mgbj2_',$query); $db->setQuery($query, 0, $params['limit']); $topics = $db->loadObjectList(); } //get list of topics foreach ($topics as $topic) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = 'com_kunenat' . $topic->id; $node->name = $topic->subject; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval(@$topic->last_post_time ? $topic->last_post_time : $topic->time); $node->link = sprintf($toplink, @$topic->category_id ? $topic->category_id : $topic->catid, $topic->id); $node->expandible = false; $node->secure = $parent->secure; if ($xmap->printNode($node) !== FALSE) { // Pagination will not work with K2.0, revisit this when that version is out and stable if ($params['include_pagination'] && isset($topic->msgcount) && $topic->msgcount > self::$config->messages_per_page) { $msgPerPage = self::$config->messages_per_page; $threadPages = ceil($topic->msgcount / $msgPerPage); for ($i = 2; $i <= $threadPages; $i++) { $subnode = new stdclass(); $subnode->id = $node->id; $subnode->uid = $node->uid . 'p' . $i; $subnode->name = "[{$i}]"; $subnode->seq = $i; $subnode->link = $node->link . '&limit=' . $msgPerPage . '&limitstart=' . ($i - 1) * $msgPerPage; $subnode->browserNav = $node->browserNav; $subnode->priority = $node->priority; $subnode->changefreq = $node->changefreq; $subnode->modified = $node->modified; $subnode->secure = $node->secure; $xmap->printNode($subnode); } } } } } $xmap->changeLevel(-1); }
function getCategoryTree(&$xmap, &$parent, &$params, $parentCat) { $database =& JFactory::getDBO(); $kunenaSession = KunenaFactory::getSession(); $kunenaSession->updateAllowedForums(); $catlist = $kunenaSession->allowed; $list = array(); $query = "SELECT id as cat_id, name as cat_title, ordering FROM #__kunena_categories WHERE parent={$parentCat} AND published=1 and id in ({$catlist}) ORDER BY name"; $database->setQuery($query); $cats = $database->loadObjectList(); /* get list of categories */ $xmap->changeLevel(1); foreach ($cats as $cat) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 'c' . $cat->cat_id; $node->name = $cat->cat_title; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = 'index.php?option=com_kunena&func=showcat&catid=' . $cat->cat_id . '&Itemid=' . $parent->id; $node->expandible = true; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->cat_id); } } if ($params['include_topics']) { $access = KunenaFactory::getAccessControl(); $hold = $access->getAllowedHold(self::$profile, $parentCat); $query = "SELECT t.id, t.catid as cat_id, t.subject as forum_name, max(m.time) as modified, count(m.id) as msgcount " . "FROM #__kunena_messages AS t " . "INNER JOIN #__kunena_messages AS m ON t.id = m.thread " . "WHERE t.catid={$parentCat} " . "AND t.hold in ({$hold}) " . "AND t.parent=0 " . $params['days'] . "GROUP BY m.`thread`" . "ORDER BY " . $params['topics_order'] . $params['limit']; $database->setQuery($query); #echo str_replace('#__','jos_',$database->getQuery()); $forums = $database->loadObjectList(); //get list of forums foreach ($forums as $forum) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 't' . $forum->id; $node->name = $forum->forum_name; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval($forum->modified); $node->link = 'index.php?option=com_kunena&func=view&catid=' . $forum->cat_id . '&id=' . $forum->id . '&Itemid=' . $parent->id; $node->expandible = false; if ($xmap->printNode($node) !== FALSE) { if ($params['include_pagination'] && $forum->msgcount > self::$config->messages_per_page) { $msgPerPage = self::$config->messages_per_page; $threadPages = ceil($forum->msgcount / $msgPerPage); for ($i = 2; $i <= $threadPages; $i++) { $subnode = new stdclass(); $subnode->id = $node->id; $subnode->uid = $node->uid . 'p' . $i; $subnode->name = "[{$i}]"; $subnode->seq = $i; $subnode->link = $node->link . '&limit=' . $msgPerPage . '&limitstart=' . ($i - 1) * $msgPerPage; $subnode->browserNav = $node->browserNav; $subnode->priority = $node->priority; $subnode->changefreq = $node->changefreq; $subnode->modified = $node->modified; $xmap->printNode($subnode); } } } } } $xmap->changeLevel(-1); }
function getCategoryTree(&$xmap, &$parent, &$params, $parentCat) { $database =& JFactory::getDBO(); $list = array(); $query = "SELECT id as cat_id, name as cat_title, ordering FROM #__fb_categories WHERE parent={$parentCat} AND published=1 and pub_access <=" . $xmap->gid . " ORDER BY name"; $database->setQuery($query); # echo $database->getQuery(); $cats = $database->loadObjectList(); /*get list of categories*/ $xmap->changeLevel(1); foreach ($cats as $cat) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 'c' . $cat->cat_id; $node->name = $cat->cat_title; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = 'index.php?option=com_kunena&func=showcat&catid=' . $cat->cat_id; $node->expandible = true; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $cat->cat_id); } } if ($params['include_topics']) { $query = "SELECT id as forum_id, catid as cat_id, subject as forum_name, time as modified " . "FROM #__fb_messages " . "WHERE catid={$parentCat} " . "AND parent=0 " . $params['days'] . "ORDER BY `" . $params['topics_order'] . "`" . $params['limit']; $database->setQuery($query); $forums = $database->loadObjectList(); //get list of forums foreach ($forums as $forum) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 't' . $forum->forum_id; $node->name = $forum->forum_name; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval($forum->modified); $node->link = 'index.php?option=com_kunena&func=view&id=' . $forum->forum_id . '&catid=' . $forum->cat_id; $node->expandible = false; $xmap->printNode($node); } } $xmap->changeLevel(-1); }
/** * Return category tree */ function getCategoryTree(&$xmap, &$parent, &$params, $parentCat) { $database =& JFactory::getDBO(); $list = array(); // Load categories if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ $catlink = 'index.php?option=com_kunena&view=category&catid=%s'; $toplink = 'index.php?option=com_kunena&view=topic&catid=%s&id=%s'; kimport('kunena.forum.category.helper'); $categories = KunenaForumCategoryHelper::getChildren($parentCat); } else { $catlink = 'index.php?option=com_kunena&func=showcat&catid=%s'; $toplink = 'index.php?option=com_kunena&func=view&catid=%s&id=%s'; if (self::getKunenaMajorVersion() >= '1.6') { // Kunena 1.6+ kimport('session'); $session = KunenaFactory::getSession(); $session->updateAllowedForums(); $allowed = $session->allowed; $query = "SELECT id, name FROM #__kunena_categories WHERE parent={$parentCat} AND id IN ({$allowed}) ORDER BY ordering"; } else { // Kunena 1.0+ $query = "SELECT id, name FROM {$params['table_prefix']}_categories WHERE parent={$parentCat} AND published=1 AND pub_access=0 ORDER BY ordering"; } $database->setQuery($query); $categories = $database->loadObjectList(); } // Create list of categories $xmap->changeLevel(1); foreach ($categories as $category) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 'c' . $category->id; $node->name = $category->name; $node->priority = $params['cat_priority']; $node->changefreq = $params['cat_changefreq']; $node->link = sprintf($catlink, $category->id); $node->expandible = true; if ($xmap->printNode($node) !== FALSE) { xmap_com_kunena::getCategoryTree($xmap, $parent, $params, $category->id); } } // Load topics if ($params['include_topics'] && $parentCat) { if (self::getKunenaMajorVersion() >= '2.0') { // Kunena 2.0+ kimport('kunena.forum.topic.helper'); // TODO: orderby parameter is missing: $topics = KunenaForumtopicHelper::getLatestTopics($parentCat, 0, $params['limit'], array('starttime', $params['days'])); } else { // Kunena 1.0+ $days = $params['days'] ? "AND time >= {$params['days']}" : ''; $query = "SELECT id, catid, subject, time \n\t\t\t\t\tFROM {$params['table_prefix']}_messages \n\t\t\t\t\tWHERE catid={$parentCat} AND parent=0 {$days} \n\t\t\t\t\tORDER BY `{$params['topics_order']}` DESC"; $database->setQuery($query, 0, $params['limit']); $topics = $database->loadObjectList(); } // Create list of topics foreach ($topics as $topic) { $node = new stdclass(); $node->id = $parent->id; $node->browserNav = $parent->browserNav; $node->uid = $parent->uid . 't' . $topic->id; $node->name = $topic->subject; $node->priority = $params['topic_priority']; $node->changefreq = $params['topic_changefreq']; $node->modified = intval($topic->time); $node->link = sprintf($toplink, $topic->catid, $topic->id); $node->expandible = false; $xmap->printNode($node); } } $xmap->changeLevel(-1); }