Exemple #1
0
 public function update($fieldsCols = null)
 {
     return parent::update(['beforeUpdate' => function ($fields) {
         if ($fields['description'] == '') {
             $fields['description'] = GsssHtml::getMiniText($fields['content']);
         }
         return $fields;
     }]);
 }
Exemple #2
0
 public function update($fieldsCols = null)
 {
     return parent::update(['beforeUpdate' => function ($fields, \app\models\Form\Blog $model) {
         if ($fields['description'] == '') {
             $fields['description'] = GsssHtml::getMiniText($fields['content']);
         }
         if ($model->is_add_image) {
             $fields['content'] = Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($model->image), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $fields['header']])) . $fields['content'];
         }
         return $fields;
     }]);
 }
Exemple #3
0
 public function update($fieldsCols = null)
 {
     $fields = parent::update(['beforeUpdate' => function ($fields, \app\models\Form\Article $model) {
         if ($fields['description'] == '') {
             $fields['description'] = GsssHtml::getMiniText($fields['content']);
         }
     }]);
     $item = \app\models\Article::find($this->id);
     if ($this->is_add_image) {
         $content = Html::tag('p', Html::img(\cs\Widget\FileUpload2\FileUpload::getOriginal($item->getImage()), ['class' => 'thumbnail', 'style' => 'width:100%;', 'alt' => $item->getField('header')])) . $item->getField('content');
         $item->update(['content' => $content]);
     }
 }
Exemple #4
0
 public function update($fieldsCols = null)
 {
     parent::update();
     $item = \app\models\Picture::find($this->id);
     $fields = [];
     if ($item->getField('description') == '') {
         $fields['description'] = GsssHtml::getMiniText($item->getField('content'));
     }
     if (count($fields) > 0) {
         $item->update($fields);
     }
     return true;
 }
Exemple #5
0
 /**
  * @param int $id идентификатор объединения gs_unions.id
  * @return array|bool
  */
 public function update2($id)
 {
     if ($this->id) {
         return parent::update();
     } else {
         $this->union_id = $id;
         return parent::insert(['beforeInsert' => function ($fields, \app\models\Form\Shop $model) {
             $fields['union_id'] = $model->union_id;
             (new Query())->createCommand()->insert('gs_unions_shop_tree', ['union_id' => $model->union_id, 'name' => 'Root'])->execute();
             return $fields;
         }]);
     }
 }
Exemple #6
0
 public function update($fieldsCols = null)
 {
     return parent::update(['beforeUpdate' => function ($fields) {
         if (Str::pos('<', $fields['content']) === false) {
             $rows = explode("\r", $fields['content']);
             $rows2 = [];
             foreach ($rows as $row) {
                 if (trim($row) != '') {
                     $rows2[] = Html::tag('p', trim($row));
                 }
             }
             $fields['content'] = join("\r\r", $rows2);
         }
         return $fields;
     }]);
 }
 public function update2($id)
 {
     $item = parent::update();
     $item['id'] = $id;
     $class = new \app\models\SubscribeHistory($item);
     $content = $class->getField('content');
     require_once Yii::getAlias('@csRoot/services/simplehtmldom_1_5/simple_html_dom.php');
     $content = str_get_html($content);
     foreach ($content->find('img') as $element) {
         $src = $element->attr['src'];
         if (StringHelper::startsWith($src, 'http') == false) {
             $element->attr['src'] = Url::to($src, true);
         }
     }
     $content = $content->root->outertext();
     $class->setContent($content);
     return $item;
 }
Exemple #8
0
 /**
  * Обновляет запись в таблицу
  *
  * @return boolean результат операции
  */
 public function update($fieldsCols = NULL)
 {
     if ($this->validate()) {
         // cs_users
         if (!parent::update($fieldsCols)) {
             return false;
         }
         $query = new Query();
         $command = $query->createCommand();
         // cs_users_fields
         $fields = [];
         foreach (self::$fields2 as $field) {
             $this->processUpdateField($fields, $field);
         }
         if ((new Query())->select('*')->from(self::TABLE_FIELDS)->where(['user_id' => $this->id])->count() == 0) {
             $fields['user_id'] = $this->id;
             $command->insert(self::TABLE_FIELDS, $fields)->execute();
         } else {
             $command->update(self::TABLE_FIELDS, $fields, ['user_id' => $this->id])->execute();
         }
         return true;
     }
     return false;
 }
Exemple #9
0
 public function update($fieldsCols = null)
 {
     return parent::update(['beforeUpdate' => function ($fields) {
         return $fields;
     }]);
 }
Exemple #10
0
 public function update($fields = null)
 {
     $this->clearCache();
     return parent::update($fields);
 }