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


PHP CategoryModel::setJoinUserCategory方法代码示例

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


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

示例1: getCategoryTree

 /**
  * Build a structured tree of children for the specified category.
  *
  * @param int|string|object|array|null $category Category or code/ID to build the tree for. Null for all.
  * @param string|null $displayAs What display should the tree be configured for?
  * @param bool $recent Join in recent record info?
  * @param bool $watching Filter categories by "watching" status?
  * @return array
  */
 private function getCategoryTree($category = null, $displayAs = null, $recent = false, $watching = false)
 {
     $categoryIdentifier = null;
     if (is_string($category) || is_numeric($category)) {
         $category = CategoryModel::categories($category);
     }
     if ($category) {
         if ($displayAs === null) {
             $displayAs = val('DisplayAs', $category, 'Discussions');
         }
         $categoryIdentifier = val('CategoryID', $category, null);
     }
     switch ($displayAs) {
         case 'Flat':
             $perPage = c('Vanilla.Categories.PerPage', 30);
             $page = Gdn::request()->get('Page', Gdn::request()->get('page', null));
             list($offset, $limit) = offsetLimit($page, $perPage);
             $categoryTree = $this->CategoryModel->getTreeAsFlat($categoryIdentifier, $offset, $limit);
             $this->setData('_Limit', $perPage);
             $this->setData('_CurrentRecords', count($categoryTree));
             break;
         case 'Categories':
         case 'Discussions':
         case 'Default':
         case 'Nested':
         default:
             $categoryTree = $this->CategoryModel->setJoinUserCategory(true)->getChildTree($categoryIdentifier ?: null, ['depth' => CategoryModel::instance()->getMaxDisplayDepth() ?: 10]);
     }
     if ($recent) {
         $this->CategoryModel->joinRecent($categoryTree);
     }
     return $categoryTree;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:42,代码来源:class.categoriescontroller.php

示例2: getData

 /**
  * Get the data for this module.
  */
 protected function getData()
 {
     // Allow plugins to set different data.
     $this->fireEvent('GetData');
     if ($this->Data) {
         return;
     }
     $categoryModel = new CategoryModel();
     $Categories = $categoryModel->setJoinUserCategory(true)->getChildTree(null);
     $Categories = CategoryModel::flattenTree($Categories);
     $Categories2 = $Categories;
     // Filter out the categories we aren't watching.
     foreach ($Categories2 as $i => $Category) {
         if (!$Category['PermsDiscussionsView'] || !$Category['Following']) {
             unset($Categories[$i]);
         }
     }
     $Data = new Gdn_DataSet($Categories, DATASET_TYPE_ARRAY);
     $Data->datasetType(DATASET_TYPE_OBJECT);
     $this->Data = $Data;
 }
开发者ID:vanilla,项目名称:vanilla,代码行数:24,代码来源:class.categoriesmodule.php


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