예제 #1
0
 public function showCategories()
 {
     $categoryModel = new Category();
     $categories = $categoryModel->getAllCategories(10);
     var_dump($categories);
     die;
 }
 public function categoryAction()
 {
     $catId = (int) $this->getRequestParam('id', 0);
     $categoriesTbl = new Category();
     $cat = $categoriesTbl->getCategory($catId);
     if (!$cat) {
         $this->notFound();
     }
     $componentMenu = new TopMenuComponent($this);
     $componentMenuResp = $componentMenu->toString();
     $componentNotify = new NotifyComponent($this);
     $componentNotifyResp = $componentNotify->toString();
     $form = new CategoryFormType($this);
     $form->fill($cat);
     if ($_POST) {
         if ($form->fillAndIsValid()) {
             if ($idNew = $form->save()) {
                 if (is_array($idNew)) {
                     $idNew = $catId;
                 }
                 $this->redirect('backend_category', array('id' => $idNew));
             }
         }
     }
     $formR = $form->render();
     $this->render(array('componentMenu' => $componentMenuResp, 'componentNotify' => $componentNotifyResp, 'form' => $formR), 'Backend/Category/category.html');
 }
예제 #3
0
 protected function make(MainForm $form)
 {
     $form->setName('product');
     $form->setMethod(MainForm::METHOD_POST);
     $validOpt = array(MainValidator::NOT_EMPTY => array('message' => 'Заполните название'), MainValidator::LENGTH_MIN => array('message' => 'Название не должно быть таким маленьким)', 'min' => 2), MainValidator::LENGTH_MAX => array('message' => 'Слишком большое название', 'max' => 255));
     $form->addText('name', 'Название', '', true, $validOpt);
     $form->addFile('file', 'Изображение', '', true);
     $tblCat = new Category();
     $categories = $tblCat->getAllCategoriesForFilter();
     $form->addSelect('parent_category', 'Родительская категория', '0', $categories);
     $form->addText('number_sort', 'Порядок сортировки', '0', true, array());
     $form->addSubmit('pr_s', 'Отправить');
     return $form;
 }
예제 #4
0
 public function categoryAction()
 {
     $catId = (int) $this->getRequestParam('id', 0);
     $catTbl = new Category();
     $category = $catTbl->getCategory($catId);
     if (!$category) {
         $this->notFound();
     }
     $categories = $catTbl->getAllThisLevelCategories($catId);
     $products = $catTbl->getProductsFromCategory($catId);
     $componentMenu = new TopMenuComponent($this);
     $componentMenuResp = $componentMenu->toString();
     $this->render(array('category' => $category, 'categories' => $categories, 'products' => $products, 'leftMenu' => $componentMenuResp), 'App/Category/products.html');
 }
예제 #5
0
 protected function make(MainForm $form)
 {
     $form->setName('product');
     $form->setMethod(MainForm::METHOD_POST);
     $validOpt = array(MainValidator::NOT_EMPTY => array('message' => 'Заполните название'), MainValidator::LENGTH_MIN => array('message' => 'Название не должно быть таким маленьким)', 'min' => 2), MainValidator::LENGTH_MAX => array('message' => 'Слишком большое название', 'max' => 255));
     $form->addText('name', 'Название', '', true, $validOpt);
     $form->addText('price', 'Цена', '', true, array(MainValidator::IS_INTEGER => true));
     $tblCat = new Category();
     $categories = $tblCat->getAllCategoriesForFilter();
     $form->addSelect('category_id', 'Категория', '0', $categories);
     $form->addFile('file', 'Изображение', '', true);
     $form->addBool('visible', 'Видимость', true);
     $form->addBool('isset', 'Наличие', true);
     $form->addTextarea('description', 'Описание', '', true, array(MainValidator::NOT_EMPTY => true));
     $form->addSubmit('pr_s', 'Отправить');
     return $form;
 }
예제 #6
0
 protected function run()
 {
     $catTbl = new Category();
     $categories = $catTbl->getAllThisLevelCategories();
     return $this->render(array('categories' => $categories), 'App/Component/topMenuComponent.html');
 }