Пример #1
0
 public function addAction()
 {
     if ($this->tplVars['lvals']['canEdit']) {
         array_push($this->tplVars['page_css'], 'livevalidation.css');
         array_push($this->tplVars['page_js'], 'livevalidation.js');
         array_push($this->tplVars['page_css'], 'product_edit.css');
         array_push($this->tplVars['header']['actions']['names'], array('name' => 'add', 'menu_name' => 'Add Product'));
         $this->tplVars['header']['actions']['names'][] = array('name' => 'platforms', 'menu_name' => 'Platform list');
         $this->tplVars['header']['actions']['names'][] = array('name' => 'os', 'menu_name' => 'OS list');
         array_push($this->viewIncludes, 'products/productsEdit.tpl');
         $this->tplVars['lvals']['postRes'] = 2;
         $products = new AdminProducts();
         $this->tplVars['product'] = array();
         $this->tplVars['cats'] = $products->getCategories(TRUE);
         $this->tplVars['plat'] = $products->getPlatforms(TRUE);
         $this->tplVars['langs'] = $products->getProductLangs(TRUE);
         $this->tplVars['os'] = $products->getProductOS(TRUE);
         $this->tplVars['lvals']['isNewRecord'] = true;
         if ($this->_request->getPost('ispost')) {
             $this->tplVars['product'] = $this->_request->getPost();
             $this->tplVars['cats']['select'] = $this->_request->getPost('p_cat');
             $this->tplVars['plat']['select'] = $this->_request->getPost('p_platform');
             $this->tplVars['langs']['select'] = $this->_request->getPost('p_languages');
             $this->tplVars['os']['select'] = $this->_request->getPost('p_os');
             $id = $this->tplVars['lvals']['postRes'] = $products->addProduct($this->tplVars['product']);
             $this->to_log($id);
             if ($id > 0) {
                 $this->_redirect('/products/edit/id/' . $id);
             }
         }
     }
 }