Пример #1
0
 /**
  * Builds the default view for the categories
  * management page. Built using streams it also
  * manages all insert/editing of the given
  * category.
  *
  * @param integry $id (Optional) The ID of the category
  *					  to be edited/updated.
  * @access public
  */
 public function index($id = 0)
 {
     // Check for post data
     if ($this->input->post('btnAction') == 'save') {
         // Variables
         $input = $this->input->post();
         $id = $input['id'] > 0 ? $input['id'] : $id;
         $skip = array('btnAction');
         $extra = array('return' => '/admin/firesale/categories', 'success_message' => lang('firesale:cats_' . ($id == NULL ? 'add' : 'edit') . '_success'), 'error_message' => lang('firesale:cats_' . ($id == NULL ? 'add' : 'edit') . '_error'));
         if ($id != null) {
             $input = (object) $input;
             $this->data->input = $input;
         }
     } else {
         if ($this->input->post('btnAction') == 'delete') {
             $this->delete($this->input->post('id'));
         } else {
             $input = FALSE;
             $skip = array();
             $extra = array();
         }
     }
     // Get the stream fields
     $fields = $this->fields->build_form($this->stream, $id == NULL ? 'new' : 'edit', $input, FALSE, FALSE, $skip, $extra);
     // Set query paramaters
     $params = array('stream' => 'firesale_categories', 'namespace' => 'firesale_categories', 'order_by' => 'ordering_count', 'sort' => 'asc');
     // Assign variables
     $this->data->controller =& $this;
     $this->data->cats = $this->categories_m->generate_streams_tree($params);
     $this->data->fields = fields_to_tabs($fields, $this->tabs);
     $this->data->tabs = array_keys($this->data->fields);
     // Build the page
     $this->template->title(lang('firesale:title') . ' ' . lang('firesale:sections:categories'))->build('admin/categories/index', $this->data);
 }
Пример #2
0
 public function create($id = NULL, $row = NULL)
 {
     // Check for post data
     if (substr($this->input->post('btnAction'), 0, 4) == 'save') {
         // Variables
         $input = $this->input->post();
         $skip = array('btnAction');
         $extra = array('return' => '/admin/firesale/products/edit/-id-', 'success_message' => lang('firesale:prod_' . ($id == NULL ? 'add' : 'edit') . '_success'), 'error_message' => lang('firesale:prod_' . ($id == NULL ? 'add' : 'edit') . '_error'));
         // Check button action for return location
         if ($this->input->post('btnAction') == 'save_exit') {
             $extra['return'] = '/admin/firesale/products';
         }
         // Manually update categories
         // Multiple tends not to do it
         if ($id !== NULL) {
             $this->products_m->update_categories($id, $this->stream->id, $input['category']);
             unset($_POST['category']);
         }
         // Added to seperate if since above will be removed for 2.2
         if ($id !== NULL) {
             $data = array_merge(array('id' => $id, 'stream' => 'firesale_products'), $input);
             Events::trigger('product_updated', $data);
         }
     } else {
         $input = FALSE;
         $skip = array();
         $extra = array();
     }
     // Get the stream fields
     $fields = $this->fields->build_form($this->stream, $id == NULL ? 'new' : 'edit', $id == NULL ? $input : $row, FALSE, FALSE, $skip, $extra);
     // Assign variables
     if ($row !== NULL) {
         $this->data = $row;
     }
     $this->data->id = $id;
     $this->data->fields = fields_to_tabs($fields, $this->tabs);
     $this->data->tabs = array_keys($this->data->fields);
     // Get current images
     if ($row != FALSE) {
         $folder = $this->products_m->get_file_folder_by_slug($row->slug);
         $images = Files::folder_contents($folder->id);
         $this->data->images = $images['data']['file'];
     }
     // Add metadata
     $this->template->append_js('module::jquery.filedrop.js')->append_js('module::upload.js')->append_metadata($this->load->view('fragments/wysiwyg', NULL, TRUE));
     // Add page data
     $this->template->title(lang('firesale:title') . ' ' . lang('firesale:prod_title_' . ($id == NULL ? 'create' : 'edit')))->set($this->data)->enable_parser(true);
     // Fire events
     Events::trigger('page_build', $this->template);
     // Build page
     $this->template->build('admin/products/create');
 }