public function editAction() { if ($this->_request->getParam('dataPage')) { $dataPage = $this->_request->getParam('dataPage'); $id = $this->_request->getParam('id'); $item = $this->_modelMapper->find($id, $this->_model); $item->setOptions($dataPage); $categories = $this->_modelCategoriesMapper->find($item->getCategoryId(), new Manufacture_Model_ManufactureCategories()); $fullPath = $categories->getPath() . '/' . $item->getPath(); $item->setFullPath($fullPath); $this->setUploadImage($item); $markdown = $dataPage['contentMarkdown']; $context_html = Michelf\MarkdownExtra::defaultTransform($markdown); $item->setContentHtml($context_html); $this->_modelMapper->save($item); $this->_redirector->gotoUrlAndExit('/manufacture/' . $item->getFullPath()); } parent::editAction(); }
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); } }
/** * @param $id * @param Zend_Db_Table_Select|null $select * @return array|null * @throws Zend_Db_Table_Exception * @throws Zend_Db_Table_Row_Exception */ public function fetchManufactureRel($id, Zend_Db_Table_Select $select = null) { $result = $this->getDbTable()->find($id); if (0 == count($result)) { return null; } $category = $result->current(); $resultSet = $category->findDependentRowset('Manufacture_Model_DbTable_Manufacture', 'CategoriesRel', $select); $entries = array(); $manufactureMapper = new Manufacture_Model_Mapper_Manufacture(); foreach ($resultSet as $row) { $entry = new Manufacture_Model_Manufacture(); $entry = $manufactureMapper->_setDbData($row, $entry); $entries[] = $entry; } return $entries; }