public function indexAction()
 {
     $category = $this->_category;
     if (!$category) {
         $this->_redirector->gotoSimpleAndExit('index', 'index');
     }
     $select = $this->_itemMapper->getDbTable()->select();
     $select->where('deleted != ?', 1)->where('active != ?', 0)->where('category_id = ?', $category->getId())->order('sorting ASC');
     $pagesItems = $this->_itemMapper->fetchAll($select);
     if (!empty($pagesItems)) {
         $this->view->pageItems = $this->paginationPage($pagesItems);
     }
     $this->setMetaHead($category);
     $this->view->category = $category;
 }
 public function seoAction()
 {
     $pageId = $this->_request->getParam('id');
     if (is_null($pageId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $page = $this->_modelMapper->find($pageId, new Pages_Model_Pages());
     if ($this->getRequest()->isPost()) {
         if ($this->getRequest()->getParam('dataFormSeo')) {
             $dataFormSeo = $this->getRequest()->getParam('dataFormSeo');
             $page->setOptions($dataFormSeo);
             $this->_modelMapper->save($page);
         }
     }
     $url = $page->getPath() != 'home' ? '/' . $page->getPath() : '/';
     $this->_redirector->gotoUrlAndExit($url);
 }
 public function indexAction()
 {
     $fullPath = $this->getFullPath();
     if (is_null($fullPath)) {
         $this->_redirector->gotoSimpleAndExit('index', 'index');
     }
     $category = $this->_categoryMapper->findByFulPath($fullPath, new Oil_Model_OilCategories());
     if (is_null($category)) {
         //throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         //перенаправляем в товар, может быть это товар
         $this->forward('view', 'oil');
         return;
     }
     if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) {
         $this->forward('json', 'oil-categories', 'admin', array('id' => $category->getId()));
         return;
     }
     if (Zend_Auth::getInstance()->hasIdentity()) {
         $this->_request->setParams(array('dataItem' => array('controller' => 'oil-categories', 'id' => $category->getId(), 'active' => $category->getActive(), 'deleted' => $category->getDeleted())));
     }
     if ($category->getDeleted() != '0') {
         if (!Zend_Auth::getInstance()->hasIdentity()) {
             throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
         }
         $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'oil-categories', 'action' => 'index'), 'adminEdit', true);
     }
     $this->view->assign(array('category' => $category, 'title' => $category->getTitle(), 'adminPath' => 'oil-categories/list/' . $category->getId()));
     if ($category->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) {
         throw new Zend_Controller_Action_Exception("Раздел временно не доступен", 500);
     }
     if ($category->getId() != 0) {
         $select = $this->_categoryMapper->getDbTable()->select();
         $select->where('parent_id = ?', $category->getId())->where('deleted != ?', 1)->order('sorting ASC');
         $categories = $this->_categoryMapper->fetchAll($select);
         if (empty($categories)) {
             $this->forward('index', 'oil', 'oil', array('category' => $category));
             return;
         }
         $this->view->categories = $categories;
     } else {
         $this->_redirector->gotoUrlAndExit('/oil/', array('code' => 301));
     }
 }
 public function editAction()
 {
     //Zend_Debug::dump($this->_request->getParams());
     $productId = $this->_request->getParam('id');
     if (is_null($productId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $product = $this->_modelMapper->find($productId, new Catalog_Model_Products());
     if ($this->_request->isPost()) {
         $url = $this->_request->getParam('currentUrl');
         if ($this->_request->getParam('dataFormProducts')) {
             $dataProducts = $this->_request->getParam('dataFormProducts');
             //основные - sku, name, description, note, sorting, path
             $product->setOptions($dataProducts);
             //modDate, order
             $product->setModDate(date("Y-m-d H:i:s"));
             $product->setOrder($dataProducts['sorting']);
             //fullPath, categoryId в category_xref
             $categoryId = $this->_request->getParam('categoryId');
             $category = $this->_modelCategoriesMapper->find($categoryId, new Catalog_Model_Categories());
             if ($category) {
                 $fullPath = $category->getFullPath() . '/' . $dataProducts['path'];
                 $product->setFullPath($fullPath);
                 $categoriesXrefMapper = new Catalog_Model_Mapper_CategoriesXref();
                 $oldCategory = $this->_modelMapper->findCategoryRel($productId, new Catalog_Model_Categories());
                 $categoriesXref = $categoriesXrefMapper->find($productId, $oldCategory->getId(), new Catalog_Model_CategoriesXref());
                 $categoriesXref->setCategoryId($categoryId);
                 $categoriesXrefMapper->updateByProductId($categoriesXref);
                 $url = '/catalog/' . $fullPath;
             }
             $upload = new Zend_File_Transfer();
             $uploadPath = '/upload/products/' . $productId . '/';
             //image
             if ($upload->isUploaded('fileLoadImage')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadImage');
                 $product->setUploadPath($uploadPath)->setImage($imageFile['fileLoadImage']['name']);
             }
             //draft
             if ($upload->isUploaded('fileLoadDraft')) {
                 $imageFile = $this->_uploadFiles($productId, $upload, 'fileLoadDraft');
                 $product->setUploadPathDraft($uploadPath)->setDraft($imageFile['fileLoadDraft']['name']);
             }
             $this->_modelMapper->save($product);
             /*Zend_Debug::dump($upload->isUploaded('fileLoadImage'));
               Zend_Debug::dump($upload->isUploaded('fileLoadDraft'));*/
         }
         //Zend_Debug::dump($product);
         $this->_redirector->gotoUrlAndExit($url);
     }
 }
 public function enableAction()
 {
     $itemId = $this->_request->getParam('id');
     if (empty($itemId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $item = $this->getModelMapper()->find($itemId, $this->getModel());
     if (is_null($item)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     $enabled = $item->getActive() != 0 ? 0 : 1;
     $item->setActive($enabled);
     $this->getModelMapper()->save($item);
     $this->clearCache($this->_getNamespace());
     $url = $this->getRedirectUrl();
     //Zend_Debug::dump($this->_getNamespace());
     $this->getRedirector()->gotoUrlAndExit($url);
 }
 /**
  * executes the defult url if it is configured at agana.ini file
  * with agana.defaulturl parameter
  */
 public function indexAction()
 {
     $options = Agana_Util_Bootstrap::getOption('agana');
     //Zend_Debug::dump(Agana_Api_Util_Bootstrap::getBootstrap()->getOptions());
     if (isset($options['defaultdispatch'])) {
         if (strtolower(trim($options['defaultdispatch'])) == 'redirect') {
             if (trim($options['defaulturl']) != '') {
                 $this->_redirect($options['defaulturl']);
             } else {
                 $redirect = new Zend_Controller_Action_Helper_Redirector();
                 $redirect->gotoSimpleAndExit($options['defaultaction'], $options['defaultcontroller'], $options['defaultmodule']);
             }
         } else {
             if (strtolower(trim($options['defaultdispatch'])) == 'forward') {
                 $this->_forward($options['defaultaction'], $options['defaultcontroller'], $options['defaultmodule']);
             }
         }
     }
 }
 public function disabledAction()
 {
     $categoryId = $this->_request->getParam('id');
     if (is_null($categoryId)) {
         $this->_redirector->gotoSimpleAndExit('index');
     }
     $category = $this->_modelMapper->find($categoryId, new Catalog_Model_Categories());
     if (is_null($category)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     if ($this->_request->isPost()) {
         $url = $this->_request->getParam('currentUrl');
         $enabled = $category->getActive() != 0 ? 0 : 1;
         $category->setActive($enabled);
         $this->_modelMapper->save($category);
         $this->clearCache('CatalogCategories');
         $this->_redirector->gotoUrlAndExit($url);
     }
 }
 public function clearAllAction()
 {
     $this->_cache->clean(Zend_Cache::CLEANING_MODE_ALL);
     $this->_redirector->gotoSimpleAndExit('index');
 }