示例#1
0
 /**
  * Overrides xPDOObject::save to cache the actionMap.
  *
  * {@inheritdoc}
  */
 public function remove(array $ancestors = array())
 {
     $removed = parent::remove($ancestors);
     if ($removed && empty($this->xpdo->config[xPDO::OPT_SETUP])) {
         $this->rebuildCache();
     }
     return $removed;
 }
 /**
  * Overrides xPDOObject::remove to fire modX-specific events
  *
  * {@inheritDoc}
  */
 public function remove(array $ancestors = array())
 {
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnBeforeResourceGroupRemove', array('resourceGroup' => &$this, 'ancestors' => $ancestors));
     }
     $removed = parent::remove($ancestors);
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnResourceGroupRemove', array('resourceGroup' => &$this, 'ancestors' => $ancestors));
     }
     return $removed;
 }
 public function save($cacheFlag = null)
 {
     $this->tag = trim($this->tag);
     if (!$this->tag) {
         $this->xpdo->log(xPDO::LOG_LEVEL_ERROR, "[- " . __CLASS__ . " -]. Column tag can not be empty");
         return false;
     }
     if (!$this->Topic) {
         $this->xpdo->log(xPDO::LOG_LEVEL_WARN, "[- " . __CLASS__ . " -]. Topic required");
         return false;
     }
     return parent::save($cacheFlag);
 }
 /**
  * Overrides xPDOObject::remove to reset all Element categories back to 0
  * and fire modX-specific events.
  *
  * {@inheritDoc}
  */
 public function remove(array $ancestors = array())
 {
     if ($this->xpdo instanceof modX) {
         $this->xpdo->invokeEvent('OnCategoryBeforeRemove', array('category' => &$this, 'ancestors' => $ancestors));
     }
     $removed = parent::remove($ancestors);
     if ($removed && $this->xpdo instanceof modX) {
         $elementClasses = array('modChunk', 'modPlugin', 'modSnippet', 'modTemplate', 'modTemplateVar');
         foreach ($elementClasses as $classKey) {
             $elements = $this->xpdo->getCollection($classKey, array('category' => $this->get('id')));
             foreach ($elements as $element) {
                 $element->set('category', 0);
                 $element->save();
             }
         }
         $this->xpdo->invokeEvent('OnCategoryRemove', array('category' => &$this, 'ancestors' => $ancestors));
     }
     return $removed;
 }
 /**
  * Overridden to handle changes to content managed in an external file.
  *
  * {@inheritdoc}
  */
 public function save($cacheFlag = null)
 {
     if (!$this->getOption(xPDO::OPT_SETUP)) {
         if ($this->staticSourceChanged()) {
             $staticContent = $this->getFileContent();
             if ($staticContent !== $this->get('content')) {
                 if ($this->isStaticSourceMutable() && $staticContent === '') {
                     $this->setDirty('content');
                 } else {
                     $this->setContent($staticContent);
                 }
             }
             unset($staticContent);
         }
         $staticContentChanged = $this->staticContentChanged();
         if ($staticContentChanged && !$this->isStaticSourceMutable()) {
             $this->setContent($this->getFileContent());
             $staticContentChanged = false;
         }
     }
     $saved = parent::save($cacheFlag);
     if (!$this->getOption(xPDO::OPT_SETUP)) {
         if ($saved && $staticContentChanged) {
             $saved = $this->setFileContent($this->get('content'));
         }
     }
     return $saved;
 }
示例#6
0
 /**
  * Persist new or changed modResource instances to the database container.
  *
  * {@inheritdoc}
  *
  * If the modResource is new, the createdon and createdby fields will be set
  * using the current time and user authenticated in the context.
  *
  * If uri is empty or uri_overridden is not set and something has been changed which
  * might affect the Resource's uri, it is (re-)calculated using getAliasPath(). This
  * can be forced recursively by setting refreshURIs to true before calling save().
  */
 public function save($cacheFlag= null) {
     if ($this->isNew()) {
         if (!$this->get('createdon')) $this->set('createdon', time());
         if (!$this->get('createdby') && $this->xpdo instanceof modX) $this->set('createdby', $this->xpdo->getLoginUserID());
     }
     $refreshChildURIs = false;
     if ($this->xpdo instanceof modX && $this->xpdo->getOption('friendly_urls')) {
         $refreshChildURIs = ($this->get('refreshURIs') || $this->isDirty('alias') || $this->isDirty('parent') || $this->isDirty('context_key'));
         if ($this->get('uri') == '' || (!$this->get('uri_override') && ($this->isDirty('uri_override') || $this->isDirty('content_type') || $this->isDirty('isfolder') || $refreshChildURIs))) {
             $this->set('uri', $this->getAliasPath($this->get('alias')));
         }
     }
     $rt= parent :: save($cacheFlag);
     if ($rt && $refreshChildURIs) {
         $this->xpdo->call('modResource', 'refreshURIs', array(
             &$this->xpdo,
             $this->get('id'),
         ));
     }
     return $rt;
 }
 /**
  * Override xPDOObject::save to clear the sources cache on save
  *
  * @param boolean $cacheFlag
  * @return boolean
  */
 public function save($cacheFlag = null)
 {
     $saved = parent::save($cacheFlag);
     if ($saved) {
         $this->clearCache();
     }
     return $saved;
 }
示例#8
0
 /**
  * Persist new or changed modResource instances to the database container.
  *
  * {@inheritdoc}
  *
  * If the modResource is new, the createdon and createdby fields will be set
  * using the current time and user authenticated in the context.
  */
 public function save($cacheFlag = null)
 {
     if ($this->_new) {
         if (!$this->get('createdon')) {
             $this->set('createdon', time());
         }
         if (!$this->get('createdby') && $this->xpdo instanceof modX) {
             $this->set('createdby', $this->xpdo->getLoginUserID());
         }
     }
     $rt = parent::save($cacheFlag);
     return $rt;
 }
示例#9
0
 /**
  * Overrides xPDOObject::remove to remove all Property Sets that are related
  * to this object.
  *
  * {@inheritdoc}
  */
 public function remove(array $ancestors = array())
 {
     $this->xpdo->removeCollection('modElementPropertySet', array('element' => $this->get('id'), 'element_class' => $this->_class));
     $result = parent::remove($ancestors);
     return $result;
 }