Ejemplo n.º 1
0
 public function beforeValidate()
 {
     if ($this->is_cache == null) {
         $this->is_cache = true;
     }
     return parent::beforeValidate();
 }
Ejemplo n.º 2
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         if ($this->is_default) {
             DefineTable::updateAll(['is_default' => 0]);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 public function beforeValidate()
 {
     if (parent::beforeValidate()) {
         $this->title_format = CommonUtility::getTitleFormatValue($this->title_format);
         $uploadedFile = CommonUtility::uploadFile('Page[title_pic]');
         if ($uploadedFile != null) {
             $this->title_pic = $uploadedFile['url'] . $uploadedFile['new_name'];
         }
         if (!is_int($this->sort_num)) {
             $this->sort_num = 0;
         }
         $this->publish_time = TTimeHelper::getCurrentTime();
         $this->modify_time = TTimeHelper::getCurrentTime();
         if ($this->summary == null || empty($this->summary)) {
             $body = strip_tags($this->body);
             $pattern = '/\\s/';
             //去除空白
             $body = preg_replace($pattern, '', $body);
             $this->summary = TStringHelper::subStr($body, 250);
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 public function beforeSave($insert)
 {
     if (parent::beforeSave($insert)) {
         $this->checkLength();
         return true;
     }
     return false;
 }