示例#1
0
文件: Page.php 项目: eok8177/shopCMS
 /**
  * Add
  */
 public function action_add()
 {
     $this->title = __('publications.page_add');
     $obj = ORM::factory('Publications_Page');
     if ($this->request->is_post()) {
         $tags = Arr::get($_POST, 'tags');
         $obj->prepare();
         $obj->values($_POST);
         try {
             $obj->save();
             if (Module::is_on('cms_tags')) {
                 $obj->save_tags($tags, Model_Tag::TYPE_PUBLICATION);
             }
             Message::success(__('publications.page_added'));
             $this->_redirect($obj->id);
         } catch (ORM_Validation_Exception $e) {
             Message::error(__('settings.error_saving'));
             $errors = $e->errors('validation');
         }
     } else {
         $tags = '';
     }
     $sel_category = Tree::instance('publications_categories', $this->curr_module)->form_select('category_id', $obj->category_id, ['', ''], ['class' => 'form-control']);
     $this->content = View::factory($this->form, ['obj' => $obj, 'sel_category' => $sel_category])->bind('tags', $tags)->bind('errors', $errors);
 }
示例#2
0
 public static function getInstance()
 {
     if (!self::$instance instanceof self) {
         self::$instance = new self();
     }
     return self::$instance;
 }
示例#3
0
 /**
  * Edit
  */
 public function action_edit()
 {
     $this->title = __('shop.category_edit');
     $obj = ORM::factory('Shop_Category', $this->request->param('id'));
     if (!$obj->loaded()) {
         throw new HTTP_Exception_404();
     }
     if ($this->request->is_post()) {
         $obj->prepare();
         $obj->values($_POST);
         try {
             $obj->save();
             Message::success(__('settings.changes_saved'));
             $this->_redirect($obj->id);
         } catch (ORM_Validation_Exception $e) {
             Message::error(__('settings.error_saving'));
             $errors = $e->errors('validation');
         }
     }
     $sel_category = Tree::instance('shop_categories', $this->curr_module, ['last' => false])->form_select('parent_id', $obj->parent_id, [0, ''], ['class' => 'form-control']);
     $this->content = View::factory($this->form, ['obj' => $obj, 'sel_category' => $sel_category])->bind('errors', $errors);
 }
示例#4
0
 /**
  * Edit
  */
 public function action_edit()
 {
     Assets::instance()->add_styles(['vendor/crop/css/cropper.min.css', 'vendor/crop/css/screen.css'])->add_scripts(['vendor/fileuploader/jquery.ui.widget.js', 'vendor/fileuploader/jquery.iframe-transport.js', 'vendor/fileuploader/jquery.fileupload.js', 'vendor/crop/js/cropper.min.js', 'vendor/crop/js/main.js']);
     $this->title = __('shop.product_edit');
     $obj = ORM::factory('Shop_Product', $this->request->param('id'));
     if (!$obj->loaded()) {
         throw new HTTP_Exception_404();
     }
     if ($this->request->is_post()) {
         $obj->prepare();
         $obj->values($_POST);
         try {
             $obj->save();
             Message::success(__('settings.changes_saved'));
             $this->_redirect($obj->id);
         } catch (ORM_Validation_Exception $e) {
             Message::error(__('settings.error_saving'));
             $errors = $e->errors('validation');
         }
     }
     $sel_category = Tree::instance('shop_categories', $this->curr_module)->form_select('category_id', $obj->category_id, ['', ''], ['class' => 'form-control']);
     $this->content = View::factory($this->form, ['obj' => $obj, 'sel_category' => $sel_category])->bind('errors', $errors);
 }