Пример #1
0
 /**
  * Edit an existing news article
  *
  * @return void
  */
 public function editAction()
 {
     $this->view->currentPage = 'news';
     if ($this->getRequest()->isPost()) {
         // Save changes
         $this->_saveNewsArticle();
     }
     $newsID = $this->getRequest()->getParam('id');
     $news = new Datasource_Cms_News();
     $article = $news->getArticle($newsID);
     $newsDate = new Zend_Date($article['date']);
     $this->view->newsTitle = $article['title'];
     $this->view->newsContent = $article['content'];
     $this->view->newsID = $newsID;
     $this->view->newsDate = $newsDate->toString('dd/MM/YYYY');
     $this->view->selectedCategories = $article['categoryList'];
     $newsCategories = new Datasource_Cms_News_Categories();
     $newsCategoriesArray = $newsCategories->getAll();
     $selectedCategoryArray = explode(',', $article['categoryList']);
     foreach ($newsCategoriesArray as &$category) {
         if (in_array($category['categoryID'], $selectedCategoryArray)) {
             $category['selected'] = true;
         } else {
             $category['selected'] = false;
         }
     }
     $this->view->categoryList = $this->view->partialLoop('/partials/news-category.phtml', $newsCategoriesArray);
     $passThrough = $this->_helper->getHelper('FlashMessenger')->getMessages();
     if (count($passThrough) > 0) {
         if (isset($passThrough[0]['saved'])) {
             if ($passThrough[0]['saved'] == true) {
                 $this->view->saved = true;
             }
         }
         if (isset($passThrough[0]['errorMessage'])) {
             $this->view->errorMessage = $passThrough[0]['errorMessage'];
         }
     }
 }
Пример #2
0
 /**
  * Show a specific news article
  *
  * @return void
  */
 public function articleAction()
 {
     $articleID = $this->getRequest()->getParam('articleID');
     $news = new Datasource_Cms_News();
     $article = $news->getArticle($articleID);
     $content = $article['content'];
     // Replace code snippets in the content
     $snippets = new Application_Cms_PageSnippets();
     $content = $snippets->replace($content);
     $this->view->pageTitle = htmlentities(html_entity_decode($article['title'], ENT_QUOTES, 'UTF-8'), ENT_QUOTES, 'UTF-8');
     $this->view->content = $content;
     $this->view->title = $article['title'];
     $this->view->summary = $article['summary'];
     $this->view->date = $article['niceDate'];
     $this->view->category = 'corporate';
     $this->view->articleId = intval($articleID);
 }