Beispiel #1
0
 public function keywords_validation($attribute, $params)
 {
     $censor = new \app\common\DCensor();
     if ($censor->check($this->{$attribute})) {
         $this->addError($attribute, '关键词中有敏感信息');
     }
     $keywordsExp = explode(',', $this->{$attribute});
     if (count($keywordsExp) > 7) {
         $this->addError($attribute, '关键词不能超过7个');
     } else {
         foreach ($keywordsExp as $key => $value) {
             $utf8Str = mb_convert_encoding($value, 'UTF-8', array('GBK', 'GB2312'));
             if (\app\common\XUtils::utf8_strlen($utf8Str) >= 12) {
                 $this->addError($attribute, '每个关键词长度不能超过12个字符');
             }
         }
     }
 }