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


PHP DiscussHelper::buildNestedCategories方法代码示例

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


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

示例1: _getParentIdsWithPost

 protected function _getParentIdsWithPost()
 {
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     $query = 'select * from `#__discuss_category`';
     $query .= ' where `published` = 1';
     $query .= ' and `parent_id` = 0';
     if ($my->id == 0) {
         $query .= ' and `private` = 0';
     }
     $db->setQuery($query);
     $result = $db->loadObjectList();
     $validCat = array();
     if (count($result) > 0) {
         for ($i = 0; $i < count($result); $i++) {
             $item =& $result[$i];
             $item->childs = null;
             DiscussHelper::buildNestedCategories($item->id, $item);
             $catIds = array();
             $catIds[] = $item->id;
             DiscussHelper::accessNestedCategoriesId($item, $catIds);
             $item->cnt = $this->getTotalPostCount($catIds);
             if ($item->cnt > 0) {
                 $validCat[] = $item->id;
             }
         }
     }
     return $validCat;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:29,代码来源:category.php

示例2: getPrivateCategories

 public static function getPrivateCategories($acltype = DISCUSS_CATEGORY_ACL_ACTION_VIEW)
 {
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     static $result = array();
     $excludeCats = array();
     $sig = (int) $my->id . '-' . (int) $acltype;
     if (!isset($result[$sig])) {
         if ($my->id == 0) {
             $catQuery = 'select distinct a.`id`, a.`private`';
             $catQuery .= ' from `#__discuss_category` as a';
             $catQuery .= ' 	left join `#__discuss_category_acl_map` as b on a.`id` = b.`category_id`';
             $catQuery .= ' 		and b.`acl_id` = ' . $db->Quote($acltype);
             $catQuery .= ' 		and b.`type` = ' . $db->Quote('group');
             $catQuery .= ' where a.`private` != ' . $db->Quote('0');
             $gid = array();
             $gids = '';
             if (DiscussHelper::getJoomlaVersion() >= '1.6') {
                 // $gid	= JAccess::getGroupsByUser(0, false);
                 $gid = DiscussHelper::getUserGroupId($my);
             } else {
                 $gid = DiscussHelper::getUserGids();
             }
             if (count($gid) > 0) {
                 foreach ($gid as $id) {
                     $gids .= empty($gids) ? $db->Quote($id) : ',' . $db->Quote($id);
                 }
                 $catQuery .= ' and a.`id` NOT IN (';
                 $catQuery .= '     SELECT c.category_id FROM `#__discuss_category_acl_map` as c ';
                 $catQuery .= '        WHERE c.acl_id = ' . $db->Quote($acltype);
                 $catQuery .= '        AND c.type = ' . $db->Quote('group');
                 $catQuery .= '        AND c.content_id IN (' . $gids . ') )';
             }
             $db->setQuery($catQuery);
             $result = $db->loadObjectList();
         } else {
             $result = self::getAclCategories($acltype, $my->id);
         }
         for ($i = 0; $i < count($result); $i++) {
             $item =& $result[$i];
             $item->childs = null;
             DiscussHelper::buildNestedCategories($item->id, $item, true);
             $catIds = array();
             $catIds[] = $item->id;
             DiscussHelper::accessNestedCategoriesId($item, $catIds);
             $excludeCats = array_merge($excludeCats, $catIds);
         }
         $result[$sig] = $excludeCats;
     }
     return $result[$sig];
 }
开发者ID:pguilford,项目名称:vcomcc,代码行数:51,代码来源:helper.php

示例3: listings

 /**
  * Displays a list of recent discussions from a particular category.
  *
  * @since	3.0
  * @access	public
  */
 public function listings()
 {
     // Initialise variables
     $doc = JFactory::getDocument();
     $my = JFactory::getUser();
     $config = DiscussHelper::getConfig();
     $app = JFactory::getApplication();
     $registry = DiscussHelper::getRegistry();
     $categoryId = JRequest::getInt('category_id', 0);
     // Try to detect if there's any category id being set in the menu parameter.
     $activeMenu = $app->getMenu()->getActive();
     if ($activeMenu) {
         // Load menu params to the registry.
         $registry->loadString($activeMenu->params);
         // Set the active category id if exists.
         $categoryId = $registry->get('category_id') ? $registry->get('category_id') : $categoryId;
     }
     // Get the current logged in user's access.
     $acl = DiscussHelper::getHelper('ACL');
     // Todo: Perhaps we should fix the confused naming of filter and sort to type and sort
     $activeFilter = JRequest::getString('filter', $registry->get('filter'));
     $sort = JRequest::getString('sort', $registry->get('sort'));
     // Get the pagination limit
     $limit = $registry->get('limit');
     $limit = $limit == '-2' ? DiscussHelper::getListLimit() : $limit;
     $limit = $limit == '-1' ? DiscussHelper::getJConfig()->get('list_limit') : $limit;
     // Get the active category id if there is any
     $activeCategory = DiscussHelper::getTable('Category');
     $activeCategory->load($categoryId);
     DiscussHelper::setPageTitle($activeCategory->title);
     // Add breadcrumbs for active category.
     if ($activeCategory->id != 0) {
         // Test if user is really allowed to access this category.
         if (!$activeCategory->canAccess()) {
             $app->redirect(DiscussRouter::_('index.php?option=com_easydiscuss&view=index', false), JText::_('COM_EASYDISCUSS_SYSTEM_INSUFFICIENT_PERMISSIONS'));
             $app->close();
             return;
         }
         // Add pathway for category here.
         DiscussHelper::getHelper('Pathway')->setCategoryPathway($activeCategory);
     }
     // Add view to this page.
     $this->logView();
     // Set the meta of the page.
     DiscussHelper::setMeta();
     $doc = JFactory::getDocument();
     $doc->setMetadata('description', strip_tags($activeCategory->getDescription()));
     // Add rss feed into headers
     DiscussHelper::getHelper('Feeds')->addHeaders('index.php?option=com_easydiscuss&view=index');
     // Get list of categories on the site.
     $catModel = $this->getModel('Categories');
     // Pagination is by default disabled.
     $pagination = false;
     if ($categoryId) {
         $category = DiscussHelper::getTable('Category');
         $category->load($categoryId);
         $categories[] = $category;
     } else {
         $categories = $catModel->getCategories($categoryId);
         if (count($categories) > 1) {
             $ids = array();
             foreach ($categories as $row) {
                 $ids[] = $row->id;
             }
             // iniCounts should only called in index page.
             $category = DiscussHelper::getTable('Category');
             $category->initCounts($ids, true);
         }
     }
     // Get the model.
     $postModel = DiscussHelper::getModel('Posts');
     $authorIds = array();
     $topicIds = array();
     for ($i = 0; $i < count($categories); $i++) {
         $category =& $categories[$i];
         // building category childs lickage.
         $category->childs = null;
         $nestedLinks = '';
         // In category page
         if ($config->get('layout_show_all_subcategories', '1')) {
             // By default show all the subcategories of the selected category
             DiscussHelper::buildNestedCategories($category->id, $category, false, true);
         } else {
             // Show one level of subcategories of the selected category only
             $category->childs = $catModel->getChildCategories($category->id);
         }
         DiscussHelper::accessNestedCategories($category, $nestedLinks, '0', '', 'listlink', ', ');
         $category->nestedLink = $nestedLinks;
         // Get featured posts from this particular category.
         $featured = $postModel->getDiscussions(array('pagination' => false, 'sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $config->get('layout_featuredpost_limit', $limit), 'featured' => true));
         // Get normal discussion posts.
         $posts = $postModel->getDiscussions(array('sort' => $sort, 'filter' => $activeFilter, 'category' => $category->id, 'limit' => $limit, 'featured' => false));
         $tmpPostsArr = array_merge($featured, $posts);
         if (count($tmpPostsArr) > 0) {
//.........这里部分代码省略.........
开发者ID:pguilford,项目名称:vcomcc,代码行数:101,代码来源:view.html.php

示例4: getPostCount

 /**
  * Retrieves the number of post count from a particular category.
  *
  * @since	3.0
  * @access	public
  */
 public function getPostCount()
 {
     $db = DiscussHelper::getDBO();
     $my = JFactory::getUser();
     $queryExclude = '';
     $excludeCats = array();
     // We need to determine if the user is a guest.
     // If it is a guest, we need to retrieve all private categories.
     if (!$my->id) {
         $query = 'SELECT a.' . $db->nameQuote('id') . ',' . $db->nameQuote('private');
         $query .= ' FROM ' . $db->nameQuote('#__discuss_category') . ' AS a';
         $query .= ' WHERE a.' . $db->nameQuote('private') . '=' . $db->Quote(1);
         $db->setQuery($query);
         $result = $db->loadObjectList();
         for ($i = 0; $i < count($result); $i++) {
             $item = $result[$i];
             $item->childs = null;
             DiscussHelper::buildNestedCategories($item->id, $item);
             $catIds = array();
             $catIds[] = $item->id;
             DiscussHelper::accessNestedCategoriesId($item, $catIds);
             $excludeCats = array_merge($excludeCats, $catIds);
         }
     }
     $model = DiscussHelper::getModel('Categories');
     $childs = $model->getChildIds($this->id);
     $total = count($childs);
     $subcategories = array();
     $subcategories[] = $this->id;
     if ($childs) {
         for ($i = 0; $i < $total; $i++) {
             $subcategories[] = $childs[$i];
         }
     }
     $filtered = array_diff($subcategories, $excludeCats);
     if (empty($filtered)) {
         // just a temp fix when DiscussHelper::getPrivateCategories()
         // failed to get correct result and it will cause the following
         // query fails with error 500.
         return;
     }
     $allowedCategories = array();
     foreach ($filtered as $filteredCategory) {
         if ($filteredCategory) {
             $allowedCategories[] = $db->Quote($filteredCategory);
         }
     }
     $query = 'SELECT COUNT(1) FROM ' . $db->nameQuote('#__discuss_posts') . ' ' . 'WHERE ' . $db->nameQuote('category_id') . ' IN (' . implode(',', $allowedCategories) . ') ' . 'AND ' . $db->nameQuote('parent_id') . '=' . $db->Quote(0) . ' ' . 'AND ' . $db->nameQuote('published') . '=' . $db->Quote(DISCUSS_ID_PUBLISHED);
     $db->setQuery($query);
     $count = $db->loadResult();
     return $count;
 }
开发者ID:BetterBetterBetter,项目名称:B3App,代码行数:58,代码来源:category.php


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