Beispiel #1
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $p =& $this->data;
     $saveFields = array();
     $saveValues = array();
     $params = array();
     $i = 1;
     if (empty($p['visible'])) {
         $p['visible'] = 0;
     }
     foreach ($this->tableFields as $fieldName) {
         $field = null;
         if (!empty($this->template)) {
             $field = $this->template->getField($fieldName);
         }
         if (isset($p[$fieldName])) {
             $value = $p[$fieldName];
             $value = is_scalar($value) || is_null($value) ? $value : Util\jsonEncode($value);
             $saveFields[] = $fieldName;
             $saveValues[] = $value;
             $params[] = $i;
             $i++;
         } elseif (!empty($field)) {
             $value = @$this->getFieldValue($fieldName, 0)['value'];
             // this if should be removed after complete migration to language abreviation titles
             if (empty($value) && in_array($fieldName, array('l1', 'l2', 'l3', 'l4'))) {
                 $lang = @\CB\Config::get('languages')[$fieldName[1] - 1];
                 if (!empty($lang)) {
                     $value = @$this->getFieldValue($lang, 0)['value'];
                 }
             }
             $value = is_scalar($value) || is_null($value) ? $value : Util\jsonEncode($value);
             $saveFields[] = $fieldName;
             $saveValues[] = $value;
             $params[] = $i;
             $i++;
         } else {
             // this if should be removed after complete migration to language abreviation titles
             if (in_array($fieldName, array('l1', 'l2', 'l3', 'l4'))) {
                 $lang = @\CB\Config::get('languages')[$fieldName[1] - 1];
                 if (!empty($lang)) {
                     $value = @$this->getFieldValue($lang, 0)['value'];
                     $saveFields[] = $fieldName;
                     $saveValues[] = $value;
                     $params[] = "{$i}";
                     $i++;
                 }
             }
         }
     }
     if (!empty($saveFields)) {
         $params = '$' . implode(',$', $params);
         DB\dbQuery('INSERT INTO templates
             (`' . implode('`,`', $saveFields) . '`)
             VALUES(' . $params . ')', $saveValues) or die(DB\dbQueryError());
     }
     $this->saveFields();
 }
Beispiel #2
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $p =& $this->data;
     $data = $this->collectCustomModelData();
     $data['template_id'] = $this->detectParentTemplate();
     DM\TemplatesStructure::create($data);
 }
Beispiel #3
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $d =& $this->data;
     $dd =& $d['data'];
     $p = array('id' => $this->id, 'pid' => empty($d['pid']) ? null : $this->getDMPid($d['pid']), 'param' => $dd['_title'], 'value' => empty($dd['value']) ? '' : $dd['value']);
     if (isset($dd['order'])) {
         $p['order'] = $dd['order'];
     }
     DM\Config::create($p);
 }
Beispiel #4
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $data = $this->collectCustomModelData();
     $data['template_id'] = $this->detectParentTemplate();
     DM\TemplatesStructure::create($data);
     if ($this->isSolrConfigUpdated()) {
         $tpl = \CB\Objects::getCachedObject($data['template_id']);
         $tpl->setSysDataProperty('solrConfigUpdated', true);
     }
 }
Beispiel #5
0
 /**
  * function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     $p =& $this->data;
     $p['sys_data'] = Util\toJSONArray(@$p['sys_data']);
     $sd =& $p['sys_data'];
     //add assigned users as followers by default
     if (empty($sd['fu'])) {
         $sd['fu'] = Util\toNumericArray(@$this->getFieldValue('assigned', 0)['value']);
     }
     parent::createCustomData();
 }
Beispiel #6
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $p =& $this->data;
     if (empty($p['visible'])) {
         $p['visible'] = 0;
     }
     $data = $this->collectCustomModelData();
     if (!empty($data)) {
         DM\Templates::create($data);
     }
 }
Beispiel #7
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $res = DB\dbQuery('INSERT INTO files
             (id
             ,content_id
             ,`date`
             ,`name`
             ,`cid`
             )
         VALUES (
             $1
             ,$2
             ,$3
             ,$4
             ,$5
         )', array($this->id, @$this->data['content_id'], @$this->data['date'], @$this->data['name'], @$this->data['cid'])) or die(DB\dbQueryError());
 }
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     $p =& $this->data;
     $saveFields = array('template_id');
     $saveValues = array($this->detectParentTemplate());
     $params = array('1');
     $i = 2;
     $dataParams = $this->getParamsFromData();
     foreach ($dataParams as $k => $v) {
         $saveFields[] = $k;
         $saveValues[] = $v;
         $params[] = $i;
         $i++;
     }
     if (!empty($saveFields)) {
         $params = '$' . implode(',$', $params);
         $sql = 'INSERT INTO templates_structure
             (`' . implode('`,`', $saveFields) . '`)
             VALUES(' . $params . ')';
         DB\dbQuery($sql, $saveValues) or die(DB\dbQueryError());
     }
 }
Beispiel #9
0
 /**
  * internal function used by create method for creating custom data
  * @return void
  */
 protected function createCustomData()
 {
     parent::createCustomData();
     DM\Files::create(array('id' => $this->id, 'content_id' => @$this->data['content_id'], 'date' => @$this->data['date'], 'name' => @$this->data['name'], 'cid' => @$this->data['cid']));
 }