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)); } }