baseline
[omp.pkp.sfu.ca.git] / lib / pkp / pages / announcement / PKPAnnouncementHandler.inc.php
blob964a2ecd2b2c0bcbb9018c982a2c51807e65ad48
1 <?php
3 /**
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 {
19 /**
20 * Display announcement index page.
22 function index() {
23 $this->validate();
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');
37 } else {
38 Request::redirect();
43 /**
44 * View announcement details.
45 * @param $args array optional, first parameter is the ID of the announcement to display
47 function view($args = array()) {
48 $this->validate();
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());
62 } else {
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');
67 } else {
68 Request::redirect(null, null, 'announcement');
70 } else {
71 Request::redirect(null, null, 'announcement');
75 /**
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');