当前位置: 首页>>代码示例>>PHP>>正文


PHP KunenaForumCategoryHelper::getNewTopics方法代码示例

本文整理汇总了PHP中KunenaForumCategoryHelper::getNewTopics方法的典型用法代码示例。如果您正苦于以下问题:PHP KunenaForumCategoryHelper::getNewTopics方法的具体用法?PHP KunenaForumCategoryHelper::getNewTopics怎么用?PHP KunenaForumCategoryHelper::getNewTopics使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KunenaForumCategoryHelper的用法示例。


在下文中一共展示了KunenaForumCategoryHelper::getNewTopics方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: before

 /**
  * Prepare category subscriptions display.
  *
  * @return void
  *
  * @throws KunenaExceptionAuthorise
  */
 protected function before()
 {
     parent::before();
     $me = KunenaUserHelper::getMyself();
     if (!$me->exists()) {
         throw new KunenaExceptionAuthorise(JText::_('COM_KUNENA_NO_ACCESS'), 401);
     }
     $limit = $this->input->getInt('limit', 0);
     if ($limit < 1 || $limit > 100) {
         $limit = 20;
     }
     $limitstart = $this->input->getInt('limitstart', 0);
     if ($limitstart < 0) {
         $limitstart = 0;
     }
     list($total, $this->categories) = KunenaForumCategoryHelper::getLatestSubscriptions($me->userid);
     $topicIds = array();
     $userIds = array();
     $postIds = array();
     foreach ($this->categories as $category) {
         // Get list of topics.
         if ($category->last_topic_id) {
             $topicIds[$category->last_topic_id] = $category->last_topic_id;
         }
     }
     // Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
     $topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
     // Pre-fetch users (and get last post ids for moderators).
     foreach ($topics as $topic) {
         $userIds[$topic->last_post_userid] = $topic->last_post_userid;
         $postIds[$topic->id] = $topic->last_post_id;
     }
     KunenaUserHelper::loadUsers($userIds);
     KunenaForumMessageHelper::getMessages($postIds);
     // Pre-fetch user related stuff.
     if ($me->exists() && !$me->isBanned()) {
         // Load new topic counts.
         KunenaForumCategoryHelper::getNewTopics(array_keys($this->categories));
     }
     $this->actions = $this->getActions();
     $this->pagination = new JPagination($total, $limitstart, $limit);
     $this->headerText = JText::_('COM_KUNENA_CATEGORY_SUBSCRIPTIONS');
 }
开发者ID:densem-2013,项目名称:exikom,代码行数:50,代码来源:display.php

示例2: getCategories

 public function getCategories()
 {
     if ($this->items === false) {
         $this->items = array();
         $catid = $this->getState('item.id');
         $layout = $this->getState('layout');
         $flat = false;
         if ($layout == 'user') {
             $categories[0] = KunenaForumCategoryHelper::getSubscriptions();
             $flat = true;
         } elseif ($catid) {
             $categories[0] = KunenaForumCategoryHelper::getCategories($catid);
             if (empty($categories[0])) {
                 return array();
             }
         } else {
             $categories[0] = KunenaForumCategoryHelper::getChildren();
         }
         if ($flat) {
             $allsubcats = $categories[0];
         } else {
             $allsubcats = KunenaForumCategoryHelper::getChildren(array_keys($categories[0]), 1);
         }
         if (empty($allsubcats)) {
             return array();
         }
         KunenaForumCategoryHelper::getNewTopics(array_keys($allsubcats));
         $modcats = array();
         $lastpostlist = array();
         $userlist = array();
         $topiclist = array();
         foreach ($allsubcats as $subcat) {
             if ($flat || isset($categories[0][$subcat->parent_id])) {
                 $last = $subcat->getLastCategory();
                 if ($last->last_topic_id) {
                     // Get list of topics
                     $topiclist[$last->last_topic_id] = $last->last_topic_id;
                 }
                 if ($this->config->listcat_show_moderators) {
                     // Get list of moderators
                     $subcat->moderators = $subcat->getModerators(false, false);
                     $userlist += $subcat->moderators;
                 }
                 if ($this->me->isModerator($subcat)) {
                     $modcats[] = $subcat->id;
                 }
             }
             $categories[$subcat->parent_id][] = $subcat;
         }
         // Prefetch topics
         $topics = KunenaForumTopicHelper::getTopics($topiclist);
         foreach ($topics as $topic) {
             // Prefetch users
             $userlist[$topic->last_post_userid] = $topic->last_post_userid;
             $lastpostlist[$topic->id] = $topic->last_post_id;
         }
         if ($this->me->ordering != 0) {
             $topic_ordering = $this->me->ordering == 1 ? true : false;
         } else {
             $topic_ordering = $this->config->default_sort == 'asc' ? false : true;
         }
         $this->pending = array();
         if ($this->me->userid && count($modcats)) {
             $catlist = implode(',', $modcats);
             $db = JFactory::getDBO();
             $db->setQuery("SELECT catid, COUNT(*) AS count\n\t\t\t\tFROM #__kunena_messages\n\t\t\t\tWHERE catid IN ({$catlist}) AND hold=1\n\t\t\t\tGROUP BY catid");
             $pending = $db->loadAssocList();
             KunenaError::checkDatabaseError();
             foreach ($pending as $item) {
                 if ($item['count']) {
                     $this->pending[$item['catid']] = $item['count'];
                 }
             }
         }
         // Fix last post position when user can see unapproved or deleted posts
         if ($lastpostlist && !$topic_ordering && ($this->me->isAdmin() || KunenaAccess::getInstance()->getModeratorStatus())) {
             KunenaForumMessageHelper::getMessages($lastpostlist);
             KunenaForumMessageHelper::loadLocation($lastpostlist);
         }
         // Prefetch all users/avatars to avoid user by user queries during template iterations
         KunenaUserHelper::loadUsers($userlist);
         if ($flat) {
             $this->items = $allsubcats;
         } else {
             $this->items = $categories;
         }
     }
     return $this->items;
 }
开发者ID:madcsaba,项目名称:li-de,代码行数:89,代码来源:category.php

示例3: before

 /**
  * Prepare category index display.
  *
  * @return void
  */
 protected function before()
 {
     parent::before();
     $this->me = KunenaUserHelper::getMyself();
     // Get sections to display.
     $catid = $this->input->getInt('catid', 0);
     if ($catid) {
         $sections = KunenaForumCategoryHelper::getCategories($catid);
     } else {
         $sections = KunenaForumCategoryHelper::getChildren();
     }
     $sectionIds = array();
     $this->more[$catid] = 0;
     foreach ($sections as $key => $category) {
         $this->categories[$category->id] = array();
         $this->more[$category->id] = 0;
         // Display only categories which are supposed to show up.
         if ($catid || $category->params->get('display.index.parent', 3) > 0) {
             if ($catid || $category->params->get('display.index.children', 3) > 1) {
                 $sectionIds[] = $category->id;
             } else {
                 $this->more[$category->id]++;
             }
         } else {
             $this->more[$category->parent_id]++;
             unset($sections[$key]);
             continue;
         }
     }
     // Get categories and subcategories.
     if (empty($sections)) {
         return;
     }
     $this->sections = $sections;
     $categories = KunenaForumCategoryHelper::getChildren($sectionIds);
     if (empty($categories)) {
         return;
     }
     $categoryIds = array();
     $topicIds = array();
     $userIds = array();
     $postIds = array();
     foreach ($categories as $key => $category) {
         $this->more[$category->id] = 0;
         // Display only categories which are supposed to show up.
         if ($catid || $category->params->get('display.index.parent', 3) > 1) {
             if ($catid || $category->getParent()->params->get('display.index.children', 3) > 2 && $category->params->get('display.index.children', 3) > 2) {
                 $categoryIds[] = $category->id;
             } else {
                 $this->more[$category->id]++;
             }
         } else {
             $this->more[$category->parent_id]++;
             unset($categories[$key]);
             continue;
         }
         // Get list of topics.
         $last = $category->getLastCategory();
         if ($last->last_topic_id) {
             $topicIds[$last->last_topic_id] = $last->last_topic_id;
         }
         $this->categories[$category->parent_id][] = $category;
         $rssURL = $category->getRSSUrl();
         if (!empty($rssURL)) {
             $category->rssURL = $category->getRSSUrl();
         }
     }
     $subcategories = KunenaForumCategoryHelper::getChildren($categoryIds);
     foreach ($subcategories as $category) {
         // Display only categories which are supposed to show up.
         if ($catid || $category->params->get('display.index.parent', 3) > 2) {
             $this->categories[$category->parent_id][] = $category;
         } else {
             $this->more[$category->parent_id]++;
         }
     }
     // Pre-fetch topics (also display unauthorized topics as they are in allowed categories).
     $topics = KunenaForumTopicHelper::getTopics($topicIds, 'none');
     // Pre-fetch users (and get last post ids for moderators).
     foreach ($topics as $topic) {
         $userIds[$topic->last_post_userid] = $topic->last_post_userid;
         $postIds[$topic->id] = $topic->last_post_id;
     }
     KunenaUserHelper::loadUsers($userIds);
     KunenaForumMessageHelper::getMessages($postIds);
     // Pre-fetch user related stuff.
     $this->pending = array();
     if ($this->me->exists() && !$this->me->isBanned()) {
         // Load new topic counts.
         KunenaForumCategoryHelper::getNewTopics(array_keys($categories + $subcategories));
         // Get categories which are moderated by current user.
         $access = KunenaAccess::getInstance();
         $moderate = $access->getAdminStatus($this->me) + $access->getModeratorStatus($this->me);
         if (!empty($moderate[0])) {
             // Global moderators.
//.........这里部分代码省略.........
开发者ID:giabmf11,项目名称:Kunena-Forum,代码行数:101,代码来源:display.php


注:本文中的KunenaForumCategoryHelper::getNewTopics方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。