当前位置: 首页>>代码示例>>PHP>>正文


PHP Model_Category::validate方法代码示例

本文整理汇总了PHP中Model_Category::validate方法的典型用法代码示例。如果您正苦于以下问题:PHP Model_Category::validate方法的具体用法?PHP Model_Category::validate怎么用?PHP Model_Category::validate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model_Category的用法示例。


在下文中一共展示了Model_Category::validate方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: action_Edit

 public function action_Edit($Kid = 0)
 {
     //ドロップダウンリストの生成
     $select = Model_College::get_list();
     $Kid and $this->data['category'] = Model_Category::query()->where('Kid', '=', $Kid)->get();
     if (Input::post()) {
         $val = Model_Category::validate();
         if ($val->run()) {
             $query = DB::update('Category')->set(array('Cid' => Input::post('college'), 'Kname' => Input::post('Kname'), 'Kkana' => Input::post('Kkana'), 'luID' => Auth::get_screen_name()))->where('Kid', '=', $Kid)->execute();
             Response::redirect('category');
         } else {
             $this->message = $val->error();
             $view = View::forge('categorymanagement/CategoryEdit', $this->data);
             $view->set_global('message', $this->message, false);
             //ドロップダウン箇所のセット
             $view->set_global('select', $select, false);
         }
     } else {
         $view = View::forge('categorymanagement/CategoryEdit', $this->data);
         $view->set_global('message', $this->message, false);
         //ドロップダウン箇所のセット
         $view->set_global('select', $select, false);
     }
     return $view;
 }
开发者ID:nihonLoomba,项目名称:noteshare-,代码行数:25,代码来源:categorymanagement.php

示例2: action_edit

 /**
  * Страница редактирования категории
  */
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('admin/articles/categories');
     $category = \Model_Category::find($id);
     if (empty($category)) {
         throw new \HttpNotFoundException();
     }
     $val = \Model_Category::validate('edit');
     if ($val->run()) {
         $category->value = \Input::post('value');
         if ($category->save()) {
             \Session::set_flash('success', e('Категория успешно отредактирована'));
             \Response::redirect('admin/categories');
         } else {
             \Session::set_flash('error', e('Невозможно отредактировать статью' . $id));
         }
     } else {
         if (\Input::method() == 'POST') {
             $category->value = $val->validated('value');
             \Session::set_flash('error', $val->error());
         }
         $this->template->set_global('category', $category, false);
     }
     $this->template->title = "Статьи";
     $this->template->content = \View::forge('categories/edit');
 }
开发者ID:alexmon1989,项目名称:fcssadon.ru,代码行数:29,代码来源:categories.php

示例3: action_edit

 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('category');
     if (!($category = Model_Category::find($id))) {
         Session::set_flash('error', 'Could not find category #' . $id);
         Response::redirect('category');
     }
     $val = Model_Category::validate('edit');
     if ($val->run()) {
         $category->name = Input::post('name');
         $category->keywords = Input::post('keywords');
         $category->meta = Input::post('meta');
         if ($category->save()) {
             Session::set_flash('success', 'Updated category #' . $id);
             Response::redirect('admin/category');
         } else {
             Session::set_flash('error', 'Could not update category #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $category->name = $val->validated('name');
             $category->keywords = $val->validated('keywords');
             $category->meta = $val->validated('meta');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('category', $category, false);
     }
     $this->template->title = "Categories";
     $this->template->content = View::forge('admin/category/create');
 }
开发者ID:sajans,项目名称:cms,代码行数:30,代码来源:category.php

示例4: action_edit

 public function action_edit($id = null)
 {
     $category = Model_Category::find($id);
     $val = Model_Category::validate('edit');
     if ($val->run()) {
         if ($category->save()) {
             Session::set_flash('success', e('Updated category #' . $id));
             Response::redirect('admin/category');
         } else {
             Session::set_flash('error', e('Could not update category #' . $id));
         }
     } else {
         if (Input::method() == 'POST') {
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('category', $category, false);
     }
     $this->template->title = "Categories";
     $this->template->content = View::forge('admin/category/edit');
 }
开发者ID:blueshift9,项目名称:pscms,代码行数:20,代码来源:category.php

示例5: action_update

 public function action_update($id = false)
 {
     if (!is_numeric($id)) {
         \Response::redirect('admin/product/category/list');
     }
     // Get news item to edit
     if (!($item = Model_Category::find_one_by_id($id))) {
         \Response::redirect('admin/product/category/list');
     }
     \View::set_global('title', 'Edit Category');
     if (\Input::post()) {
         $val = Model_Category::validate('update');
         // Upload image and display errors if there are any
         $image = $this->upload_image();
         if (!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images)) {
             // No previous images and image is not selected and it is required
             \Messages::error('<strong>There was an error while trying to upload content image</strong>');
             \Messages::error('You have to select image');
         } elseif ($image['errors']) {
             \Messages::error('<strong>There was an error while trying to upload content image</strong>');
             foreach ($image['errors'] as $error) {
                 \Messages::error($error);
             }
         }
         if ($val->run() && $image['is_valid'] && !(!$image['exists'] && \Config::get('details.image.required', false) && empty($item->images))) {
             /** IMAGES **/
             // Get all alt texts to update if there is no image change
             foreach (\Arr::filter_prefixed(\Input::post(), 'alt_text_') as $image_id => $alt_text) {
                 if (strpos($image_id, 'new_') === false) {
                     $item_images[$image_id] = array('id' => $image_id, 'data' => array('alt_text' => \Input::post('alt_text_' . $image_id, '')));
                 }
             }
             // Save images if new files are submitted
             if (isset($this->_image_data)) {
                 foreach ($this->_image_data as $image_data) {
                     $cover_count = count($item->images);
                     if (strpos($image_data['field'], 'new_') === false) {
                         // Update existing image
                         if (str_replace('image_', '', $image_data['field']) != 0) {
                             $image_id = (int) str_replace('image_', '', $image_data['field']);
                             $cover_count--;
                             $item_images[$image_id] = array('id' => $image_id, 'data' => array('content_id' => $item->id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_' . $image_id, '')));
                             $this->delete_image(\Input::post('image_db_' . $image_id, ''));
                         }
                     } else {
                         // Save new image
                         $image_tmp = str_replace('image_new_', '', $image_data['field']);
                         $item_images[0] = array('id' => 0, 'data' => array('content_id' => $item->id, 'image' => $image_data['saved_as'], 'alt_text' => \Input::post('alt_text_new_' . $image_tmp, ''), 'cover' => $cover_count == 0 ? 1 : 0, 'sort' => $cover_count + 1));
                     }
                 }
             }
             Model_Category::bind_images($item_images);
             /** END OF IMAGES **/
             // Get POST values
             $insert = \Input::post();
             // Prepare some values
             //				$insert['published_at'] = !empty($insert['published_at']) ? strtotime($insert['published_at']) : $news->created_at;
             $insert['active_from'] = !empty($insert['active_from']) ? strtotime($insert['active_from']) : NULL;
             $insert['active_to'] = !empty($insert['active_to']) ? strtotime($insert['active_to']) : NULL;
             if ($insert['status'] != 2) {
                 unset($insert['active_from']);
                 unset($insert['active_to']);
             }
             $item->set($insert);
             try {
                 $item->save();
                 \Messages::success('Category successfully updated.');
                 \Response::redirect(\Input::post('exit', false) ? \Uri::create('admin/product/category/list/') : \Uri::admin('current'));
             } catch (\Database_Exception $e) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update category</strong>');
                 // Uncomment lines below to show database errors
                 //$errors = $e->getMessage();
                 //\Messages::error($errors);
             }
         } else {
             // Delete uploaded images if there is category saving error
             if (isset($this->_image_data)) {
                 foreach ($this->_image_data as $image_data) {
                     $this->delete_image($image_data['saved_as']);
                 }
             }
             if ($val->error() != array()) {
                 // show validation errors
                 \Messages::error('<strong>There was an error while trying to update category</strong>');
                 foreach ($val->error() as $e) {
                     \Messages::error($e->get_message());
                 }
             }
         }
     }
     $category = Model_Category::find_one_by_id($id);
     \Theme::instance()->set_partial('content', $this->view_dir . 'update')->set('category', $category);
 }
开发者ID:EdgeCommerce,项目名称:edgecommerce,代码行数:94,代码来源:category.php


注:本文中的Model_Category::validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。