/** * @param Oil_Model_Oil $pageItem * @return $this * @throws Zend_Controller_Action_Exception */ public function checkDeleted(Oil_Model_Oil $pageItem) { if ($pageItem->getDeleted() != '0') { if (!Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'oil-categories', 'action' => 'list', 'id' => $pageItem->getCategoryId()), 'adminEdit', true); } return $this; }
/** * @param Pipeline_Model_PipelineCategories $categories * @return $this * @throws Zend_Controller_Action_Exception */ public function checkDeleted(Pipeline_Model_PipelineCategories $categories) { if ($categories->getDeleted() != '0') { if (!Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'pipeline-categories'), 'adminEdit', true); } return $this; }
public function viewAction() { $request = $this->getRequest(); $fullPath = $request->getParam('fullPath'); $manufactureMapper = new Manufacture_Model_Mapper_Manufacture(); $manufacture = $manufactureMapper->findByFullPath($fullPath, new Manufacture_Model_Manufacture()); if (is_null($manufacture)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) { $this->forward('json', 'manufacture', 'admin', array('id' => $manufacture->getId())); return; } if (Zend_Auth::getInstance()->hasIdentity()) { $this->_request->setParams(array('dataItem' => array('controller' => 'manufacture', 'id' => $manufacture->getId(), 'active' => $manufacture->getActive(), 'deleted' => $manufacture->getDeleted()))); } $manufactureCategoryMapper = new Manufacture_Model_Mapper_ManufactureCategories(); $manufactureCategory = $manufactureCategoryMapper->find($manufacture->getCategoryId(), new Manufacture_Model_ManufactureCategories()); if ($manufacture->getDeleted() != '0') { if (!Zend_Auth::getInstance()->hasIdentity() && $manufacture->getDeleted() != '0') { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'manufacture-categories', 'action' => 'list', 'id' => $manufactureCategory->getId()), 'adminEdit', true); } $this->view->assign(array('manufacture' => $manufacture, 'meta_description' => $manufacture->getMetaDescription(), 'meta_keywords' => $manufacture->getMetaKeywords(), 'adminPath' => 'manufacture/edit/' . $manufacture->getId(), 'category' => $manufactureCategory)); if ($manufacture->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) { $this->view->assign(array('title' => $manufacture->getTitle())); throw new Zend_Controller_Action_Exception("Страница временно не доступна", 403); } }
public function addAction() { $form = new Front_Form_Contact(); if ($this->_request->isPost()) { $data = $this->_request->getPost(); if ($form->isValid($data)) { $dataFiltrees = $form->getValues(); $contact = new Application_Model_Contact(); $contact->setPrenom($dataFiltrees['prenom'])->setNom($dataFiltrees['nom'])->setEmail($dataFiltrees['email'])->setTelephone($dataFiltrees['telephone']); $this->mapper->insert($contact); $this->_flashMessenger->addMessage('Le contact ' . $contact->getPrenom() . ' a bien été créé'); $this->_redirector->gotoRouteAndExit(['controller' => 'contact'], null, true); } } $this->view->contactForm = $form; }
public function viewAction() { $request = $this->getRequest(); $mediaPathItem = $request->getParam('fullPath'); $mediaMapper = new Media_Model_Mapper_Media(); $mediaItem = $mediaMapper->findByFullPath($mediaPathItem, new Media_Model_Media()); if (is_null($mediaItem)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) { $this->forward('json', 'media', 'admin', array('id' => $mediaItem->getId())); return; } if (Zend_Auth::getInstance()->hasIdentity()) { $this->_request->setParams(array('dataItem' => array('controller' => 'media', 'id' => $mediaItem->getId(), 'active' => $mediaItem->getActive(), 'deleted' => $mediaItem->getDeleted()))); } $mediaCategoryMapper = new Media_Model_Mapper_MediaCategories(); $currentCategory = $mediaCategoryMapper->find($mediaItem->getCategoryId(), new Media_Model_MediaCategories()); if ($mediaItem->getDeleted() != '0') { if (!Zend_Auth::getInstance()->hasIdentity() && $mediaItem->getDeleted() != '0') { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'media-categories', 'action' => 'list', 'id' => $currentCategory->getId()), 'adminEdit', true); } $this->view->assign(array('currentCategory' => $currentCategory, 'adminPath' => 'media/edit/' . $mediaItem->getId())); $meta_description = $mediaItem->getMetaDescription() != '' ? $mediaItem->getMetaDescription() : $mediaItem->getName() . '. ' . $currentCategory->getName() . '. Альфа-Гидро.'; $meta_keywords = $mediaItem->getMetaKeywords() != '' ? $mediaItem->getMetaKeywords() : $mediaItem->getName() . ', ' . $currentCategory->getName() . ', пресса'; $this->view->assign(array('mediaItem' => $mediaItem, 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords)); if ($mediaItem->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) { $this->view->assign(array('title' => $mediaItem->getName())); throw new Zend_Controller_Action_Exception("Страница временно не доступна", 403); } }
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 indexAction() { $parent_id = $this->_request->getParam('parent_id') ? $this->_request->getParam('parent_id') : 0; if ($parent_id != 0) { $this->view->assign(array('breadcrumbs' => $this->containerNavigation($parent_id), 'current_category' => $this->_request->getParam('parent_id'))); } $cache = Zend_Registry::get('cache'); $cacheName = 'Admin_CatalogCategories_' . $parent_id; if (!($pageItems = $cache->load($cacheName))) { $select = $this->_modelMapper->getDbTable()->select(); $select->where('parent_id = ?', $parent_id)->order('sorting ASC'); $pageItems = $this->_modelMapper->fetchAll($select); $cache->save($pageItems, $cacheName, array('admin', 'Catalog', 'CatalogCategories')); } if (0 == count($pageItems)) { $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'categories', 'action' => 'list', 'id' => $parent_id), 'adminEdit', true); } $pageItems = $this->setPaginationPage($pageItems); $config = array(Zend_Navigation_Page_Mvc::factory(array('label' => 'На сайт', 'uri' => '/catalog/' . $this->_modelMapper->getFullPathById($parent_id)))); $containerNav = new Zend_Navigation($config); $editUrlOptions = array('module' => 'admin', 'controller' => 'pages', 'action' => 'edit', 'id' => $this->getPageModule('catalog')->getId()); $this->view->assign(array('pages' => $pageItems, 'auth' => Zend_Auth::getInstance()->hasIdentity(), 'editUrlOptions' => $editUrlOptions, 'container_nav' => $containerNav)); }
public function enableAction() { $request = $this->getRequest(); $itemId = $request->getParam('id'); if (is_null($itemId)) { $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'pipeline-property', 'action' => 'index'), 'adminEdit', true); } $pipelinePropertyMapper = new Pipeline_Model_Mapper_PipelineProperty(); $pipelineProperty = $pipelinePropertyMapper->find($itemId, new Pipeline_Model_PipelineProperty()); if (is_null($pipelineProperty)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $active = $pipelineProperty->getActive() != 0 ? 0 : 1; $pipelineProperty->setActive($active); $pipelinePropertyMapper->save($pipelineProperty); $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'pipeline-property', 'action' => 'index'), 'adminEdit', true); }
public function preDispatch(Zend_Controller_Request_Abstract $request) { $pagesMapper = new Pages_Model_Mapper_Pages(); $page = $pagesMapper->findByPath($request->getModuleName(), new Pages_Model_Pages()); $r = new Zend_Controller_Action_Helper_Redirector(); $layout = Zend_Layout::getMvcInstance(); if (is_null($page)) { return; } if ($page->getDeleted() === '1') { if (!Zend_Auth::getInstance()->hasIdentity()) { $layout->setLayout('layout_error'); throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $r->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'pages', 'action' => 'index'), 'adminEdit', true); } if ($page->getActive() === '0') { if (!Zend_Auth::getInstance()->hasIdentity()) { $layout->setLayout('layout_error'); throw new Zend_Controller_Action_Exception("Раздел временно не доступен", 500); } } }
/** * Denies access to a particular resource */ protected function denyAccess() { $this->_redirector->gotoRouteAndExit(array('controller' => 'error', 'action' => 'access'), null, true); }
/** * When there is a redirectRoute this function will execute it. * * When hasHtmlOutput() is true this functions should not be called. * * @see \Zend_Controller_Action_Helper_Redirector */ public function redirectRoute() { if ($url = $this->getRedirectRoute()) { //\MUtil_Echo::track($url); $router = new \Zend_Controller_Action_Helper_Redirector(); $router->gotoRouteAndExit($url, null, $this->resetRoute); } }
protected function _initLanguage() { $singleLang = Zend_Controller_Front::getInstance()->getParam('singleLang'); if (isset($singleLang) && $singleLang != "") { //1. get language from app.ini $language = $singleLang; $this->getRequest()->setParam("lang", $singleLang); } else { //1. get language from request $language = $this->getRequest()->getParam("lang"); } //$this->_log("Request: " . json_encode($this->getRequest()->getParams()), Zend_Log::DEBUG); if ($language == '') { $language = null; } //2. get language from cookie if (!isset($language)) { $language = $this->getRequest()->getCookie("saved_lang", null); } //3. get from geoip if (!isset($language)) { $country = new Application_Model_Country(); if (Application_Model_CountryMapper::getInstance()->getCountryByGeoIp(HCMS_Utils::getRealIpAddr(), $country)) { $language = strtolower($country->get_def_lang()); } } //4. get default if (!isset($language)) { $language = $this->_getPrimaryLang(); } //check if lang available if (!HCMS_Translate_Adapter_Db::isLangAvailable($language, $this->_isFrontEnd)) { $language = $this->_getPrimaryLang(); } //redirect if lang is not in url if ($language != $this->getRequest()->getParam("lang")) { //redirect only if lang not exists...otherwise let it 404 if (!$this->getRequest()->getParam("lang")) { $this->_log("redirecting to {$language}", Zend_Log::DEBUG); $redirector = new Zend_Controller_Action_Helper_Redirector(); $redirector->gotoRouteAndExit(array('lang' => $language), 'default', false); } } //activate lang HCMS_Translate_Adapter_Db::activate($language); //store lang in cookie $cookieRes = setcookie('saved_lang', $language, time() + 3600, '/', null, false, true); if (!$cookieRes) { $this->_logger->log("Error storing lang cookie", Zend_Log::WARN); } //and in router Zend_Controller_Front::getInstance()->getRouter()->setGlobalParam('lang', $language); //set view and js var if ($this->view) { $this->view->availableLang = Application_Model_TranslateMapper::getInstance()->getLanguages(); $this->view->currLang = $language; $this->view->headScript()->appendScript("var CURR_LANG = '" . $language . "';"); $this->view->singleLang = $this->isSingleLang(); //$this->addLinkAlternateLang(); } //define php const if (!defined("CURR_LANG")) { define("CURR_LANG", $language); } }
/** * @throws Zend_Controller_Action_Exception * */ public function viewAction() { $fullPath = $this->getFullPath(); $products = new Catalog_Model_Mapper_Products(); $product = new Catalog_Model_Products(); $product = $products->findByFulPath($fullPath, $product); if (is_null($product)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } if (!is_null($this->getRequest()->getParam('json')) && Zend_Auth::getInstance()->hasIdentity()) { $this->forward('json', 'products', 'admin', array('id' => $product->getId())); return; } $categoryRel = $products->findCategoryRel($product->getId(), new Catalog_Model_Categories()); $this->setCurrentCategory($categoryRel); if ($product->getDeleted() != '0') { if (!Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'categories', 'action' => 'list', 'id' => $categoryRel->getId()), 'adminEdit', true); } $this->view->draftImage = $product->getDraft(); if (!is_null($product->getAImages())) { $draftImages = unserialize($product->getAImages()); if (!empty($draftImages)) { $this->view->draftImage = $draftImages[0]; } } $productsParams = new Catalog_Model_Mapper_ProductParams(); $select = $productsParams->getDbTable()->select()->order('order ASC'); $productProrerty = $products->findProductParams($product->getId(), $select); if (!empty($productProrerty)) { $this->view->productProperty = $productProrerty; } $subproducts = new Catalog_Model_Mapper_Subproducts(); $select = $subproducts->getDbTable()->select()->where('deleted != ?', 1)->order('order ASC'); $modifications = $products->findSubproductsRel($product->getId(), $select); if (!empty($modifications)) { $this->view->modificationsTableValues = $this->modificationsTableValues($modifications); $this->view->modifications = $modifications; } $subproductParams = new Catalog_Model_Mapper_SubproductParams(); $select = $subproductParams->getDbTable()->select()->order('order ASC'); $subproductProperty = $products->findSubproductParams($product->getId(), $select); if (!empty($subproductProperty)) { $this->view->assign('subproductProperty', $subproductProperty); } if ($product->getMetaDescription() != '') { $meta_description = $product->getMetaDescription(); } else { $categoryMapper = new Catalog_Model_Mapper_Categories(); $parentCategories = $categoryMapper->fetchTreeParentCategories($categoryRel->getId()); $aDescription = array(); $aDescription[] = $product->getName(); if (!empty($parentCategories)) { foreach ($parentCategories as $parentCategory) { $aDescription[] = $parentCategory->name; } } $aDescription[] = 'Альфа-Гидро - Каталог продукции'; $meta_description = implode(", ", array_reverse($aDescription)); } if ($product->getMetaKeywords() != '') { $meta_keywords = $product->getMetaKeywords(); } else { $aKeywords = array(); if (!empty($modifications)) { /**@var $modification Catalog_Model_Subproducts*/ foreach ($modifications as $modification) { $sku = $modification->getSku(); $aKeywords[] = str_replace('A', '', $sku); $aKeywords[] = str_replace(' ', '', $sku); $aKeywords[] = str_replace(array(' ', 'A'), '', $sku); } } $aKeywords[] = $product->getSku(); $aKeywords[] = $product->getName(); $meta_keywords = implode(", ", array_reverse($aKeywords)); } $this->view->assign(array('current_category' => $categoryRel->getId(), 'product' => $product, 'title' => $this->transformSku($product->getSku()), 'secondaryHeader' => $product->getName(), 'adminPath' => 'categories/list/' . $categoryRel->getId(), 'meta_description' => $meta_description, 'meta_keywords' => $meta_keywords)); if ($product->getActive() != '1' && !Zend_Auth::getInstance()->hasIdentity()) { $this->view->assign(array('breadcrumbs' => true, 'sidebar_headers' => true)); throw new Zend_Controller_Action_Exception("Товар временно не доступен", 403); } if (Zend_Auth::getInstance()->hasIdentity()) { $this->_request->setParams(array('dataItem' => array('controller' => 'products', 'id' => $product->getId(), 'active' => $product->getActive(), 'deleted' => $product->getDeleted()))); } }
public function indexAction() { $fullPath = $this->getFullPath(); $categories = new Catalog_Model_Mapper_Categories(); $category = new Catalog_Model_Categories(); $category = $categories->findByFulPath($fullPath, $category); if (is_null($category)) { //throw new Zend_Controller_Action_Exception("Страница не найдена", 404); $this->forward('view', 'products'); return; } if (Zend_Auth::getInstance()->hasIdentity()) { $this->_request->setParams(array('dataItem' => array('controller' => 'categories', 'id' => $category->getId(), 'active' => $category->getActive(), 'deleted' => $category->getDeleted()))); } if ($category->getDeleted() === '1') { if (!Zend_Auth::getInstance()->hasIdentity()) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->_redirector->gotoRouteAndExit(array('module' => 'admin', 'controller' => 'categories', 'action' => 'index', 'parent_id' => $category->getParentId()), 'adminCategoriesEdit', true); } $current_category_id = $category->getId(); $this->view->assign('adminPath', 'categories/' . $current_category_id); if ($current_category_id !== 0) { $jsonRequest = $this->getRequest()->getParam('json'); if (isset($jsonRequest)) { $id = $jsonRequest !== '' ? $jsonRequest : $current_category_id; $this->forward('json', 'categories', 'admin', array('id' => $id)); return; } $select = $categories->getDbTable()->select(); $select->where('parent_id = ?', $current_category_id)->where('deleted != ?', 1)->order('sorting ASC'); if (!$this->_auth) { $select->where('active != ?', 0); } $entries = $categories->fetchAll($select); if (empty($entries)) { /*$productsMapper = new Catalog_Model_Mapper_Products(); $select = $productsMapper->getDbTable()->select()->order('sorting ASC'); $entries = $categories->fetchProductsRel($current_category_id, $select);*/ $this->view->assign(array('category' => $category)); $this->forward('index', 'products'); return; } $this->view->assign('entries', $entries); } else { $this->redirect('/catalog/', array('code' => 301)); return; } if ($category->getMetaKeywords() != '') { $meta_keywords = $category->getMetaKeywords(); } else { $aKeywords = array(); if (!empty($entries)) { foreach ($entries as $entry) { $aKeywords[] = $entry->getName(); } } $aKeywords[] = $category->getName(); $meta_keywords = implode(", ", array_reverse($aKeywords)); } $this->view->assign(array('title' => $category->getName(), 'current_category' => $current_category_id, 'meta_description' => $this->setMetaDescription($category), 'meta_keywords' => strtolower($meta_keywords))); if ($category->getActive() === '0' && !Zend_Auth::getInstance()->hasIdentity()) { $this->view->assign(array('breadcrumbs' => true, 'sidebar_headers' => true)); throw new Zend_Controller_Action_Exception("Раздел временно не доступен", 403); } }