예제 #1
0
 /**
  * @return array|null|string
  */
 public function beforeSet()
 {
     $this->_published = $this->getProperty('published', null);
     if ($this->_published && !$this->modx->hasPermission('ticket_publish')) {
         return $this->modx->lexicon('ticket_err_publish');
     }
     // Required fields
     $requiredFields = $this->getProperty('requiredFields', array('parent', 'pagetitle', 'content'));
     foreach ($requiredFields as $field) {
         $value = trim($this->getProperty($field));
         if (empty($value) && $this->modx->context->key != 'mgr') {
             $this->addFieldError($field, $this->modx->lexicon('field_required'));
         } else {
             $this->setProperty($field, $value);
         }
     }
     $content = $this->getProperty('content');
     $length = mb_strlen(strip_tags($content), $this->modx->getOption('modx_charset', null, 'UTF-8', true));
     $max = $this->modx->getOption('tickets.ticket_max_cut', null, 1000, true);
     if (empty($content) && $this->modx->context->key != 'mgr') {
         return $this->modx->lexicon('ticket_err_empty');
     } elseif ($this->modx->context->key != 'mgr' && !preg_match('#<cut\\b.*?>#', $content) && $length > $max) {
         return $this->modx->lexicon('ticket_err_cut', array('length' => $length, 'max_cut' => $max));
     }
     $set = parent::beforeSet();
     if ($this->hasErrors()) {
         return $this->modx->lexicon('ticket_err_form');
     }
     return $set;
 }
예제 #2
0
 /**
  * @return array|string
  */
 public function beforeSet()
 {
     foreach (array('description', 'introtext', 'content') as $key) {
         if ($field = $this->getProperty($key, false)) {
             $field = base64_decode($field);
             $this->setProperty($key, $field);
         }
     }
     foreach (array('createdon', 'publishedon', 'pub_date', 'unpub_date') as $key) {
         if ($field = $this->getProperty($key, false)) {
             $this->setProperty($key, date('Y-m-d H:i:s', strtotime($field)));
         }
     }
     return parent::beforeSet();
 }
예제 #3
0
 /** {@inheritDoc} */
 public function beforeSet()
 {
     $this->setDefaultProperties(array('show_in_tree' => $this->modx->getOption('ms2_product_show_in_tree_default', null, false), 'hidemenu' => $this->modx->getOption('hidemenu_default', null, true), 'source' => $this->modx->getOption('ms2_product_source_default', null, 1), 'template' => $this->modx->getOption('ms2_template_product_default', null, $this->modx->getOption('default_template'))));
     return parent::beforeSet();
 }
예제 #4
0
 /** {@inheritDoc} */
 public function beforeSet()
 {
     $this->setProperties(array('isfolder' => 1));
     return parent::beforeSet();
 }
예제 #5
0
 public function beforeSet()
 {
     $this->setProperty('searchable', true);
     $this->setProperty('richtext', true);
     $this->setProperty('isfolder', false);
     $this->setProperty('cacheable', true);
     $this->setProperty('clearCache', true);
     $this->setProperty('class_key', 'Article');
     return parent::beforeSet();
 }