Example #1
0
 function editnewsAction()
 {
     if ($this->isLoggedIn() == 0) {
         $this->_redirect('/admin/index');
     }
     $this->view->langId = $this->_request->getParam('langId');
     $this->view->newsId = $this->_request->getParam('newsId');
     $fitnessNews = new FitnessNews();
     $fitnessNewsMulti = new FitnessNewsMultilang();
     $fitnessCategoryMulti = new FitnessNewsCategoryMultilang();
     $defaultLang = $this->getDefaultLanguage();
     $this->view->newcategoryList = $fitnessCategoryMulti->getAllcategory($defaultLang);
     $newsData = array();
     $newsMultilangData = array();
     $newsmultiArray = array();
     $this->view->fitnessMultiNewsData = $fitnessNewsMulti->getNews($this->_request->getParam('newsId'), $this->_request->getParam('langId'));
     $this->view->fitnessNewsData = $fitnessNews->getNews($this->_request->getParam('newsId'));
     if ($this->_request->isPost()) {
         $newsMultilangData['news_id'] = $this->_request->getPost('newsId');
         $newsMultilangData['news_title'] = $this->_request->getPost('news_title');
         $newsMultilangData['news_content'] = $this->_request->getPost('news');
         $newsData['news_category'] = $this->_request->getPost('category');
         $newsData['news_date'] = $this->_request->getPost('news_date');
         $checkRecords = $fitnessNewsMulti->getLangRecord($this->_request->getPost('newsId'), $this->_request->getPost('langId'));
         $fitnessNews->update($newsData, array('id = ?' => $this->_request->getPost('newsId')));
         if ($checkRecords['count'] > 0) {
             $fitnessNewsMulti->update($newsMultilangData, array('news_id = ?' => $this->_request->getPost('newsId'), 'lang = ?' => $this->_request->getPost('langId')));
         } else {
             $newsmultiArray['news_id'] = $this->_request->getPost('newsId');
             $newsMultilangData['news_title'] = $this->_request->getPost('news_title');
             $newsmultiArray['news_content'] = $this->_request->getPost('news');
             $newsmultiArray['lang_id'] = $this->_request->getPost('langId');
             $fitnessNewsMulti->addData($newsmultiArray);
         }
         $this->_redirect('/admin/listnews');
     }
 }
Example #2
0
 /**
  * function that displays the news template
  * @author lekha
  * @date 8/21/2012
  * 
  */
 public function newsAction()
 {
     $this->_helper->layout()->setLayout('layout_news');
     $this->view->loginStatus = $this->isLoggedIn();
     $fitnessPages = new FitnessWebsitePages();
     $fitnessPagesMulti = new FitnessWebsitePagesMultilang();
     $fitnessNews = new FitnessNews();
     $fitnessNewsMulti = new FitnessNewsMultilang();
     $lang = $this->getDefaultLanguage();
     if ($this->_request->getParam('category') != "") {
         $category = $this->_request->getParam('category');
         $getNews = $fitnessNews->getNewsByCategory($category);
         foreach ($getNews as $catN) {
             $newsCatList[] = $fitnessNewsMulti->getNews($catN['id'], $lang);
         }
         $this->view->newsList = $newsCatList;
     } else {
         if ($this->_request->getParam('date') != "") {
             $getNews = $fitnessNews->getNewsByDate($this->_request->getParam('date'));
             foreach ($getNews as $catN) {
                 $newsCatList[] = $fitnessNewsMulti->getNews($catN['id'], $lang);
             }
             $this->view->newsList = $newsCatList;
         } else {
             $this->view->newsList = $fitnessNewsMulti->getAllInterests($lang);
         }
     }
     //get the date range()
     $dateFirst = date('Y-m-d');
     $dateSecond = date('Y-m-d', strtotime('-2 month'));
     $this->view->dateRange = $this->get_months($dateSecond, $dateFirst);
     //get the news subtext
     $pageId = $fitnessPages->getPageByName('News');
     $pageContent = $fitnessPagesMulti->getPage($pageId['page_id'], $lang);
     $this->view->newsSub = $pageContent['page_content_sub'];
     $this->view->newsSub = $pageContent['page_content_sub'];
     $this->view->defaultLang = $lang;
 }