Beispiel #1
0
 /**
  * @return array|string
  */
 public function cleanup()
 {
     if (!empty($this->_processor)) {
         $this->_processor->cleanup();
         $id = $this->_processor->object->get('id');
     } else {
         parent::cleanup();
         $id = $this->object->get('id');
     }
     $get = (require 'get.class.php');
     /** @var mxResourceGetProcessor $processor */
     $processor = new $get($this->modx, array('id' => $id));
     $processor->initialize();
     return $processor->process();
 }
 public static function getInstance(modX &$modx, $className, $properties = array())
 {
     if (isset($properties['data'])) {
         $data = (array) $modx->fromJSON($properties['data']);
         $properties = array_merge($properties, $data);
         unset($properties['data'], $data);
     }
     return parent::getInstance($modx, $className, $properties);
 }
 public function beforeSave()
 {
     $this->defaultText = $this->modx->lexicon('modxtalks.default');
     $properties = $this->getProperties();
     if (isset($properties['modxtalks'])) {
         $settings = $this->cleanArray($properties['modxtalks']);
         $this->object->setProperties($settings, 'modxtalks', false);
     }
     return parent::beforeSave();
 }
Beispiel #4
0
 public function beforeSet()
 {
     # $this->setDefaultProperties(array(
     #     "context_key"   => $this->object->context_key,
     #     "pagetitle"   => $this->object->pagetitle,
     #     "alias"   => $this->object->alias,
     # ));
     $this->setDefaultProperties($this->object->toArray());
     return parent::beforeSet();
 }
 public function afterSave()
 {
     $collectionsTemplate = (int) $this->getProperty('collections_template');
     $config = $this->modx->getObject('CollectionSetting', array('collection' => $this->object->id));
     if (!$config) {
         $config = $this->modx->newObject('CollectionSetting');
         $config->set('collection', $this->object->id);
     }
     $config->set('template', $collectionsTemplate);
     $config->save();
     return parent::afterSave();
 }
 public function initialize()
 {
     $data = $this->getProperty('data');
     if (empty($data)) {
         return $this->modx->lexicon('invalid_data');
     }
     $data = $this->modx->fromJSON($data);
     if (empty($data)) {
         return $this->modx->lexicon('invalid_data');
     }
     $this->setProperties($data);
     $this->unsetProperty('data');
     $this->setProperty('clearCache', true);
     return parent::initialize();
 }
 /**
 * Do any processing before the save of the Resource but after fields are set.
 * @return boolean
 */
 public function beforeSave()
 {
     $beforeSave = parent::beforeSave();
     // Get all translated data as arrays
     $translations = $this->getTranslatedFields();
     $resId = $this->getProperty('id');
     foreach ($translations as $lang => $fields) {
         if ($row = $this->modx->getObject('Translation', array('articleID' => $resId, 'language' => $lang))) {
             $row->set('pagetitle', $fields['pagetitle']);
             $row->set('longtitle', $fields['longtitle']);
             $row->set('menutitle', $fields['menutitle']);
             $row->set('introtext', $fields['introtext']);
             $row->set('description', $fields['description']);
             $row->set('content', $fields['content']);
             $row->save();
         }
     }
     return $beforeSave;
 }
Beispiel #8
0
 public function beforeSave()
 {
     $afterSave = parent::beforeSave();
     // Make sure this is not saved anywhere it shouldn't be
     /*
             $parent = $this->modx->getObject('modResource',$this->object->get('parent'));
             if ($parent) {
                 $this->modx->log(1, print_r($parent->toArray(),true));
             }
             else {
                 $this->modx->log(1, 'No Parent!');
             }
     */
 }
Beispiel #9
0
 /** {inheritDoc} */
 public function clearCache()
 {
     parent::clearCache();
     $this->object->clearCache();
 }
 public function afterSave()
 {
     $this->setProperty('clearCache', true);
     return parent::afterSave();
 }
Beispiel #11
0
 public function afterSave()
 {
     $afterSave = parent::afterSave();
     if ($this->isPublishing) {
         $this->object->notifyUpdateServices();
         $this->object->sendNotifications();
     }
     $this->clearContainerCache();
     return $afterSave;
 }
 /**
  * Override modResourceUpdateProcessor::afterSave to provide custom functionality
  * {@inheritDoc}
  * @return boolean
  */
 public function afterSave()
 {
     $this->addContainerId();
     $this->removeFromArchivistIds();
     $this->setProperty('clearCache', true);
     $this->object->set('isfolder', true);
     return parent::afterSave();
 }
Beispiel #13
0
 /** {inheritDoc} */
 public function beforeSet()
 {
     $this->setProperties(array('isfolder' => 1));
     return parent::beforeSet();
 }
Beispiel #14
0
 /**
  * @return bool|string
  */
 public function beforeSet()
 {
     $this->setProperties(array('isfolder' => 1, 'hide_children_in_tree' => 0));
     $this->handleProperties();
     return parent::beforeSet();
 }
Beispiel #15
0
 /**
 * Override modResourceUpdateProcessor::beforeSave to provide custom functionality, saving settings for the container
 * to a custom field in the DB.
 *
 * The Post data comes thru flattened (boo)
 *
        [specs_4] => on
        [specs_12] => on
        [taxonomies_3] => on
        [taxonomies_4] => on
        [variations_1] => Option Only
        [variations_2] => Variant
        [variations_3]
 * On the flip side, it should be available in JS via this path: MODx.activePage.config.record.properties.moxycart
 *
 * {@inheritDoc}
 * @return boolean
 */
 public function beforeSave()
 {
     $raw = $this->getProperties();
     // <-- this will have raw values
     $properties = $this->object->getProperties('moxycart');
     //<-- we need to update these values
     $this->object->set('class_key', 'Store');
     //$this->modx->log(1,'beforeSave raw values: '.print_r($raw,true));
     //$this->modx->log(1,'existing values: '.print_r($properties,true));
     //$this->modx->log(1,'beforeSave raw POST values: '.print_r($_POST,true));
     $properties['product_type'] = $this->modx->getOption('product_type', $raw);
     $properties['product_template'] = $this->modx->getOption('product_template', $raw);
     $properties['track_inventory'] = $this->modx->getOption('track_inventory', $raw) == 'Yes' ? 1 : 0;
     $properties['sort_order'] = $this->modx->getOption('sort_order', $raw);
     $properties['qty_alert'] = $this->modx->getOption('qty_alert', $raw);
     // Fresh start...
     $properties['specs'] = array();
     $properties['taxonomies'] = array();
     $properties['variations'] = array();
     foreach ($raw as $k => $v) {
         $len = strlen($k);
         if ($this->starts_with($k, 'specs')) {
             $properties['specs'][substr($k, 6 - $len)] = true;
         }
         if ($this->starts_with($k, 'taxonomies')) {
             $properties['taxonomies'][substr($k, 11 - $len)] = true;
         }
         if ($this->starts_with($k, 'variations')) {
             $properties['variations'][substr($k, 11 - $len)] = $v;
         }
     }
     $this->object->setProperties($properties, 'moxycart');
     return parent::beforeSave();
 }
Beispiel #16
0
 /**
  * @return array
  */
 public function cleanup()
 {
     $this->processFiles();
     return parent::cleanup();
 }