Esempio n. 1
0
 public function treatAction()
 {
     $categoryMapper = new CategoryMapper();
     $faqMapper = new FaqMapper();
     if ($this->getRequest()->getParam('id')) {
         $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($this->getTranslator()->trans('edit'), array('action' => 'treat'));
         $this->getView()->set('faq', $faqMapper->getFaqById($this->getRequest()->getParam('id')));
     } else {
         $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($this->getTranslator()->trans('add'), array('action' => 'treat'));
     }
     if ($this->getRequest()->isPost()) {
         $model = new FaqModel();
         if ($this->getRequest()->getParam('id')) {
             $model->setId($this->getRequest()->getParam('id'));
         }
         $question = $this->getRequest()->getPost('question');
         $answer = $this->getRequest()->getPost('answer');
         if (empty($question)) {
             $this->addMessage('missingQuestion', 'danger');
         } elseif (empty($answer)) {
             $this->addMessage('missingAnswer', 'danger');
         } else {
             $model->setQuestion($question);
             $model->setAnswer($answer);
             $model->setCatId($this->getRequest()->getPost('catId'));
             $faqMapper->save($model);
             $this->addMessage('saveSuccess');
             $this->redirect(array('action' => 'index'));
         }
     }
     $this->getView()->set('cats', $categoryMapper->getCategories());
 }
Esempio n. 2
0
 public function indexAction()
 {
     $categoryMapper = new CategoryMapper();
     $this->getLayout()->getAdminHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('controller' => 'index', 'action' => 'index'))->add($this->getTranslator()->trans('menuCats'), array('action' => 'index'));
     if ($this->getRequest()->getPost('action') === 'delete') {
         foreach ($this->getRequest()->getPost('check_cats') as $catId) {
             $categoryMapper->delete($catId);
         }
         $this->addMessage('deleteSuccess');
         $this->redirect(array('action' => 'index'));
     }
     $this->getView()->set('cats', $categoryMapper->getCategories());
 }
Esempio n. 3
0
 public function indexAction()
 {
     $categoryMapper = new CategoryMapper();
     $faqMapper = new FaqMapper();
     if ($this->getRequest()->getParam('catId')) {
         $category = $categoryMapper->getCategoryById($this->getRequest()->getParam('catId'));
         $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($category->getTitle(), array('action' => 'index', 'catId' => $category->getId()));
         $faqs = $faqMapper->getFaqs(array('cat_id' => $this->getRequest()->getParam('catId')));
     } else {
         $catId = $categoryMapper->getCategoryMinId();
         if ($catId != '') {
             $category = $categoryMapper->getCategoryById($catId->getId());
             $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'))->add($category->getTitle(), array('action' => 'index', 'catId' => $category->getId()));
             $faqs = $faqMapper->getFaqs(array('cat_id' => $catId->getId()));
             $this->getView()->set('firstCatId', $catId->getId());
         } else {
             $this->getLayout()->getHmenu()->add($this->getTranslator()->trans('menuFaqs'), array('action' => 'index'));
             $faqs = $faqMapper->getFaqs();
         }
     }
     $this->getView()->set('faqs', $faqs);
     $this->getView()->set('categorys', $categoryMapper->getCategories());
 }