Пример #1
0
 protected function validateForm()
 {
     if (!$this->user->hasPermission('modify', 'catalog/category')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     foreach ($this->request->post['category_description'] as $language_id => $value) {
         if (utf8_strlen($value['name']) < 2 || utf8_strlen($value['name']) > 255) {
             $this->error['name'][$language_id] = $this->language->get('error_name');
         }
         if (utf8_strlen($value['meta_title']) < 1 || utf8_strlen($value['meta_title']) > 255) {
             $this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
         }
     }
     if (utf8_strlen($this->request->post['keyword']) > 0) {
         $keyword = strtolower(trim($this->request->post['keyword']));
         if (!checkURLString($keyword)) {
             $this->error['keyword'] = sprintf($this->language->get('error_keyword'));
         }
     } else {
         //如果为空,取出第一个语言的名字作为网址keyword
         $name = '';
         foreach ($this->request->post['category_description'] as $language_id => $value) {
             $name = $value['name'];
             break;
         }
         $this->request->post['keyword'] = getURLString($name);
     }
     return !$this->error;
 }
Пример #2
0
 protected function validateForm()
 {
     if (!$this->user->hasPermission('modify', 'catalog/information')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     foreach ($this->request->post['information_description'] as $language_id => $value) {
         if (utf8_strlen($value['title']) < 1 || utf8_strlen($value['title']) > 64) {
             $this->error['title'][$language_id] = $this->language->get('error_title');
         }
         if (utf8_strlen($value['description']) < 1) {
             $this->error['description'][$language_id] = $this->language->get('error_description');
         }
         if (utf8_strlen($value['meta_title']) < 1 || utf8_strlen($value['meta_title']) > 255) {
             $this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
         }
     }
     if (utf8_strlen($this->request->post['keyword']) > 0) {
         $keyword = strtolower(trim($this->request->post['keyword']));
         if (!checkURLString($keyword)) {
             $this->error['keyword'] = sprintf($this->language->get('error_keyword'));
         }
     } else {
         $this->error['keyword'] = sprintf($this->language->get('error_keyword'));
     }
     if ($this->error && !isset($this->error['warning'])) {
         $this->error['warning'] = $this->language->get('error_warning');
     }
     return !$this->error;
 }
Пример #3
0
 protected function validateForm()
 {
     if (!$this->user->hasPermission('modify', 'catalog/product')) {
         $this->error['warning'] = $this->language->get('error_permission');
     }
     foreach ($this->request->post['product_description'] as $language_id => $value) {
         if (utf8_strlen($value['name']) < 1 || utf8_strlen($value['name']) > 255) {
             $this->error['name'][$language_id] = $this->language->get('error_name');
         }
         if (utf8_strlen($value['meta_title']) < 1 || utf8_strlen($value['meta_title']) > 255) {
             $this->error['meta_title'][$language_id] = $this->language->get('error_meta_title');
         }
     }
     if (utf8_strlen($this->request->post['model']) < 1 || utf8_strlen($this->request->post['model']) > 64) {
         $this->error['model'] = $this->language->get('error_model');
     }
     if (utf8_strlen($this->request->post['keyword']) > 0) {
         $keyword = strtolower(trim($this->request->post['keyword']));
         if (!checkURLString($keyword)) {
             $this->error['keyword'] = sprintf($this->language->get('error_keyword'));
         }
         //去掉系统默认的方式,改为我们自己的存为数据库的keyword字段
         //			$this->load->model('catalog/url_alias');
         //
         //			$url_alias_info = $this->model_catalog_url_alias->getUrlAlias($this->request->post['keyword']);
         //
         //			if ($url_alias_info && isset($this->request->get['product_id']) && $url_alias_info['query'] != 'product_id=' . $this->request->get['product_id']) {
         //				$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
         //			}
         //
         //			if ($url_alias_info && !isset($this->request->get['product_id'])) {
         //				$this->error['keyword'] = sprintf($this->language->get('error_keyword'));
         //			}
     } else {
         //如果为空,取出第一个语言的商品名字作为网址keyword
         $name = '';
         foreach ($this->request->post['product_description'] as $language_id => $value) {
             $name = $value['name'];
             break;
         }
         $this->request->post['keyword'] = getURLString($name);
     }
     if ($this->error && !isset($this->error['warning'])) {
         $this->error['warning'] = $this->language->get('error_warning');
     }
     return !$this->error;
 }