Пример #1
0
 public function treatAction()
 {
     $categoryMapper = new CategoryMapper();
     if ($this->getRequest()->getParam('id')) {
         $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($this->getTranslator()->trans('menuCats'), array('action' => 'index'))->add($this->getTranslator()->trans('edit'), array('action' => 'treat'));
         $this->getView()->set('cat', $categoryMapper->getCategoryById($this->getRequest()->getParam('id')));
     } else {
         $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($this->getTranslator()->trans('menuCats'), array('action' => 'index'))->add($this->getTranslator()->trans('add'), array('action' => 'treat'));
     }
     if ($this->getRequest()->isPost()) {
         $model = new CategoryModel();
         if ($this->getRequest()->getParam('id')) {
             $model->setId($this->getRequest()->getParam('id'));
         }
         $title = trim($this->getRequest()->getPost('title'));
         if (empty($title)) {
             $this->addMessage('missingTitle', 'danger');
         } else {
             $model->setTitle($title);
             $categoryMapper->save($model);
             $this->addMessage('saveSuccess');
             $this->redirect(array('action' => 'index'));
         }
     }
 }
Пример #2
0
 public function showAction()
 {
     $categoryMapper = new CategoryMapper();
     $faqMapper = new FaqMapper();
     $faq = $faqMapper->getFaqById($this->getRequest()->getParam('id'));
     $category = $categoryMapper->getCategoryById($faq->getCatId());
     $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($category->getTitle(), array('action' => 'index', 'catId' => $category->getId()))->add($faq->getQuestion(), array('action' => 'show', 'id' => $faq->getId()));
     $this->getView()->set('faq', $faqMapper->getFaqById($this->getRequest()->getParam('id')));
 }