Example #1
0
 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']));
         } 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->time);
             $node->link = sprintf($toplink, $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);
 }
Example #2
0
 /**
  * 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&amp;view=category&amp;catid=%s';
         $toplink = 'index.php?option=com_kunena&amp;view=topic&amp;catid=%s&amp;id=%s';
         kimport('kunena.forum.category.helper');
         $categories = KunenaForumCategoryHelper::getChildren($parentCat);
     } else {
         $catlink = 'index.php?option=com_kunena&amp;func=showcat&amp;catid=%s';
         $toplink = 'index.php?option=com_kunena&amp;func=view&amp;catid=%s&amp;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);
 }