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


PHP modResource::getOne方法代码示例

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


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

示例1: process

 /**
  * Custom logic code here for setting placeholders, etc
  * @param array $scriptProperties
  * @return mixed
  */
 public function process(array $scriptProperties = array())
 {
     $placeholders = array();
     $this->resource = $this->modx->getObject('modResource', $scriptProperties['id']);
     if ($this->resource == null) {
         return $this->failure(sprintf($this->modx->lexicon('resource_with_id_not_found'), $scriptProperties['id']));
     }
     if (!$this->resource->checkPolicy('view')) {
         return $this->failure($this->modx->lexicon('access_denied'));
     }
     $this->resource->getOne('CreatedBy');
     $this->resource->getOne('EditedBy');
     $this->resource->getOne('Template');
     $server_offset_time = intval($this->modx->getOption('server_offset_time', null, 0));
     $this->resource->set('createdon_adjusted', strftime('%c', $this->resource->get('createdon') + $server_offset_time));
     $this->resource->set('editedon_adjusted', strftime('%c', $this->resource->get('editedon') + $server_offset_time));
     $this->resource->_contextKey = $this->resource->get('context_key');
     $buffer = $this->modx->cacheManager->get($this->resource->getCacheKey(), 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 ($buffer) {
         $placeholders['buffer'] = htmlspecialchars($buffer['resource']['_content']);
     }
     /* assign resource to smarty */
     $placeholders['resource'] = $this->resource;
     /* make preview url */
     $this->getPreviewUrl();
     $placeholders['_ctx'] = $this->resource->get('context_key');
     return $placeholders;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:33,代码来源:data.class.php

示例2: checkParentPermissions

 /**
  * Ensure the user can add children to the parent
  * @return boolean
  */
 public function checkParentPermissions()
 {
     $canAddChildren = true;
     $this->parentResource = $this->oldResource->getOne('Parent');
     if ($this->parentResource && !$this->parentResource->checkPolicy('add_children')) {
         $canAddChildren = false;
     }
     return $canAddChildren;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:13,代码来源:duplicate.class.php

示例3: setup

 public function setup()
 {
     $this->modx->lexicon->load('default', 'resource');
     if (empty($this->config['gpc']['rid'])) {
         return $this->modx->lexicon('resource_err_nf');
     }
     $this->resource = $this->modx->getObject('modResource', intval($this->config['gpc']['rid']));
     if (empty($this->resource)) {
         return $this->modx->lexicon('resource_err_nfs', array('id' => intval($this->config['gpc']['rid'])));
     }
     $this->template = $this->resource->getOne('Template');
     return true;
 }
开发者ID:rossng,项目名称:HandyMan,代码行数:13,代码来源:update.class.php

示例4: setup

 public function setup()
 {
     $this->modx->lexicon->load('default', 'resource');
     if (empty($this->config['gpc']['id'])) {
         return $this->modx->lexicon('resource_err_nf');
     }
     $this->resource = $this->modx->getObject('modResource', intval($this->config['gpc']['id']));
     if (empty($this->resource)) {
         return $this->modx->lexicon('resource_err_nfs', array('id' => intval($this->config['gpc']['id'])));
     }
     $this->resource->set('editedby', $this->modx->user->get('id'));
     $this->resource->set('editedon', strftime('%Y-%m-%d %H:%M:%S'));
     $this->template = $this->resource->getOne('Template');
     return true;
 }
开发者ID:rossng,项目名称:HandyMan,代码行数:15,代码来源:update.save.class.php

示例5: process

 /**
  * Process this page, load the resource, and present its values
  * @return void
  */
 public function process()
 {
     $this->setPlaceholders($this->resource->toArray());
     $this->template = $this->resource->getOne('Template');
     if ($this->template) {
         $this->setPlaceholder('template', $this->template->get('templatename'));
     }
     $contentType = $this->resource->getOne('ContentType');
     if ($contentType) {
         $this->setPlaceholder('content_type', $contentType->get('name'));
     }
     $this->getContent();
     $this->getResourceFields();
     $this->getResourceSettings();
     if ($this->template) {
         $this->getTemplateVariables();
     }
 }
开发者ID:rossng,项目名称:HandyMan,代码行数:22,代码来源:view.class.php

示例6: setResource

 /**
  * Sets the current resource to an internal variable, and also updates the working context.
  *
  * @param \modResource $resource
  */
 public function setResource(\modResource $resource)
 {
     $this->resource = $resource;
     $this->setWorkingContext($resource->get('context_key'));
     // Make sure the resource is also added to $modx->resource if there's nothing set there
     // This provides compatibility for dynamic media source paths using snippets relying on $modx->resource
     if (!$this->modx->resource) {
         $this->modx->resource =& $resource;
     }
     if ($this->getBooleanOption($this->namespace . '.parse_parent_path', null, true) && ($parent = $resource->getOne('Parent'))) {
         $this->setPathVariables(array('parent_alias' => $parent->get('alias')));
         $pids = $this->modx->getParentIds($resource->get('id'), (int) $this->getOption($this->namespace . '.parse_parent_path_height', null, 10), array('context' => $resource->get('context_key')));
         $pidx = count($pids) - 2;
         if ($pidx >= 0 && ($ultimateParent = $this->modx->getObject('modResource', $pids[$pidx]))) {
             $this->setPathVariables(array('ultimate_parent' => $ultimateParent->get('id'), 'ultimate_parent_alias' => $ultimateParent->get('alias'), 'ultimate_alias' => $ultimateParent->get('alias')));
         } else {
             $this->setPathVariables(array('ultimate_parent' => '', 'ultimate_parent_alias' => '', 'ultimate_alias' => ''));
         }
     } else {
         $this->setPathVariables(array('parent_alias' => '', 'ultimate_parent' => '', 'ultimate_parent_alias' => '', 'ultimate_alias' => ''));
     }
 }
开发者ID:hansek,项目名称:Alpacka,代码行数:27,代码来源:Alpacka.php

示例7: getResourceAlias

 /**
  * Calculate a resource alias from the imported file
  *
  * @param modResource $resource A reference to the new modResource object
  * @param string $alias A suggested alias
  * @param integer $parent The parent ID of the Resource
  * @param string $context The context of the Resource
  * @return string The formatted alias
  */
 public function getResourceAlias(&$resource, $alias, $parent, $context = 'web')
 {
     // auto assign alias
     if ($alias == '' && $this->modx->getOption('automatic_alias')) {
         $alias = strtolower(trim($resource->cleanAlias($resource->get('pagetitle'))));
     } else {
         $alias = $resource->cleanAlias($alias);
     }
     $resourceContext = $this->modx->getObject('modContext', $context);
     $resourceContext->prepare(true);
     $isHtml = true;
     $extension = '';
     $containerSuffix = $this->modx->getOption('container_suffix', null, '');
     /** @var modContentType $contentType */
     if ($contentType = $resource->getOne('ContentType')) {
         $extension = $contentType->getExtension();
         $isHtml = strpos($contentType->get('mime_type'), 'html') !== false;
     }
     if ($resource->get('isfolder') && $isHtml && !empty($containerSuffix)) {
         $extension = $containerSuffix;
     }
     $aliasPath = '';
     if ($this->modx->getOption('use_alias_path')) {
         $pathParentId = intval($parent);
         $parentResources = array();
         $currResource = $this->modx->getObject('modResource', $pathParentId);
         while ($currResource) {
             $parentAlias = $currResource->get('alias');
             if (empty($parentAlias)) {
                 $parentAlias = "{$pathParentId}";
             }
             $parentResources[] = "{$parentAlias}";
             $pathParentId = $currResource->get('parent');
             $currResource = $currResource->getOne('Parent');
         }
         $aliasPath = !empty($parentResources) ? implode('/', array_reverse($parentResources)) : '';
     }
     $fullAlias = $aliasPath . $alias . $extension;
     $iterations = 3;
     $origAlias = $alias;
     while ($duplicateId = $this->modx->findResource($fullAlias) && $iterations > 0) {
         $iterations--;
         $this->log($this->modx->lexicon('import_duplicate_alias_found', array('id' => $duplicateId, 'alias' => $fullAlias)));
         $alias = $origAlias . '-' . substr(uniqid(''), -3);
         $fullAlias = $aliasPath . $alias . $extension;
     }
     return $alias;
 }
开发者ID:gpsietzema,项目名称:revolution,代码行数:57,代码来源:modstaticimport.class.php

示例8:

 /**
  * {@inheritdoc}
  * */
 public function &getOne($alias, $criteria = null, $cacheFlag = true)
 {
     if (in_array($alias, $this->dataRelated)) {
         if (!is_object($this->data)) {
             $this->loadData();
         }
         return $this->data->getOne($alias, $criteria, $cacheFlag);
     } else {
         return parent::getOne($alias, $criteria, $cacheFlag);
     }
 }
开发者ID:Vitaliz,项目名称:miniShop2,代码行数:14,代码来源:msproduct.class.php


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