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


PHP modResource::getGroupsList方法代码示例

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


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

示例1: process

 public function process()
 {
     $this->resource = $this->getResource();
     if (!is_object($this->resource) || !$this->resource instanceof modResource) {
         return $this->failure($this->resource);
     }
     /* setup default properties */
     $isLimit = $this->getProperty('limit') > 0;
     $resourceGroupList = $this->resource->getGroupsList(array($this->getProperty('sort') => $this->getProperty('dir')), $isLimit ? $this->getProperty('limit') : 0, $this->getProperty('start'));
     $resourceGroups = $resourceGroupList['collection'];
     $parentGroups = array();
     $mode = $this->getProperty('mode');
     $parent = $this->getProperty('parent', 0);
     $token = $this->getProperty('token', '');
     // see if this request is in the context of a resource reload
     if (!empty($token)) {
         $rgs = $this->getRGReloadData($token);
     } else {
         if (!empty($parent) && $mode == 'create') {
             $parent = $this->modx->getObject('modResource', $parent);
             /** @var modResource $parent */
             if ($parent) {
                 $parentResourceGroups = $parent->getMany('ResourceGroupResources');
                 /** @var modResourceGroupResource $parentResourceGroup */
                 foreach ($parentResourceGroups as $parentResourceGroup) {
                     $parentGroups[] = $parentResourceGroup->get('document_group');
                 }
                 $parentGroups = array_unique($parentGroups);
             }
         }
     }
     $list = array();
     /** @var modResourceGroup $resourceGroup */
     foreach ($resourceGroups as $resourceGroup) {
         $resourceGroupArray = $resourceGroup->toArray();
         $resourceGroupArray['access'] = (bool) $resourceGroupArray['access'];
         if (!empty($parent) && $mode == 'create') {
             $resourceGroupArray['access'] = in_array($resourceGroupArray['id'], $parentGroups) ? true : false;
         }
         if (is_array($rgs) && count($rgs) > 0) {
             $name = $resourceGroup->get('name');
             if (array_key_exists($name, $rgs)) {
                 $resourceGroupArray['access'] = (bool) $rgs[$name]->get('access');
             }
         }
         $list[] = $resourceGroupArray;
     }
     return $this->outputArray($list, $resourceGroupList['total']);
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:49,代码来源:getlist.class.php

示例2: getResourceGroups

 public function getResourceGroups()
 {
     $parentGroups = array();
     if ($this->resource->get('id') == 0) {
         $parent = $this->modx->getObject('modResource', $this->resource->get('parent'));
         /** @var modResource $parent */
         if ($parent) {
             $parentResourceGroups = $parent->getMany('ResourceGroupResources');
             /** @var modResourceGroupResource $parentResourceGroup */
             foreach ($parentResourceGroups as $parentResourceGroup) {
                 $parentGroups[] = $parentResourceGroup->get('document_group');
             }
             $parentGroups = array_unique($parentGroups);
         }
     }
     $this->resourceArray['resourceGroups'] = array();
     $resourceGroups = $this->resource->getGroupsList(array('name' => 'ASC'), 0, 0);
     /** @var modResourceGroup $resourceGroup */
     foreach ($resourceGroups['collection'] as $resourceGroup) {
         $access = (bool) $resourceGroup->get('access');
         if (!empty($parent) && $this->resource->get('id') == 0) {
             $access = in_array($resourceGroup->get('id'), $parentGroups) ? true : false;
         }
         $resourceGroupArray = array($resourceGroup->get('id'), $resourceGroup->get('name'), $access);
         $this->resourceArray['resourceGroups'][] = $resourceGroupArray;
     }
     return $this->resourceArray['resourceGroups'];
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:28,代码来源:resource.class.php

示例3: process

 public function process()
 {
     $this->resource = $this->getResource();
     if (!is_object($this->resource) || !$this->resource instanceof modResource) {
         return $this->failure($this->resource);
     }
     /* setup default properties */
     $isLimit = $this->getProperty('limit') > 0;
     $resourceGroupList = $this->resource->getGroupsList(array($this->getProperty('sort') => $this->getProperty('dir')), $isLimit ? $this->getProperty('limit') : 0, $this->getProperty('start'));
     $resourceGroups = $resourceGroupList['collection'];
     $parentGroups = array();
     $mode = $this->getProperty('mode');
     $parent = $this->getProperty('parent', 0);
     if (!empty($parent) && $mode == 'create') {
         $parent = $this->modx->getObject('modResource', $parent);
         /** @var modResource $parent */
         if ($parent) {
             $parentResourceGroups = $parent->getMany('ResourceGroupResources');
             /** @var modResourceGroupResource $parentResourceGroup */
             foreach ($parentResourceGroups as $parentResourceGroup) {
                 $parentGroups[] = $parentResourceGroup->get('document_group');
             }
             $parentGroups = array_unique($parentGroups);
         }
     }
     $list = array();
     /** @var modResourceGroup $resourceGroup */
     foreach ($resourceGroups as $resourceGroup) {
         $resourceGroupArray = $resourceGroup->toArray();
         $resourceGroupArray['access'] = (bool) $resourceGroupArray['access'];
         if (!empty($parent) && $mode == 'create') {
             $resourceGroupArray['access'] = in_array($resourceGroupArray['id'], $parentGroups) ? true : false;
         }
         $list[] = $resourceGroupArray;
     }
     return $this->outputArray($list, $resourceGroupList['total']);
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:37,代码来源:getlist.class.php


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