Пример #1
0
 public function scenarios()
 {
     $parent = parent::scenarios();
     $parent['login'] = ['username', 'password'];
     $parent['register'] = ['username', 'password', 'email'];
     return $parent;
 }
Пример #2
0
 public function init()
 {
     parent::init();
     if (LsYii::getActionId() != 'index') {
         $this->sort = 0;
         $this->parent_id = 0;
         $this->status = \source\libs\Constants::Dict_Status_Enable;
     }
 }
Пример #3
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         if ($this->hasAttribute('sort_num')) {
             if ($this->sort_num == null || $this->sort_num == '') {
                 $this->sort_num = 0;
             }
         }
         if ($this->hasAttribute('created_at')) {
             if ($this->created_at == null || $this->created_at == '') {
                 $this->created_at = time();
             }
         }
         if ($this->hasAttribute('updated_at')) {
             $this->updated_at = time();
         }
         return true;
     }
     return false;
 }
Пример #4
0
 public function init()
 {
     $this->target = Constants::Target_Self;
     $this->status = Constants::Status_Enable;
     parent::init();
 }
Пример #5
0
 public function beforeSave($insert)
 {
     $uploadedFile = Common::uploadFile('Content[thumb]');
     if ($uploadedFile != null) {
         $this->thumb = $uploadedFile['url'] . $uploadedFile['new_name'];
     }
     return parent::beforeSave($insert);
 }
Пример #6
0
 /**
  * 获取分类切换列表
  * @param type $defaultId
  * @return type
  */
 public static function getItems($defaultId, $url)
 {
     $model = self::getOneMenu();
     return parent::getItemsInternal($model, $defaultId, $url);
 }
Пример #7
0
 public function afterSave($insert, $changedAttributes)
 {
     parent::afterSave($insert, $changedAttributes);
     Fragment::clearCachedData($this->fragment_id);
 }
Пример #8
0
 public function beforeSave($insert)
 {
     if ($insert) {
         //$this->generateAuthKey();
         $this->generatePasswordHash();
         //$this->generatePasswordResetToken();
     }
     if (!$insert && !empty($this->password)) {
         $this->generatePasswordHash();
     }
     return parent::beforeSave($insert);
 }
Пример #9
0
 public function beforeSave($insert)
 {
     $uploadedFile = Common::uploadFile('Content[thumb]');
     if ($uploadedFile != null) {
         $this->thumb = $uploadedFile['url'] . $uploadedFile['new_name'];
     }
     if ($this->views == null) {
         $this->views = 0;
     }
     if ($this->comments == null) {
         $this->comments = 0;
     }
     if ($this->summary == null || empty($this->summary)) {
         $content = strip_tags($this->content);
         $pattern = '/\\s/';
         //去除空白
         $content = preg_replace($pattern, '', $content);
         $this->summary = StringHelper::subStr($content, 250);
     }
     return parent::beforeSave($insert);
 }
Пример #10
0
 public function beforeSave($insert)
 {
     $uploadedFile = Common::uploadFile('Content[thumb]');
     if ($uploadedFile['message'] === 'ok') {
         $this->thumb = $uploadedFile['full_name'];
     }
     return parent::beforeSave($insert);
 }