public function beforeValidate() { if (!$this->code) { $this->code = yupe\helpers\YText::translit($this->title); } return parent::beforeValidate(); }
public function beforeValidate() { if (!$this->slug) { $this->slug = yupe\helpers\YText::translit($this->name); } return parent::beforeValidate(); }
public function beforeValidate() { if (!$this->alias) { $this->alias = yupe\helpers\YText::translit($this->name); } if (!$this->lang) { $this->lang = Yii::app()->language; } return parent::beforeValidate(); }
public function beforeValidate() { if (!$this->slug) { $this->slug = yupe\helpers\YText::translit($this->name); } foreach ((array) $this->_eavAttributes as $name => $value) { $model = Attribute::model()->getAttributeByName($name); if (!$model->isType(Attribute::TYPE_CHECKBOX) && $model->isRequired() && !$value) { $this->addError('eav.' . $name, Yii::t("StoreModule.store", "{title} attribute is required", ['title' => $model->title])); } } return parent::beforeValidate(); }
public function beforeValidate() { if (!$this->slug) { $this->slug = yupe\helpers\YText::translit($this->title); } if (!$this->lang) { $this->lang = Yii::app()->getLanguage(); } return parent::beforeValidate(); }
public function actionPosts() { $data = Yii::app()->ls->createCommand('SELECT * FROM prefix_topic pt JOIN prefix_topic_content ptc ON pt.topic_id = ptc.topic_id ')->queryAll(); $transaction = Yii::app()->db->beginTransaction(); try { foreach ($data as $post) { echo "Import post '{$post['topic_title']}'\n"; $status = $post['topic_publish'] ? 1 : 0; $extra = unserialize($post['topic_extra']); $url = isset($extra['url']) ? $extra['url'] : ''; $tags = explode(',', $post['topic_tags']); Yii::app()->db->createCommand(' INSERT INTO {{blog_post}} (id, blog_id, title, slug, content, create_user_id, update_user_id, access_type, status, create_date, update_date, publish_date, quote, link) VALUES (:id, :blog_id, :title, :slug, :content, :create_user_id, :update_user_id, :access_type, :status, :create_date, :update_date, :publish_date, :quote, :link) ')->bindValue(':id', $post['topic_id'])->bindValue(':blog_id', $post['blog_id'])->bindValue(':title', $post['topic_title'])->bindValue(':slug', yupe\helpers\YText::translit($post['topic_title']))->bindValue(':content', $post['topic_text'])->bindValue(':create_user_id', $post['user_id'])->bindValue(':update_user_id', $post['user_id'])->bindValue(':access_type', Post::ACCESS_PUBLIC)->bindValue(':status', $status)->bindValue(':create_date', strtotime($post['topic_date_add']))->bindValue(':update_date', strtotime($post['topic_date_edit']))->bindValue(':publish_date', strtotime($post['topic_date_add']))->bindValue(':quote', $post['topic_text_short'])->bindValue(':link', $url)->execute(); if (!empty($tags)) { foreach ($tags as $tag) { $tdata = Tag::model()->find('name = :name', array(':name' => $tag)); if (null === $tdata) { $tdata = new Tag(); $tdata->name = strip_tags($tag); $tdata->save(); } Yii::app()->db->createCommand(' INSERT INTO {{blog_post_to_tag}} (post_id, tag_id) VALUES (:post_id, :tag_id) ')->bindValue(':post_id', $post['topic_id'])->bindValue(':tag_id', $tdata->id)->execute(); } } } $transaction->commit(); } catch (Exception $e) { CVarDumper::dump($e); $transaction->rollback(); die; } }
public function beforeValidate() { if (!$this->slug) { $this->slug = yupe\helpers\YText::translit($this->name); $sl = \Yii::app()->db->createCommand()->select('slug')->from('site_store_product')->where('slug = :slug', [':slug' => $this->slug])->queryScalar(); if ($sl !== FALSE) { $this->slug = time() . '_' . $this->slug; } } foreach ((array) $this->_eavAttributes as $name => $value) { $model = Attribute::model()->getAttributeByName($name); if (!$model->isType(Attribute::TYPE_CHECKBOX) && $model->isRequired() && !$value) { $this->addError('eav.' . $name, Yii::t("StoreModule.default", "Необходимо заполнить поле «{title}».", ['{title}' => $model->title])); } } return parent::beforeValidate(); }
public function beforeValidate() { $this->change_user_id = Yii::app()->user->getId(); if ($this->isNewRecord) { $this->user_id = $this->change_user_id; } if (!$this->slug) { $this->slug = yupe\helpers\YText::translit($this->name); } return parent::beforeValidate(); }