plugins/generic/announcementFeed/AnnouncementFeedGatewayPlugin.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00017 import('classes.plugins.GatewayPlugin');
00018 
00019 class AnnouncementFeedGatewayPlugin extends GatewayPlugin {
00023    function getHideManagement() {
00024       return true;
00025    }
00026 
00032    function getName() {
00033       return 'AnnouncementFeedGatewayPlugin';
00034    }
00035 
00036    function getDisplayName() {
00037       return __('plugins.generic.announcementfeed.displayName');
00038    }
00039 
00040    function getDescription() {
00041       return __('plugins.generic.announcementfeed.description');
00042    }
00043 
00048    function &getAnnouncementFeedPlugin() {
00049       $plugin =& PluginRegistry::getPlugin('generic', 'AnnouncementFeedPlugin');
00050       return $plugin;
00051    }
00052 
00056    function getPluginPath() {
00057       $plugin =& $this->getAnnouncementFeedPlugin();
00058       return $plugin->getPluginPath();
00059    }
00060 
00065    function getTemplatePath() {
00066       $plugin =& $this->getAnnouncementFeedPlugin();
00067       return $plugin->getTemplatePath() . 'templates/';
00068    }
00069 
00073    function fetch($args) {
00074       // Make sure we're within a Conference context
00075       $conference =& Request::getConference();
00076       $schedConf =& Request::getSchedConf();
00077       if (!$conference) return false;
00078 
00079       // Make sure announcements and plugin are enabled
00080       $announcementsEnabled = $conference->getSetting('enableAnnouncements');
00081       $announcementFeedPlugin =& $this->getAnnouncementFeedPlugin();
00082       if (!$announcementsEnabled || !$announcementFeedPlugin->getEnabled()) return false;
00083 
00084       // Make sure the feed type is specified and valid
00085       $type = array_shift($args);
00086       $typeMap = array(
00087          'rss' => 'rss.tpl',
00088          'rss2' => 'rss2.tpl',
00089          'atom' => 'atom.tpl'
00090       );
00091       $mimeTypeMap = array(
00092          'rss' => 'application/rdf+xml',
00093          'rss2' => 'application/rss+xml',
00094          'atom' => 'application/atom+xml'
00095       );
00096       if (!isset($typeMap[$type])) return false;
00097 
00098       // Get limit setting, if any 
00099       $limitRecentItems = $announcementFeedPlugin->getSetting($conference->getId(), 0, 'limitRecentItems');
00100       $recentItems = (int) $announcementFeedPlugin->getSetting($conference->getId(), 0, 'recentItems');
00101 
00102       $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
00103       $conferenceId = $conference->getId();
00104       if ($schedConf) {
00105          $schedConfId = $schedConf->getId();
00106       } else {
00107          $schedConfId = 0;
00108       }
00109       if ($limitRecentItems && $recentItems > 0) {
00110          import('db.DBResultRange');
00111          $rangeInfo = new DBResultRange($recentItems, 1);
00112          $announcements =& $announcementDao->getAnnouncementsNotExpiredByConferenceId($conferenceId, $schedConfId, $rangeInfo);
00113       } else {
00114          $announcements =& $announcementDao->getAnnouncementsNotExpiredByConferenceId($conferenceId, $schedConfId);
00115       }
00116 
00117       // Get date of most recent announcement
00118       $lastDateUpdated = $announcementFeedPlugin->getSetting($conference->getId(), $schedConfId, 'dateUpdated');
00119       if ($announcements->wasEmpty()) {
00120          if (empty($lastDateUpdated)) { 
00121             $dateUpdated = Core::getCurrentDate(); 
00122             $announcementFeedPlugin->updateSetting($conference->getId(), $schedConfId, 'dateUpdated', $dateUpdated, 'string');         
00123          } else {
00124             $dateUpdated = $lastDateUpdated;
00125          }
00126       } else {
00127          $mostRecentAnnouncement =& $announcementDao->getMostRecentAnnouncementByConferenceId($conferenceId, $schedConfId);
00128          $dateUpdated = $mostRecentAnnouncement->getDatetimePosted();
00129          if (empty($lastDateUpdated) || (strtotime($dateUpdated) > strtotime($lastDateUpdated))) { 
00130             $announcementFeedPlugin->updateSetting($conference->getId(), $schedConfId, 'dateUpdated', $dateUpdated, 'string');         
00131          }
00132       }
00133 
00134       $versionDao =& DAORegistry::getDAO('VersionDAO');
00135       $version =& $versionDao->getCurrentVersion();
00136 
00137       $templateMgr =& TemplateManager::getManager();
00138       $templateMgr->assign('selfUrl', Request::getCompleteUrl()); 
00139       $templateMgr->assign('dateUpdated', $dateUpdated);
00140       $templateMgr->assign('ocsVersion', $version->getVersionString());
00141       $templateMgr->assign_by_ref('announcements', $announcements->toArray());
00142       $templateMgr->assign_by_ref('conference', $conference);
00143       $templateMgr->assign_by_ref('schedConf', $schedConf);
00144 
00145       $templateMgr->display($this->getTemplatePath() . $typeMap[$type], $mimeTypeMap[$type]);
00146 
00147       return true;
00148    }
00149 }
00150 
00151 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7