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


PHP modX::getCount方法代码示例

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


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

示例1: getList

 /**
  * Abstract method for routing GET requests without a primary key passed. Must be defined in your derivative
  * controller. Handles fetching of collections of objects.
  *
  * @abstract
  * @return array
  */
 public function getList()
 {
     $this->getProperties();
     $c = $this->modx->newQuery($this->classKey);
     $c = $this->addSearchQuery($c);
     $c = $this->prepareListQueryBeforeCount($c);
     $total = $this->modx->getCount($this->classKey, $c);
     $alias = !empty($this->classAlias) ? $this->classAlias : $this->classKey;
     $c->select($this->modx->getSelectColumns($this->classKey, $alias));
     $c = $this->prepareListQueryAfterCount($c);
     $c->sortby($this->getProperty($this->getOption('propertySort', 'sort'), $this->defaultSortField), $this->getProperty($this->getOption('propertySortDir', 'dir'), $this->defaultSortDirection));
     $limit = $this->getProperty($this->getOption('propertyLimit', 'limit'), $this->defaultLimit);
     if (empty($limit)) {
         $limit = $this->defaultLimit;
     }
     $c->limit($limit, $this->getProperty($this->getOption('propertyOffset', 'start'), $this->defaultOffset));
     $objects = $this->modx->getCollection($this->classKey, $c);
     if (empty($objects)) {
         $objects = array();
     }
     $list = array();
     /** @var xPDOObject $object */
     foreach ($objects as $object) {
         $list[] = $this->prepareListObject($object);
     }
     return $this->collection($list, $total);
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:34,代码来源:modrestcontroller.class.php

示例2: getStats

 function getStats()
 {
     $output = '';
     $q_status = $this->modx->newQuery('msOrderStatus', array('active' => 1));
     $q_status->select('id,name,color');
     if ($q_status->prepare() && $q_status->stmt->execute()) {
         while ($row = $q_status->stmt->fetch(PDO::FETCH_ASSOC)) {
             //$output[$row['id']] = $row;
             $output['total_counts'][$row['id']] = array('name' => $row['name'], 'color' => $row['color'], 'count_orders' => $this->modx->getCount('msOrder', array('status' => $row['id'])));
         }
     }
     $q_stats_month = $this->modx->newQuery('msOrder');
     $q_stats_month->select('status,`createdon`, month(`createdon`) AS `order_month`, count(*) AS `order_count`, SUM(cart_cost) AS order_cost');
     $q_stats_month->groupby('month(`createdon`), status');
     $q_stats_month->sortby('createdon', ASC);
     if ($q_stats_month->prepare() && $q_stats_month->stmt->execute()) {
         $output['cart_cost'] = 0;
         $output['cart_count'] = 0;
         while ($row = $q_stats_month->stmt->fetch(PDO::FETCH_ASSOC)) {
             $date = date_parse($row['createdon']);
             $output['stats_month'][$date['year'] . '-' . $date['month']][$row['status']] = array('total_cost' => $row['order_cost'], 'count_orders' => $row['order_count'], 'status' => $row['status']);
             $output['cart_cost'] += $row['order_cost'];
             $output['cart_count'] += $row['order_count'];
         }
         $output['cart_cost'] = number_format($output['cart_cost'], 2, ',', ' ');
         $output['users_count'] = $this->modx->getCount('modUser', array('active' => 1, 'primary_group' => 0));
     }
     return $output;
 }
开发者ID:bendasvadim,项目名称:shopStats,代码行数:29,代码来源:minishop2.class.php

示例3: getThread

 /**
  * Gets the current thread
  * 
  * @static
  * @param modX $modx
  * @param quipThread $thread
  * @param int $parent
  * @param string $ids
  * @param string $sortBy
  * @param string $sortByAlias
  * @param string $sortDir
  * @return array
  */
 public static function getThread(modX $modx, quipThread $thread, $parent = 0, $ids = '', $sortBy = 'rank', $sortByAlias = 'quipComment', $sortDir = 'ASC')
 {
     $c = $modx->newQuery('quipComment');
     $c->innerJoin('quipThread', 'Thread');
     $c->leftJoin('quipCommentClosure', 'Descendants');
     $c->leftJoin('quipCommentClosure', 'RootDescendant', 'RootDescendant.descendant = quipComment.id AND RootDescendant.ancestor = 0');
     $c->leftJoin('quipCommentClosure', 'Ancestors');
     $c->leftJoin('modUser', 'Author');
     $c->leftJoin('modResource', 'Resource');
     $c->where(array('quipComment.thread' => $thread->get('name'), 'quipComment.deleted' => false));
     if (!$thread->checkPolicy('moderate')) {
         $c->andCondition(array('quipComment.approved' => true), null, 2);
     }
     if (!empty($parent)) {
         $c->where(array('Descendants.ancestor' => $parent));
     }
     $total = $modx->getCount('quipComment', $c);
     if (!empty($ids)) {
         $c->where(array('Descendants.ancestor:IN' => $ids));
     }
     $c->select($modx->getSelectColumns('quipComment', 'quipComment'));
     $c->select(array('Thread.resource', 'Thread.idprefix', 'Thread.existing_params', 'RootDescendant.depth', 'Author.username', 'Resource.pagetitle', 'Resource.context_key'));
     $c->sortby($modx->escape($sortByAlias) . '.' . $modx->escape($sortBy), $sortDir);
     $comments = $modx->getCollection('quipComment', $c);
     return array('results' => $comments, 'total' => $total);
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:39,代码来源:quipcomment.class.php

示例4: getStatistics

 /**
  * Get the statistics for the bottom area of the forums
  * @return void
  */
 protected function getStatistics()
 {
     $this->setPlaceholder('totalPosts', number_format((int) $this->getPostCount()));
     $this->setPlaceholder('totalTopics', number_format((int) $this->getThreadCount()));
     $this->setPlaceholder('totalMembers', number_format((int) $this->modx->getCount('disUser')));
     /* active in last 40 */
     if ($this->modx->getOption('discuss.show_whos_online', null, true)) {
         $this->setPlaceholder('activeUsers', $this->discuss->hooks->load('user/active_in_last'));
     } else {
         $this->setPlaceholder('activeUsers', '');
     }
     /* total active */
     $this->setPlaceholder('totalMembersActive', number_format((int) $this->modx->getCount('disSession', array('user:!=' => 0))));
     $this->setPlaceholder('totalVisitorsActive', number_format((int) $this->modx->getCount('disSession', array('user' => 0))));
     /**
      * forum activity
      * @var disForumActivity $activity
      */
     $activity = $this->modx->getObject('disForumActivity', array('day' => date('Y-m-d')));
     if (!$activity) {
         $activity = $this->modx->newObject('disForumActivity');
         $activity->set('day', date('Y-m-d'));
         $activity->save();
     }
     $this->setPlaceholders($activity->toArray('activity.'));
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:30,代码来源:discusscontroller.class.php

示例5: getSettings

 /**
  * Grab settings (from cache if possible) as key => value pairs.
  * @return array|mixed
  */
 public function getSettings()
 {
     /* Attempt to get from cache */
     $cacheOptions = array(xPDO::OPT_CACHE_KEY => 'system_settings');
     $settings = $this->modx->getCacheManager()->get('clientconfig', $cacheOptions);
     if (empty($settings) && $this->modx->getCount('cgSetting') > 0) {
         $collection = $this->modx->getCollection('cgSetting');
         $settings = array();
         /* @var cgSetting $setting */
         foreach ($collection as $setting) {
             $settings[$setting->get('key')] = $setting->get('value');
         }
         /* Write to cache again */
         $this->modx->cacheManager->set('clientconfig', $settings, 0, $cacheOptions);
     }
     return is_array($settings) ? $settings : array();
 }
开发者ID:adamwintle,项目名称:flexibility5,代码行数:21,代码来源:clientconfig.class.php

示例6: templateBranch

 /**
  * Recursive template of branch of menu
  *
  * @param array $row
  *
  * @return mixed|string
  */
 public function templateBranch($row = array())
 {
     $children = '';
     $row['level'] = $this->level;
     if (!empty($row['children']) && ($this->isHere($row['id']) || empty($this->pdoTools->config['hideSubMenus'])) && $this->checkResource($row['id'])) {
         $idx = 1;
         $this->level++;
         $count = count($row['children']);
         foreach ($row['children'] as $v) {
             $v['idx'] = $idx++;
             $v['last'] = (int) $v['idx'] == $count;
             $children .= $this->templateBranch($v);
         }
         $this->level--;
         $row['children'] = $count;
     } else {
         $row['children'] = isset($row['children']) ? count($row['children']) : 0;
     }
     if (!empty($this->pdoTools->config['countChildren'])) {
         if ($ids = $this->modx->getChildIds($row['id'])) {
             $tstart = microtime(true);
             $count = $this->modx->getCount('modResource', array('id:IN' => $ids, 'published' => true, 'deleted' => false));
             $this->modx->queryTime += microtime(true) - $tstart;
             $this->modx->executedQueries++;
             $this->pdoTools->addTime('Got the number of active children for resource "' . $row['id'] . '": ' . $count);
         } else {
             $count = 0;
         }
         $row['children'] = $count;
     }
     if (!empty($children)) {
         $pls = $this->addWayFinderPlaceholders(array('wrapper' => $children, 'classes' => ' class="' . $this->pdoTools->config['innerClass'] . '"', 'classNames' => $this->pdoTools->config['innerClass'], 'classnames' => $this->pdoTools->config['innerClass'], 'level' => $this->level));
         $row['wrapper'] = $this->pdoTools->parseChunk($this->pdoTools->config['tplInner'], $pls);
     } else {
         $row['wrapper'] = '';
     }
     if (empty($row['menutitle']) && !empty($row['pagetitle'])) {
         $row['menutitle'] = $row['pagetitle'];
     }
     $classes = $this->getClasses($row);
     if (!empty($classes)) {
         $row['classNames'] = $row['classnames'] = $classes;
         $row['classes'] = ' class="' . $classes . '"';
     } else {
         $row['classNames'] = $row['classnames'] = $row['classes'] = '';
     }
     if (!empty($this->pdoTools->config['useWeblinkUrl']) && $row['class_key'] == 'modWebLink') {
         $row['link'] = is_numeric(trim($row['content'], '[]~ ')) ? $this->modx->makeUrl(intval(trim($row['content'], '[]~ ')), '', '', $this->pdoTools->config['scheme']) : $row['content'];
     } else {
         $row['link'] = $this->modx->makeUrl($row['id'], $row['context_key'], '', $this->pdoTools->config['scheme']);
     }
     $row['title'] = !empty($this->pdoTools->config['titleOfLinks']) ? $row[$this->pdoTools->config['titleOfLinks']] : '';
     $tpl = $this->getTpl($row);
     $row = $this->addWayFinderPlaceholders($row);
     return $this->pdoTools->getChunk($tpl, $row, $this->pdoTools->config['fastMode']);
 }
开发者ID:bendasvadim,项目名称:pdoTools,代码行数:63,代码来源:pdomenu.class.php

示例7: hasSubscription

 /**
  * Check if a user (by id) has a subscription to this thread
  *
  * @param int $userId ID of disUser
  * @return bool True if has a subscription
  */
 public function hasSubscription($userId = 0)
 {
     if (!isset($this->hasSubscription)) {
         if (empty($userId)) {
             $userId = $this->xpdo->discuss->user->get('id');
         }
         $this->hasSubscription = $this->xpdo->getCount('disUserNotification', array('user' => $userId, 'thread' => $this->get('id'))) > 0;
     }
     return $this->hasSubscription;
 }
开发者ID:oneismore,项目名称:Discuss,代码行数:16,代码来源:disthread.class.php

示例8: countMessages

 /**
  * Gets a count of {@link modUserMessage} objects ascribed to the user.
  *
  * @access public
  * @param mixed $read
  * @return integer The number of messages.
  */
 public function countMessages($read = '')
 {
     if ($read == 'read') {
         $read = 1;
     } elseif ($read == 'unread') {
         $read = 0;
     }
     $criteria = array('recipient' => $this->get('id'));
     if ($read) {
         $criteria['messageread'] = $read;
     }
     return $this->xpdo->getCount('modUserMessage', $criteria);
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:20,代码来源:moduser.class.php

示例9: _run

 /**
  * @param sTaskRun $run
  * @return mixed
  */
 public function _run(&$run)
 {
     $snippet = $this->get('content');
     $scriptProperties = (array) $run->get('data');
     $scriptProperties['task'] =& $this;
     $scriptProperties['run'] =& $run;
     // Check if the snippet exists before running it.
     // This may fail with OnElementNotFound snippets in 2.3
     $key = !empty($snippet) && is_numeric($snippet) ? 'id' : 'name';
     if ($this->xpdo->getCount('modSnippet', array($key => $snippet)) < 1) {
         $run->addError('snippet_not_found', array('snippet' => $snippet));
         return false;
     }
     /** @var modSnippet $snippet */
     $snippet = $this->xpdo->getObject('modSnippet', array($key => $snippet));
     if (empty($snippet) || !is_object($snippet)) {
         $run->addError('snippet_not_found', array('snippet' => $snippet));
         return false;
     }
     $snippet->setCacheable(false);
     $out = $snippet->process($scriptProperties);
     unset($scriptProperties, $snippet);
     return $out;
 }
开发者ID:sebastian-marinescu,项目名称:Scheduler,代码行数:28,代码来源:ssnippettask.class.php

示例10: checkDependencies

 public function checkDependencies()
 {
     $failed = array();
     foreach ($this->dependencies as $dependency) {
         $found = $this->modx->getCount('transport.modTransportPackage', array('package_name' => $dependency['name']));
         $foundInGPM = $this->modx->getCount('GitPackage', array('name' => $dependency['name'], 'OR:dir_name:=' => $dependency['name']));
         if ($found == 0 && $foundInGPM == 0) {
             $failed[] = $dependency['name'];
         }
     }
     if (count($failed) == 0) {
         return true;
     }
     return $failed;
 }
开发者ID:pixelfanatiker,项目名称:Git-Package-Management,代码行数:15,代码来源:gitpackageconfig.class.php

示例11: _hasConversations

 /**
  * Check resource have conversations
  *
  * @param integer $id Resource ID
  *
  * @access private
  * @return boolean True if resource have a conversation
  */
 private function _hasConversations($id)
 {
     if (!intval($id)) {
         return false;
     }
     /**
      * Checking through the map so the cache
      */
     if ($map = $this->conversationsMap()) {
         /**
          * If the resource contains at least one topic return true
          */
         if (array_key_exists($id, $map)) {
             return true;
         }
         return false;
     } elseif ($this->modx->getCount('modxTalksConversation', array('rid' => $id))) {
         /**
          * If the conversationsMap () returned false (with the cache enabled), on-base
          */
         return true;
     }
     return false;
 }
开发者ID:jolichter,项目名称:modxTalks,代码行数:32,代码来源:modxtalksrouter.class.php

示例12: listPackageVersions

 public static function listPackageVersions(modX &$modx, $criteria, $limit = 0, $offset = 0) {
     $result = array('collection' => array(), 'total' => 0);
     $c = $modx->newQuery('transport.modTransportPackage');
     $c->select($modx->getSelectColumns('transport.modTransportPackage','modTransportPackage'));
     $c->select(array('Provider.name AS provider_name'));
     $c->leftJoin('transport.modTransportProvider','Provider');
     $c->where($criteria);
     $result['total'] = $modx->getCount('modTransportPackage',$c);
     $c->sortby('modTransportPackage.version_major', 'DESC');
     $c->sortby('modTransportPackage.version_minor', 'DESC');
     $c->sortby('modTransportPackage.version_patch', 'DESC');
     $c->sortby('IF(modTransportPackage.release = "" OR modTransportPackage.release = "ga" OR modTransportPackage.release = "pl","z",modTransportPackage.release) DESC','');
     $c->sortby('modTransportPackage.release_index', 'DESC');
     if((int)$limit > 0) {
         $c->limit((int)$limit, (int)$offset);
     }
     $result['collection'] = $modx->getCollection('transport.modTransportPackage',$c);
     return $result;
 }
开发者ID:raf3600,项目名称:revolution,代码行数:19,代码来源:modtransportpackage.class.php

示例13: alreadyExists

 public function alreadyExists($name)
 {
     return $this->modx->getCount('modUser', array('username' => $name, 'id:!=' => $this->user->get('id'))) > 0;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:4,代码来源:_validation.php

示例14: getList

 public static function getList(modX &$modx, array $scriptProperties = array())
 {
     $sort = $modx->getOption('sort', $scriptProperties, 'rank');
     $cacheKey = 'gallery/item/list/' . md5(serialize($scriptProperties));
     if ($modx->getCacheManager() && ($cache = $modx->cacheManager->get($cacheKey))) {
         $items = array();
         foreach ($cache['items'] as $data) {
             /** @var galItem $item */
             $item = $modx->newObject('galItem');
             $item->fromArray($data, '', true, true);
             $items[] = $item;
         }
         if (in_array(strtolower($sort), array('random', 'rand()', 'rand'))) {
             shuffle($items);
         }
         $data = array('items' => $items, 'total' => $cache['total'], 'album' => $cache['album']);
     } else {
         $album = $modx->getOption('album', $scriptProperties, false);
         $tag = $modx->getOption('tag', $scriptProperties, '');
         $limit = $modx->getOption('limit', $scriptProperties, 0);
         $start = $modx->getOption('start', $scriptProperties, 0);
         /* Fix to make it work with getPage which uses "offset" instead of "start" */
         $offset = $modx->getOption('offset', $scriptProperties, 0);
         if ($offset > 0) {
             $start = $offset;
         }
         $sortAlias = $modx->getOption('sortAlias', $scriptProperties, 'galItem');
         if ($sort == 'rank') {
             $sortAlias = 'AlbumItems';
         }
         $dir = $modx->getOption('dir', $scriptProperties, 'ASC');
         $showInactive = $modx->getOption('showInactive', $scriptProperties, false);
         $activeAlbum = array('id' => '', 'name' => '', 'description' => '');
         $tagc = $modx->newQuery('galTag');
         $tagc->setClassAlias('TagsJoin');
         $tagc->select('GROUP_CONCAT(' . $modx->getSelectColumns('galTag', 'TagsJoin', '', array('tag')) . ')');
         $tagc->where($modx->getSelectColumns('galTag', 'TagsJoin', '', array('item')) . ' = ' . $modx->getSelectColumns('galItem', 'galItem', '', array('id')));
         $tagc->prepare();
         $tagSql = $tagc->toSql();
         $c = $modx->newQuery('galItem');
         $c->innerJoin('galAlbumItem', 'AlbumItems');
         $c->innerJoin('galAlbum', 'Album', $modx->getSelectColumns('galAlbumItem', 'AlbumItems', '', array('album')) . ' = ' . $modx->getSelectColumns('galAlbum', 'Album', '', array('id')));
         /* pull by album */
         if (!empty($album)) {
             $albumField = is_numeric($album) ? 'id' : 'name';
             $albumWhere = $albumField == 'name' ? array('name' => $album) : $album;
             /** @var galAlbum $album */
             $album = $modx->getObject('galAlbum', $albumWhere);
             if (empty($album)) {
                 return '';
             }
             $c->where(array('Album.' . $albumField => $album->get($albumField)));
             $activeAlbum['id'] = $album->get('id');
             $activeAlbum['name'] = $album->get('name');
             $activeAlbum['description'] = $album->get('description');
             $activeAlbum['year'] = $album->get('year');
             unset($albumWhere, $albumField);
         }
         if (!empty($tag)) {
             /* pull by tag */
             $c->innerJoin('galTag', 'Tags');
             $c->where(array('Tags.tag' => $tag));
             if (empty($album)) {
                 $activeAlbum['id'] = 0;
                 $activeAlbum['name'] = $tag;
                 $activeAlbum['description'] = '';
             }
         }
         $c->where(array('galItem.mediatype' => $modx->getOption('mediatype', $scriptProperties, 'image')));
         if (!$showInactive) {
             $c->where(array('galItem.active' => true));
         }
         $count = $modx->getCount('galItem', $c);
         $c->select($modx->getSelectColumns('galItem', 'galItem'));
         $c->select(array('(' . $tagSql . ') AS tags'));
         if (in_array(strtolower($sort), array('random', 'rand()', 'rand'))) {
             $c->sortby('RAND()', $dir);
         } else {
             $c->sortby($sortAlias . '.' . $sort, $dir);
         }
         if (!empty($limit)) {
             $c->limit($limit, $start);
         }
         $items = $modx->getCollection('galItem', $c);
         $data = array('items' => $items, 'total' => $count, 'album' => $activeAlbum);
         $cache = array('items' => array(), 'total' => $count, 'album' => $activeAlbum);
         /** @var galItem $item */
         foreach ($items as $item) {
             $cache['items'][] = $item->toArray('', true);
         }
         $modx->cacheManager->set($cacheKey, $cache);
     }
     return $data;
 }
开发者ID:Piterden,项目名称:modx_testfloor,代码行数:94,代码来源:galitem.class.php

示例15: getResource

 /**
  * Gets a requested resource and all required data.
  *
  * @param string $method The method, 'id', or 'alias', by which to perform
  * the resource lookup.
  * @param string|integer $identifier The identifier with which to search.
  * @param array $options An array of options for the resource fetching
  * @return modResource The requested modResource instance or request
  * is forwarded to the error page, or unauthorized page.
  */
 public function getResource($method, $identifier, array $options = array())
 {
     $resource = null;
     if ($method == 'alias') {
         $resourceId = $this->modx->aliasMap[$identifier];
     } else {
         $resourceId = $identifier;
     }
     if (!is_numeric($resourceId)) {
         $this->modx->sendErrorPage();
     }
     $isForward = array_key_exists('forward', $options) && !empty($options['forward']);
     $fromCache = false;
     $cacheKey = $this->modx->context->get('key') . "/resources/{$resourceId}";
     $cachedResource = $this->modx->cacheManager->get($cacheKey, array(xPDO::OPT_CACHE_KEY => $this->modx->getOption('cache_resource_key', null, 'resource'), xPDO::OPT_CACHE_HANDLER => $this->modx->getOption('cache_resource_handler', null, $this->modx->getOption(xPDO::OPT_CACHE_HANDLER)), xPDO::OPT_CACHE_FORMAT => (int) $this->modx->getOption('cache_resource_format', null, $this->modx->getOption(xPDO::OPT_CACHE_FORMAT, null, xPDOCacheManager::CACHE_PHP))));
     if (is_array($cachedResource) && array_key_exists('resource', $cachedResource) && is_array($cachedResource['resource'])) {
         /** @var modResource $resource */
         $resource = $this->modx->newObject($cachedResource['resourceClass']);
         if ($resource) {
             $resource->fromArray($cachedResource['resource'], '', true, true, true);
             $resource->_content = $cachedResource['resource']['_content'];
             $resource->_isForward = isset($cachedResource['resource']['_isForward']) && !empty($cachedResource['resource']['_isForward']);
             if (isset($cachedResource['contentType'])) {
                 $contentType = $this->modx->newObject('modContentType');
                 $contentType->fromArray($cachedResource['contentType'], '', true, true, true);
                 $resource->addOne($contentType, 'ContentType');
             }
             if (isset($cachedResource['resourceGroups'])) {
                 $rGroups = array();
                 foreach ($cachedResource['resourceGroups'] as $rGroupKey => $rGroup) {
                     $rGroups[$rGroupKey] = $this->modx->newObject('modResourceGroupResource', $rGroup);
                 }
                 $resource->addMany($rGroups);
             }
             if (isset($cachedResource['policyCache'])) {
                 $resource->setPolicies(array($this->modx->context->get('key') => $cachedResource['policyCache']));
             }
             if (isset($cachedResource['elementCache'])) {
                 $this->modx->elementCache = $cachedResource['elementCache'];
             }
             if (isset($cachedResource['sourceCache'])) {
                 $this->modx->sourceCache = $cachedResource['sourceCache'];
             }
             if ($resource->get('_jscripts')) {
                 $this->modx->jscripts = $this->modx->jscripts + $resource->get('_jscripts');
             }
             if ($resource->get('_sjscripts')) {
                 $this->modx->sjscripts = $this->modx->sjscripts + $resource->get('_sjscripts');
             }
             if ($resource->get('_loadedjscripts')) {
                 $this->modx->loadedjscripts = array_merge($this->modx->loadedjscripts, $resource->get('_loadedjscripts'));
             }
             $isForward = $resource->_isForward;
             $resource->setProcessed(true);
             $fromCache = true;
         }
     }
     if (!$fromCache || !is_object($resource)) {
         $criteria = $this->modx->newQuery('modResource');
         $criteria->select(array($this->modx->escape('modResource') . '.*'));
         $criteria->where(array('id' => $resourceId, 'deleted' => '0'));
         if (!$this->modx->hasPermission('view_unpublished') || $this->modx->getSessionState() !== modX::SESSION_STATE_INITIALIZED) {
             $criteria->where(array('published' => 1));
         }
         if ($resource = $this->modx->getObject('modResource', $criteria)) {
             if ($resource instanceof modResource) {
                 if ($resource->get('context_key') !== $this->modx->context->get('key')) {
                     if (!$isForward || $isForward && !$this->modx->getOption('allow_forward_across_contexts', $options, false)) {
                         if (!$this->modx->getCount('modContextResource', array($this->modx->context->get('key'), $resourceId))) {
                             return null;
                         }
                     }
                 }
                 $resource->_isForward = $isForward;
                 if (!$resource->checkPolicy('view')) {
                     $this->modx->sendUnauthorizedPage();
                 }
                 if ($tvs = $resource->getMany('TemplateVars', 'all')) {
                     /** @var modTemplateVar $tv */
                     foreach ($tvs as $tv) {
                         $resource->set($tv->get('name'), array($tv->get('name'), $tv->getValue($resource->get('id')), $tv->get('display'), $tv->get('display_params'), $tv->get('type')));
                     }
                 }
                 $this->modx->resourceGenerated = true;
             }
         }
     } elseif ($fromCache && $resource instanceof modResource && !$resource->get('deleted')) {
         if ($resource->checkPolicy('load') && ($resource->get('published') || $this->modx->getSessionState() === modX::SESSION_STATE_INITIALIZED && $this->modx->hasPermission('view_unpublished'))) {
             if ($resource->get('context_key') !== $this->modx->context->get('key')) {
                 if (!$isForward || $isForward && !$this->modx->getOption('allow_forward_across_contexts', $options, false)) {
//.........这里部分代码省略.........
开发者ID:semencov-com,项目名称:affiliate,代码行数:101,代码来源:modrequest.class.php


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