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


PHP modResource::save方法代码示例

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


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

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

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

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

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

 public function process()
 {
     if (!$this->validate()) {
         return $this->failure();
     }
     $this->resource->fromArray($this->getProperties());
     if ($this->resource->save() === false) {
         return $this->failure($this->modx->lexicon('resource_err_save'));
     }
     return $this->success();
 }
开发者ID:e-gob,项目名称:apps.gob.cl,代码行数:11,代码来源:updatefromgrid.class.php

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

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

示例8: save

 public function save($cacheFlag = null)
 {
     $isNew = $this->isNew();
     $saved = parent::save($cacheFlag);
     if ($saved && !$isNew && !empty($this->oldAlias)) {
         $newAlias = $this->get('alias');
         $saved = $this->updateChildrenURIs($newAlias, $this->oldAlias);
     }
     return $saved;
 }
开发者ID:raadhuis,项目名称:modx-basic,代码行数:10,代码来源:articlescontainer.class.php

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

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

示例11: 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);
             if ($originalParent->hasChildren() == 0) {
                 $originalParent->set('show_in_tree', 0);
                 $originalParent->save();
             }
         }
     }
 }
开发者ID:lokamaya,项目名称:Collections,代码行数:23,代码来源:collectionsonbeforedocformsave.class.php

示例12: fixParents

 /**
  * Set the parents isfolder status based upon remaining children
  *
  * @return void
  */
 public function fixParents()
 {
     $autoIsFolder = $this->modx->getOption('auto_isfolder', null, true);
     if (!$autoIsFolder) {
         return;
     }
     if (!empty($this->oldParent)) {
         $oldParentChildrenCount = $this->modx->getCount('modResource', array('parent' => $this->oldParent->get('id')));
         if ($oldParentChildrenCount <= 0 || $oldParentChildrenCount == null) {
             $this->oldParent->set('isfolder', false);
             $this->oldParent->save();
         }
     }
     if (!empty($this->newParent)) {
         $this->newParent->set('isfolder', true);
         $this->newParent->save();
     }
 }
开发者ID:ChrstnMgcn,项目名称:revolution,代码行数:23,代码来源:update.class.php

示例13: saveMarkdown

 private function saveMarkdown()
 {
     $resourceArray = $this->resource->toArray();
     $mode = $this->sp['mode'];
     $deleteUnused = (int) $this->md->getOption('upload.delete_unused', null, 1);
     $underResource = (int) $this->md->getOption('upload.under_resource', null, 1);
     if ($mode == \modSystemEvent::MODE_UPD) {
         if ($deleteUnused && $underResource) {
             $this->uploadedFiles();
         }
     }
     foreach ($resourceArray as $field => $value) {
         if (!strpos($field, '_markdown')) {
             continue;
         }
         $fieldName = str_replace('_markdown', '', $field);
         $markdown = $this->modx->fromJSON($this->resource->getProperty('markdown', 'markdowneditor', '[]'));
         if ($mode == \modSystemEvent::MODE_NEW) {
             if ($underResource) {
                 $this->moveFilesUnderCorrectResource($value, $fieldName);
             }
         }
         if ($mode == \modSystemEvent::MODE_UPD) {
             if ($deleteUnused && $underResource) {
                 $this->unsetUnusedFiles($value);
             }
         }
         $markdown[$fieldName] = $value;
         $this->resource->setProperty('markdown', $this->modx->toJSON($markdown), 'markdowneditor');
         $this->resource->save();
         $this->resource->{$field} = '';
     }
     if ($mode == \modSystemEvent::MODE_UPD) {
         if ($deleteUnused && $underResource) {
             $this->deleteUnusedFiles();
         }
     }
 }
开发者ID:ashliewebb,项目名称:ashliewebb,代码行数:38,代码来源:OnDocFormSave.php

示例14: save

 /**
  * We override/enhance the parent save() operation so we can cache the 
  * hierarchical data in there as the terms are manipulated.
  *
  * properties is rendered as JSON -- see notes @ top of class for structure.
  *
  * Updating a term triggers a ripple UP the tree.
  * Moving a term up/down in the hierarchy forces an unsetting in prev_parent
  */
 public function save($cacheFlag = null)
 {
     $properties = $this->get('properties');
     $fingerprint = $this->xpdo->getOption('fingerprint', $properties);
     // the old one
     $prev_parent = $this->xpdo->getOption('prev_parent', $properties);
     $children = $this->xpdo->getOption('children', $properties, array());
     $properties['fingerprint'] = $this->_calc_fingerprint();
     // the new one
     $properties['prev_parent'] = $this->get('parent');
     $this->set('properties', $properties);
     $rt = parent::save($cacheFlag);
     // <-- the normal save
     // old == new ?
     if ($fingerprint == $properties['fingerprint']) {
         $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, $this->get('id') . ': Fingerprint unchanged. No action taken.', '', __CLASS__, basename(__FILE__), __LINE__);
         $rt = parent::save($cacheFlag);
         return $rt;
         // nothing to do
     }
     $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, 'New Fingerprint detected.', $this->get('id'), __CLASS__, basename(__FILE__), __LINE__);
     // moved?  Run unset on prev_parent to remove this term as a child
     if ($prev_parent != $this->get('parent')) {
         $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, $this->get('id') . ': Move in the hierarchy detected from ' . $prev_parent . ' to ' . $this->get('parent'), '', __CLASS__, basename(__FILE__), __LINE__);
         $PrevParent = $this->xpdo->getObject('modResource', $prev_parent);
         if ($PrevParent) {
             $prev_parent_props = $PrevParent->get('properties');
             unset($prev_parent_props['children'][$this->get('id')]);
             unset($prev_parent_props['children_ids'][$this->get('id')]);
             $PrevParent->set('properties', $prev_parent_props);
             if (!$PrevParent->save()) {
                 // <-- this may ripple up
                 $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, $this->get('id') . ': Error saving previous parent ' . $prev_parent, '', __CLASS__, basename(__FILE__), __LINE__);
             }
         }
     }
     $Parent = $this->xpdo->getObject('modResource', $this->get('parent'));
     if (!$Parent) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, 'Parent not found!', $this->get('id'), __CLASS__, basename(__FILE__), __LINE__);
         return $rt;
         // nothing we can do
     }
     $this->xpdo->log(xPDO::LOG_LEVEL_DEBUG, $this->get('id') . ': Updating the parent (' . $this->get('parent') . ')', '', __CLASS__, basename(__FILE__), __LINE__);
     $parent_props = $Parent->get('properties');
     // Children may be out of date by this point
     $parent_props['children'][$this->get('id')] = array('alias' => $this->get('alias'), 'pagetitle' => $this->get('pagetitle'), 'published' => $this->get('published'), 'menuindex' => $this->get('menuindex'), 'children' => $children);
     $parent_props['children_ids'][$this->get('id')] = true;
     $Parent->set('properties', $parent_props);
     if (!$Parent->save()) {
         // <-- this may ripple up
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, $this->get('id') . ': Error saving parent ' . $this->get('parent'), '', __CLASS__, basename(__FILE__), __LINE__);
     }
     return $rt;
 }
开发者ID:carnevlu,项目名称:repoman,代码行数:63,代码来源:term.class.php

示例15: save

 /**
  * @param null $cacheFlag
  *
  * @return bool
  */
 public function save($cacheFlag = null)
 {
     $this->set('isfolder', 1);
     $update_actions = false;
     if ($properties = parent::get('properties')) {
         if (!empty($properties['ratings'])) {
             $ratings = implode(array_values($properties['ratings']));
             $update_actions = !empty($this->_oldRatings) && $this->_oldRatings != $ratings;
         }
     }
     $new = $this->isNew();
     $saved = parent::save($cacheFlag);
     if ($saved && !$new) {
         $this->updateChildrenURIs();
     }
     if ($saved && $update_actions) {
         $this->updateAuthorsActions();
     }
     return $saved;
 }
开发者ID:soulcreate,项目名称:Tickets,代码行数:25,代码来源:ticketssection.class.php


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