public function saveFormData(Zend_Form $form)
 {
     $item = $this->getModel();
     $item->setOptions($form->getValues());
     if ($this->_request->getParam('contentMarkdown')) {
         $context_html = Michelf\MarkdownExtra::defaultTransform($this->_request->getParam('contentMarkdown'));
         $item->setContentHtml($context_html);
     }
     $item->setFullPath($this->_request->getParam('path'));
     if ($this->_request->getParam('parentId') !== 0) {
         $parentCategory = $this->_modelMapper->find($this->_request->getParam('parentId'), new Oil_Model_OilCategories());
         if (!is_null($parentCategory)) {
             $item->setFullPath($parentCategory->getFullPath() . '/' . $this->_request->getParam('path'));
         }
     }
     $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()
 {
     $pageItem = $this->_itemMapper->findByFullPath($this->_request->getParam('fullPath'), new Oil_Model_Oil());
     if (is_null($pageItem)) {
         throw new Zend_Controller_Action_Exception("Страница не найдена", 404);
     }
     $this->getJson($pageItem);
     $this->setParamsDataItem($pageItem);
     $this->checkDeleted($pageItem);
     $category = $this->_categoriesMapper->find($pageItem->getCategoryId(), new Oil_Model_OilCategories());
     $this->setMetaHead($pageItem);
     $this->view->assign(array('category' => $category, 'title' => $pageItem->getTitle(), 'pageItem' => $pageItem));
     $this->checkActive($pageItem);
 }