Пример #1
0
 private function __checkData($data)
 {
     $errors = array();
     $options = array('cname' => array('required' => array('rule' => true, 'message' => L('_ERR_EMPTY_CNAME_')), 'string_count_in_range' => array('rule' => array_values($this->cnameLength), 'message' => L('_ERR_LENGTH_CNAME_', $this->cnameLength))));
     $rs = \Component\Tools\Validator::make($errors, $data, $options);
     if (!$rs) {
         foreach ($errors as $k => $v) {
             throw new \Exception($v);
         }
     }
     if ($data['sort']) {
         if (!($rs = is_numeric($data['sort']))) {
             throw new \Exception(L('_ERR_FORMART_PARAMS_NUM', array('param' => 'sort')));
         }
     }
     if ($data['pid']) {
         if (!($rs = is_numeric($data['pid']))) {
             throw new \Exception(L('_ERR_FORMART_PARAMS_NUM', array('param' => 'pid')));
         }
     }
     return $rs;
 }
Пример #2
0
 private function __checkData($data)
 {
     $errors = array();
     $options = array('article-title' => array('required' => array('rule' => true, 'message' => L('_ERR_EMPTY_TITLE_')), 'string_count_in_range' => array('rule' => array(2, 100), 'message' => L('_ERR_LENGTH_TITLE_', array('min' => 2, 'max' => 100)))), 'article-actid' => array('required' => array('rule' => true, 'message' => L('_ERR_EMPTY_CAT_'))), 'content' => array('required' => array('rule' => true, 'message' => L('_ERR_EMPTY_CONTENT_'))));
     $rs = \Component\Tools\Validator::make($errors, $data, $options);
     if (!$rs) {
         foreach ($errors as $k => $v) {
             throw new \Exception($v);
         }
     }
     // 判断url是否合法
     if ($data['sourl']) {
         if (!($rs = \Component\Tools\Validator::is_url($data['sourl']))) {
             throw new \Exception(L('_ERR_FORMART_URL_'));
         }
     }
     return $rs;
 }