4 * @file PKPAnnouncementHandler.inc.php
6 * Copyright (c) 2000-2009 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
9 * @class PKPAnnouncementHandler
10 * @ingroup pages_announcement
12 * @brief Handle requests for public announcement functions.
15 import('handler.Handler');
17 class PKPAnnouncementHandler
extends Handler
{
20 * Display announcement index page.
24 $this->setupTemplate();
26 if ($this->_getAnnouncementsEnabled()) {
27 $announcementDao =& DAORegistry
::getDAO('AnnouncementDAO');
28 $rangeInfo =& Handler
::getRangeInfo('announcements');
30 $announcements =& $this->_getAnnouncements($rangeInfo);
31 $announcementsIntroduction = $this->_getAnnouncementsIntroduction();
33 $templateMgr =& TemplateManager
::getManager();
34 $templateMgr->assign('announcements', $announcements);
35 $templateMgr->assign('announcementsIntroduction', $announcementsIntroduction);
36 $templateMgr->display('announcement/index.tpl');
44 * View announcement details.
45 * @param $args array optional, first parameter is the ID of the announcement to display
47 function view($args = array()) {
49 $this->setupTemplate();
51 $announcementId = !isset($args) ||
empty($args) ?
null : (int) $args[0];
52 $announcementDao =& DAORegistry
::getDAO('AnnouncementDAO');
54 if ($this->_getAnnouncementsEnabled() && $this->_announcementIsValid($announcementId)) {
55 $announcement =& $announcementDao->getAnnouncement($announcementId);
57 if ($announcement->getDateExpire() == null ||
strtotime($announcement->getDateExpire()) > time()) {
58 $templateMgr =& TemplateManager
::getManager();
59 $templateMgr->assign('announcement', $announcement);
60 if ($announcement->getTypeId() == null) {
61 $templateMgr->assign('announcementTitle', $announcement->getLocalizedTitle());
63 $templateMgr->assign('announcementTitle', $announcement->getAnnouncementTypeName() . ": " . $announcement->getLocalizedTitle());
65 $templateMgr->append('pageHierarchy', array(PKPRequest
::url(null, 'announcement'), 'announcement.announcements'));
66 $templateMgr->display('announcement/view.tpl');
68 Request
::redirect(null, null, 'announcement');
71 Request
::redirect(null, null, 'announcement');
76 * Setup common template variables.
77 * @param $subclass boolean set to true if caller is below this handler in the hierarchy
79 function setupTemplate($subclass = false) {
80 parent
::setupTemplate();
82 $templateMgr =& TemplateManager
::getManager();
83 $templateMgr->setCacheability(CACHEABILITY_PUBLIC
);
84 $templateMgr->assign('pageHierachy', array(array(Request
::url(null, null, 'announcements'), 'announcement.announcements')));
87 function _getAnnouncementsEnabled() {
88 fatalError('Abstract Method');
91 function &_getAnnouncements($rangeInfo = null) {
92 fatalError('Abstract Method');
95 function _getAnnouncementsIntroduction() {
96 fatalError('Abstract Method');
99 function _announcementIsValid($announcementId) {
100 fatalError('Abstract Method');