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


PHP modResource::set方法代码示例

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


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

示例1: process

 /**
  * {@inheritDoc}
  * @return mixed
  */
 public function process()
 {
     if ($this->modx->getOption('site_start') == $this->resource->get('id')) {
         return $this->failure($this->modx->lexicon('resource_err_delete_sitestart'));
     }
     if ($this->modx->getOption('site_unavailable_page') == $this->resource->get('id')) {
         return $this->failure($this->modx->lexicon('resource_err_delete_siteunavailable'));
     }
     /* check for locks on resource */
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     $childrenIds = $this->getChildrenIds();
     $this->fireBeforeDelete($childrenIds);
     /* delete children */
     $this->deleteChildren();
     /* delete the document. */
     $this->resource->set('deleted', true);
     $this->resource->set('deletedby', $this->modx->user->get('id'));
     $this->resource->set('deletedon', $this->deletedTime);
     if ($this->resource->save() == false) {
         $this->resource->removeLock();
         return $this->failure($this->modx->lexicon('resource_err_delete'));
     }
     $this->fireAfterDelete($childrenIds);
     /* log manager action */
     $this->logManagerAction();
     $this->resource->removeLock();
     /* empty cache */
     $this->clearCache();
     return $this->success('', $this->resource->get(array('id', 'deleted', 'deletedby', 'deletedon')));
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:36,代码来源:delete.class.php

示例2: 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

示例3: moveFilesUnderCorrectResource

 private function moveFilesUnderCorrectResource(&$md, $field)
 {
     $matches = array();
     preg_match_all('~' . $this->uploadURL . '0/(?<file>[^ "\\)]+)~', $md, $matches);
     $path = $this->uploadPath . '0/';
     $correctPath = $this->uploadPath . $this->resource->id . '/';
     if (!is_dir($correctPath)) {
         mkdir($correctPath);
     }
     $files = $matches['file'];
     if (!empty($files)) {
         $files = array_map('trim', $files);
         $files = array_keys(array_flip($files));
         $files = array_filter($files);
         foreach ($files as $file) {
             rename($path . $file, $correctPath . $file);
         }
         $md = str_replace($this->uploadURL . '0/', $this->uploadURL . $this->resource->id . '/', $md);
         if (strpos($field, 'tv')) {
             $tvID = str_replace('tv', '', $field);
             $content = str_replace($this->uploadURL . '0/', $this->uploadURL . $this->resource->id . '/', $this->resource->getTVValue($tvID));
             $this->resource->setTVValue($tvID, $content);
         } else {
             if ($field == 'ta') {
                 $field = 'content';
             }
             $content = str_replace($this->uploadURL . '0/', $this->uploadURL . $this->resource->id . '/', $this->resource->get($field));
             $this->resource->set($field, $content);
             $this->resource->save();
         }
     }
 }
开发者ID:ashliewebb,项目名称:ashliewebb,代码行数:32,代码来源:OnDocFormSave.php

示例4: process

 public function process()
 {
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     /* 'undelete' the resource. */
     $this->resource->set('deleted', false);
     $this->resource->set('deletedby', 0);
     $this->resource->set('deletedon', 0);
     if ($this->resource->save() == false) {
         $this->resource->removeLock();
         return $this->failure($this->modx->lexicon('resource_err_undelete'));
     }
     $this->unDeleteChildren($this->resource->get('id'), $this->resource->get('deletedon'));
     $this->fireAfterUnDeleteEvent();
     /* log manager action */
     $this->logManagerAction();
     /* empty cache */
     $skipClearCache = $this->getProperty('skipClearCache', false);
     if ($skipClearCache == false) {
         $this->clearCache();
     }
     $this->removeLock();
     $deletedCount = $this->modx->getCount('modResource', array('deleted' => 1));
     $outputArray = $this->resource->get(array('id'));
     $outputArray['deletedCount'] = $deletedCount;
     return $this->modx->error->success('', $outputArray);
 }
开发者ID:lokamaya,项目名称:Collections,代码行数:28,代码来源:undelete.class.php

示例5: beforeSave

 public function beforeSave()
 {
     /** @var modResource $parent */
     $parent = $this->modx->getObject('modResource', $this->object->parent);
     if ($parent && $parent->class_key == 'CollectionContainer') {
         $this->object->set('show_in_tree', 0);
     } else {
         $this->object->set('show_in_tree', 1);
     }
     return parent::beforeSave();
 }
开发者ID:lokamaya,项目名称:Collections,代码行数:11,代码来源:changeparent.class.php

示例6: handleOriginalParent

 /**
  * @param \modResource $parent
  * @param \modResource $resource
  * @param \modResource $originalParent
  */
 protected function handleOriginalParent($parent, $resource, $originalParent)
 {
     if ($originalParent->class_key == 'CollectionContainer') {
         if ($parent->class_key != 'CollectionContainer') {
             $resource->set('show_in_tree', 1);
         }
     } else {
         /** @var \modResource $originalGreatParent */
         $originalGreatParent = $originalParent->Parent;
         if ($originalGreatParent && $originalGreatParent->class_key == 'CollectionContainer') {
             $resource->set('show_in_tree', 1);
         }
     }
 }
开发者ID:Burick,项目名称:Collections,代码行数:19,代码来源:collectionsonbeforedocformsave.class.php

示例7: process

 public function process()
 {
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     if ($this->isSiteStart()) {
         return $this->failure($this->modx->lexicon('resource_err_unpublish_sitestart'));
     }
     $this->resource->set('published', false);
     $this->resource->set('pub_date', false);
     $this->resource->set('unpub_date', false);
     $this->resource->set('editedby', $this->modx->user->get('id'));
     $this->resource->set('editedon', time(), 'integer');
     $this->resource->set('publishedby', false);
     $this->resource->set('publishedon', false);
     if ($this->resource->save() == false) {
         $this->resource->removeLock();
         return $this->failure($this->modx->lexicon('resource_err_unpublish'));
     }
     $this->fireAfterUnPublishEvent();
     $this->logManagerAction();
     $skipClearCache = $this->getProperty('skipClearCache', false);
     if ($skipClearCache == false) {
         $this->clearCache();
     }
     return $this->success('', $this->resource->get(array('id')));
 }
开发者ID:lokamaya,项目名称:Collections,代码行数:27,代码来源:unpublish.class.php

示例8: process

 public function process()
 {
     if (!$this->addLock()) {
         return $this->failure($this->modx->lexicon('resource_locked_by', array('id' => $this->resource->get('id'), 'user' => $this->lockedUser->get('username'))));
     }
     $duplicateAlias = $this->checkForDuplicateAlias();
     if ($duplicateAlias !== false) {
         return $this->failure($duplicateAlias);
     }
     /* publish resource */
     $this->resource->set('published', true);
     $this->resource->set('pub_date', false);
     $this->resource->set('unpub_date', false);
     $this->resource->set('editedby', $this->modx->user->get('id'));
     $this->resource->set('editedon', time(), 'integer');
     $this->resource->set('publishedby', $this->modx->user->get('id'));
     $this->resource->set('publishedon', time());
     $saved = $this->resource->save();
     $this->resource->removeLock();
     if (!$saved) {
         return $this->failure($this->modx->lexicon('resource_err_publish'));
     }
     $this->fireAfterPublish();
     $this->logManagerAction();
     $this->clearCache();
     return $this->success('', $this->resource->get(array('id', 'pub_date', 'unpub_date', 'editedby', 'editedon', 'publishedby', 'publishedon')));
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:27,代码来源:publish.class.php

示例9: 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

示例10: handleOriginalParent

 /**
  * @param \modResource $originalParent
  */
 protected function handleOriginalParent($originalParent)
 {
     $originalGreatParent = $originalParent->Parent;
     if ($originalGreatParent && $originalGreatParent->class_key == 'CollectionContainer' && $originalParent->hasChildren() == 0) {
         $originalParent->set('show_in_tree', 0);
         $originalParent->save();
     }
 }
开发者ID:Burick,项目名称:Collections,代码行数:11,代码来源:collectionsonresourcebeforesort.class.php

示例11: checkIfSiteStart

 /**
  * Quick check to make sure it's not site_start, if so, publish if not published to prevent site error
  * 
  * @return boolean
  */
 public function checkIfSiteStart()
 {
     $saved = false;
     if ($this->object->get('id') == $this->workingContext->getOption('site_start') && !$this->object->get('published')) {
         $this->object->set('published', true);
         $saved = $this->object->save();
     }
     return $saved;
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:14,代码来源:create.class.php

示例12: getResource

 /**
  * Get the Resource associated
  * 
  * @return modResource|string
  */
 public function getResource()
 {
     $resourceId = $this->getProperty('resource', 0);
     if (empty($resourceId)) {
         $this->resource = $this->modx->newObject('modResource');
         $this->resource->set('id', 0);
     } else {
         $this->resource = $this->modx->getObject('modResource', $resourceId);
         if (empty($this->resource)) {
             return $this->modx->lexicon('resource_err_nfs', array('id' => $resourceId));
         }
         /* check access */
         if (!$this->resource->checkPolicy('view')) {
             return $this->modx->lexicon('permission_denied');
         }
     }
     return $this->resource;
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:23,代码来源:getlist.class.php

示例13: process

 public function process(array $scriptProperties = array())
 {
     $placeholders = array();
     $reloadData = $this->getReloadData();
     $loaded = $this->getResource();
     if ($loaded !== true) {
         return $this->failure($loaded);
     }
     if (is_array($reloadData) && !empty($reloadData)) {
         $this->resource->fromArray($reloadData);
     }
     /* get context */
     $this->setContext();
     /* check for locked status */
     $this->checkForLocks();
     /* set template overrides */
     if (isset($scriptProperties['template'])) {
         $this->resource->set('template', $scriptProperties['template']);
     }
     $this->setParent();
     /* invoke OnDocFormRender event */
     $this->fireOnRenderEvent();
     /* check permissions */
     $this->setPermissions();
     /* register FC rules */
     $this->resourceArray = $this->resource->toArray();
     $overridden = $this->checkFormCustomizationRules($this->resource);
     $this->resourceArray = array_merge($this->resourceArray, $overridden);
     $this->resourceArray['published'] = intval($this->resourceArray['published']) == 1 ? true : false;
     $this->resourceArray['hidemenu'] = intval($this->resourceArray['hidemenu']) == 1 ? true : false;
     $this->resourceArray['isfolder'] = intval($this->resourceArray['isfolder']) == 1 ? true : false;
     $this->resourceArray['richtext'] = intval($this->resourceArray['richtext']) == 1 ? true : false;
     $this->resourceArray['searchable'] = intval($this->resourceArray['searchable']) == 1 ? true : false;
     $this->resourceArray['cacheable'] = intval($this->resourceArray['cacheable']) == 1 ? true : false;
     $this->resourceArray['deleted'] = intval($this->resourceArray['deleted']) == 1 ? true : false;
     $this->resourceArray['uri_override'] = intval($this->resourceArray['uri_override']) == 1 ? true : false;
     if (!empty($this->resourceArray['parent'])) {
         if ($this->parent->get('id') == $this->resourceArray['parent']) {
             $this->resourceArray['parent_pagetitle'] = $this->parent->get('pagetitle');
         } else {
             $overriddenParent = $this->modx->getObject('modResource', $this->resourceArray['parent']);
             if ($overriddenParent) {
                 $this->resourceArray['parent_pagetitle'] = $overriddenParent->get('pagetitle');
             }
         }
     }
     /* get TVs */
     $this->resource->set('template', $this->resourceArray['template']);
     $this->prepareResource();
     $this->loadTVs($reloadData);
     $this->getPreviewUrl();
     /* single-use token for reloading resource */
     $this->setResourceToken();
     $this->setPlaceholder('resource', $this->resource);
     return $placeholders;
 }
开发者ID:rosstimson,项目名称:revolution,代码行数:56,代码来源:update.class.php

示例14: fixParents

 /**
  * Set the parents isfolder status based upon remaining children
  *
  * @TODO Debate whether or not this should be default functionality
  * 
  * @return void
  */
 public function fixParents()
 {
     if (!empty($this->oldParent) && !empty($this->newParent)) {
         $oldParentChildrenCount = $this->modx->getCount('modResource', array('parent' => $this->oldParent->get('id')));
         if ($oldParentChildrenCount <= 0 || $oldParentChildrenCount == null) {
             $this->oldParent->set('isfolder', false);
             $this->oldParent->save();
         }
         $this->newParent->set('isfolder', true);
     }
 }
开发者ID:semencov-com,项目名称:affiliate,代码行数:18,代码来源:update.class.php

示例15: process

 /**
  * Process this page, load the resource, and present its values
  * @return void
  */
 public function process()
 {
     $data = $this->processInput($this->config['gpc']);
     /* @var modProcessorResponse $response */
     $response = $this->modx->runProcessor('resource/create', $data);
     if (!$response->isError()) {
         $tempRes = $response->getObject();
         $this->resource = $this->modx->getObject('modResource', $tempRes['id']);
         /* Make sure the createdby column is set */
         $cb = $this->resource->get('createdby');
         if (empty($cb)) {
             $this->resource->set('createdby', $this->modx->user->get('id'));
             $this->resource->save();
         }
         $this->setPlaceholders(array('message' => 'Resource created.', 'resid' => $this->resource->get('id'), 'ctx' => $this->resource->get('context_key')));
     } else {
         $error = $response->getAllErrors();
         $this->setPlaceholder('message', 'Something went wrong creating the Resource: ' . implode(', ', $error));
     }
 }
开发者ID:rossng,项目名称:HandyMan,代码行数:24,代码来源:create.save.class.php


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