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 getFlag() { return yupe\helpers\YText::langToflag($this->lang); }
public function getQuote($limit = 500) { return $this->quote ?: yupe\helpers\YText::characterLimiter($this->content, (int) $limit); }
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(); }
<div class="panel panel-default"> <div class="panel-heading"> <h4 class="panel-title"> <a data-toggle="collapse" data-parent="#accordion" href="#collapse-<?php echo $data->id; ?> "> <?php echo yupe\helpers\YText::characterLimiter(strip_tags($data->theme), 250); ?> </a> </h4> </div> <div id="collapse-<?php echo $data->id; ?> " class="panel-collapse collapse"> <div class="panel-body"> <?php echo strip_tags($data->answer); ?> <span class="label label-info"> <?php echo CHtml::link(Yii::t('FeedbackModule.feedback', 'More...'), ['/feedback/contact/faqView', 'id' => $data->id]); ?> </span> </div> </div> </div>
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(); }
<ul class="list-unstyled"> <?php $cnt = count($models); $i = 0; ?> <?php foreach ($models as $model) { ?> <li> <?php echo CHtml::link(yupe\helpers\YText::characterLimiter($model->text, 50), ['/feedback/contact/faqView/', 'id' => $model->id]); ?> </li> <?php $i++; if ($i != $cnt) { echo '<hr>'; } ?> <?php } ?> </ul>