public function saveFormData(Zend_Form $form) { $item = $this->_model; $item->setOptions($form->getValues()); if ($this->_request->getParam('contentMarkdown')) { $context_html = Michelf\MarkdownExtra::defaultTransform($this->_request->getParam('contentMarkdown')); $item->setContentHtml($context_html); } $fullPath = $this->_request->getParam('path'); if ($this->_request->getParam('parentId') != 0) { $parentCategory = $this->_modelMapper->find($this->_request->getParam('parentId'), new Pipeline_Model_PipelineCategories()); if ($parentCategory) { $fullPath = $parentCategory->getFullPath(); } } $item->setFullPath($fullPath); $this->setMetaData($item); $this->getModelMapper()->save($item); if ($item->getId() && $item->getId() != '') { $id = $item->getId(); } else { $id = $this->getModelMapper()->getDbTable()->getAdapter()->lastInsertId(); } $item = $this->getModelMapper()->find($id, $this->getModel()); foreach ($form->getElements() as $key => $element) { if ($element instanceof Zend_Form_Element_File && $element->isUploaded()) { $item = $this->saveUploadFile($element, $item); } } return $item; }
public function viewAction() { $fullPath = $this->getFullPath(); $pipelineMapper = new Pipeline_Model_Mapper_Pipeline(); $pipeline = $pipelineMapper->findByFulPath($fullPath, new Pipeline_Model_Pipeline()); if (is_null($pipeline)) { throw new Zend_Controller_Action_Exception("Страница не найдена", 404); } $this->getJson($pipeline); $this->setParamsDataItem($pipeline); $this->checkDeleted($pipeline); $categoriesMapper = new Pipeline_Model_Mapper_PipelineCategories(); $category = $categoriesMapper->find($pipeline->getCategoryId(), new Pipeline_Model_PipelineCategories()); $pipelineProperties = $pipelineMapper->fetchPropertyRel($pipeline->getId()); if (!empty($pipelineProperties)) { $propertyValuesMapper = new Pipeline_Model_Mapper_PipelinePropertyValues(); $viewProperties = array(); foreach ($pipelineProperties as $property) { $propertyValues = $propertyValuesMapper->findByKey($pipeline->getId(), $property->getId(), new Pipeline_Model_PipelinePropertyValues()); $viewProperties[$property->getName()] = $propertyValues; } $this->view->assign('properties', $viewProperties); } $this->view->assign(array('pipeline' => $pipeline, 'category' => $category, 'title' => $pipeline->getTitle(), 'adminPath' => 'pipeline/edit/' . $pipeline->getId())); $this->checkActive($pipeline); }