Пример #1
0
 public function indexAction()
 {
     $news = new News_Model_News();
     $this->view->article = $news->getRowInstance($this->_getParam('id'));
     if ($this->view->article->date > date('Y-m-d H:i:s') && $this->user->role != Users_Model_User::ROLE_ADMIN) {
         throw new Monkeys_AccessDeniedException();
     }
     $this->_helper->actionStack('index', 'login', 'users');
 }
Пример #2
0
 public function deleteAction()
 {
     $news = new News_Model_News();
     if (!($article = $news->getRowInstance($this->_getParam('id')))) {
         $this->_helper->FlashMessenger->addMessage($this->view->translate('The article doesn\'t exist.'));
     } else {
         $article->delete();
         $this->_helper->FlashMessenger->addMessage($this->view->translate('The article has been deleted.'));
     }
     $this->_redirect('/news');
 }
Пример #3
0
 public function indexAction()
 {
     $scriptsDir = $this->view->getScriptPaths();
     $locale = Zend_Registry::get('Zend_Locale');
     // render() changes _ to -
     $locale = str_replace('_', '-', $locale);
     $localeElements = explode('-', $locale);
     $view = false;
     foreach ($scriptsDir as $scriptDir) {
         if (file_exists($scriptDir . "index/subheader-{$locale}.phtml")) {
             $view = "subheader-{$locale}";
             break;
         } else {
             if (count($localeElements == 2) && file_exists($scriptDir . "index/subheader-" . $localeElements[0] . ".phtml")) {
                 $view = 'subheader-' . $localeElements[0];
                 break;
             }
         }
     }
     if (!$view) {
         $view = 'subheader-en';
     }
     $this->getResponse()->insert('subHeader', $this->view->render("index/{$view}.phtml"));
     $this->_helper->actionStack('index', 'login', 'users');
     $news = new News_Model_News();
     $this->view->news = $news->getLatest(self::NEWS_NUMBER, $this->user);
     $view = false;
     foreach ($scriptsDir as $scriptDir) {
         if (file_exists($scriptDir . "index/index-{$locale}.phtml")) {
             $view = "index-{$locale}";
             break;
         } else {
             if (count($localeElements == 2) && file_exists($scriptDir . "index/index-" . $localeElements[0] . ".phtml")) {
                 $view = 'index-' . $localeElements[0];
                 break;
             }
         }
     }
     if (!$view) {
         $view = 'index-en';
     }
     $this->render($view);
 }
Пример #4
0
 public function showAction()
 {
     $newsModel = new News_Model_News();
     $channel = $newsModel->getChannelInfo($this->_request->getParam('docid'), $this->_request->getParam('ctxid'), 20);
     $baseUrl = "http://{$_SERVER['HTTP_HOST']}";
     //		$baseUrl = $this->_request->baseUrl;
     //		$tempbook = $books->current();
     //		$pubDate = $tempbook->date_entered;
     $feedArray = array('title' => $channel->info['TITLE'], 'link' => "{$baseUrl}{$_SERVER['REQUEST_URI']}", 'description' => $channel->info['DESCRIPTION'], 'language' => $channel->info['LANGUAGE'], 'charset' => 'utf-8', 'published' => $channel->info['CREATEDATE'], 'entries' => array());
     foreach ($channel->news as $item) {
         $feedArray['entries'][] = array('title' => $item['TITLE'], 'link' => $item['URL'] ? $baseUrl . $item['URL'] : '', 'description' => $item['DESCRIPTION'], 'lastUpdate' => $item['NEWSDATE']);
     }
     $feed = Zend_Feed::importArray($feedArray, 'rss');
     // Not needed - see comments
     foreach ($feed as $entry) {
         $element = $entry->summary->getDOM();
     }
     $feed->send();
     exit;
 }
Пример #5
0
 public function indexAction()
 {
     $envConf = Zend_Registry::get('environmentSettings');
     $req = $this->getRequest();
     $id = $req->getParam('id');
     $title = $req->getParam('title');
     $this->view->news = false;
     $this->view->paginator = false;
     $this->view->writeForm = new News_Form_Comment('#');
     if ($id) {
         $this->view->news = News_Model_News::getNewsById($id);
     } else {
         if ($title) {
             $this->view->news = News_Model_News::getNewsBySlug(urldecode($title));
         }
     }
     if ($this->view->news) {
         $paginator = $this->view->news->getCommentPaginator(false, true);
         $page = $req->getParam('page');
         $paginator->setItemCountPerPage($this->conf->news->comments->numpage);
         $paginator->setCurrentPageNumber($page);
         $this->view->paginator = $paginator;
     }
     if ($req->isPost() && $this->view->news) {
         if ($this->view->writeForm->isValid($_POST)) {
             $values = $this->view->writeForm->getValues();
             $nc = new News_Model_Comment();
             $nc->ip = getenv('REMOTE_ADDR');
             $nc->email = User_Model_User::isLoggedIn() ? Zend_Auth::getInstance()->getIdentity()->email : $values['email'];
             $nc->news_id = $this->view->news->id;
             $nc->visible = 'yes';
             // there is no moderation yet
             $nc->author = User_Model_User::isLoggedIn() ? Zend_Auth::getInstance()->getIdentity()->name : $values['author'];
             $nc->url = $values['url'];
             $nc->comment = $values['comment'];
             $nc->checkSpam();
             $nc->save();
             $this->view->writeForm = new News_Form_Comment('#');
             // clear form because comment is submitted
         }
     }
 }
Пример #6
0
 public function indexAction()
 {
     $news = new News_Model_News();
     $this->view->paginator = $news->getArticlesPaginator(News_Model_News::RECORDS_PER_PAGE, $this->_getParam('page', 0), $this->user);
     $this->_helper->actionStack('index', 'login', 'users');
 }
Пример #7
0
 public function previewAction()
 {
     $id = $this->getRequest()->getParam('id');
     $n = News_Model_News::getNewsById($id);
     if (!$n) {
         $this->session->message = $this->translate('news_not_existent');
         $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'admin', 'module' => 'news'), 'news');
     }
     $this->_helper->redirector->gotoRoute(array('action' => 'index', 'controller' => 'comment', 'module' => 'news', 'title' => $n->title_slug), 'news_new_perma');
 }
 public function showAction()
 {
     $newsModel = new News_Model_News();
     $this->view->assign('channel', $newsModel->getChannelInfo($this->_request->channel, $this->view->docid));
 }