/**
  * Handle fetch requests for this plugin.
  */
 function fetch($args)
 {
     // Make sure we're within a Journal context
     $journal =& Request::getJournal();
     if (!$journal) {
         return false;
     }
     // Make sure thesis abstracts and feed plugin are enabled
     $application =& PKPApplication::getApplication();
     $products = $application->getEnabledProducts('plugins.generic');
     $thesisEnabled = $products['thesis'];
     $thesisFeedPlugin =& $this->getThesisFeedPlugin();
     $thesisFeedPluginEnabled = $thesisFeedPlugin->getEnabled();
     if (!$thesisEnabled || !$thesisFeedPluginEnabled) {
         return false;
     }
     // Make sure the feed type is specified and valid
     $type = array_shift($args);
     $typeMap = array('rss' => 'rss.tpl', 'rss2' => 'rss2.tpl', 'atom' => 'atom.tpl');
     $mimeTypeMap = array('rss' => 'application/rdf+xml', 'rss2' => 'application/rss+xml', 'atom' => 'application/atom+xml');
     if (!isset($typeMap[$type])) {
         return false;
     }
     // Get limit setting, if any
     $limitRecentItems = $thesisFeedPlugin->getSetting($journal->getId(), 'limitRecentItems');
     $recentItems = (int) $thesisFeedPlugin->getSetting($journal->getId(), 'recentItems');
     $thesisDao =& DAORegistry::getDAO('ThesisDAO');
     $journalId = $journal->getId();
     if ($limitRecentItems && $recentItems > 0) {
         import('lib.pkp.classes.db.DBResultRange');
         $rangeInfo = new DBResultRange($recentItems, 1);
         $theses =& $thesisDao->getActiveThesesByJournalId($journalId, null, null, null, null, null, null, $rangeInfo);
     } else {
         $theses =& $thesisDao->getActiveThesesByJournalId($journalId);
     }
     // Get date of most recent thesis
     $lastDateUpdated = $thesisFeedPlugin->getSetting($journal->getId(), 'dateUpdated');
     if ($theses->wasEmpty()) {
         if (empty($lastDateUpdated)) {
             $dateUpdated = Core::getCurrentDate();
             $thesisFeedPlugin->updateSetting($journal->getId(), 'dateUpdated', $dateUpdated, 'string');
         } else {
             $dateUpdated = $lastDateUpdated;
         }
     } else {
         $mostRecentThesis =& $thesisDao->getMostRecentActiveThesisByJournalId($journalId);
         $dateUpdated = $mostRecentThesis->getDateSubmitted();
         if (empty($lastDateUpdated) || strtotime($dateUpdated) > strtotime($lastDateUpdated)) {
             $thesisFeedPlugin->updateSetting($journal->getId(), 'dateUpdated', $dateUpdated, 'string');
         }
     }
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $version =& $versionDao->getCurrentVersion();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('ojsVersion', $version->getVersionString());
     $templateMgr->assign('selfUrl', Request::getCompleteUrl());
     $templateMgr->assign('dateUpdated', $dateUpdated);
     $templateMgr->assign_by_ref('theses', $theses->toArray());
     $templateMgr->assign_by_ref('journal', $journal);
     $templateMgr->display($this->getTemplatePath() . $typeMap[$type], $mimeTypeMap[$type]);
     return true;
 }
 /**
  * Handle fetch requests for this plugin.
  */
 function fetch($args)
 {
     // Make sure we're within a Journal context
     $journal =& Request::getJournal();
     if (!$journal) {
         return false;
     }
     // Make sure announcements and plugin are enabled
     $announcementsEnabled = $journal->getSetting('enableAnnouncements');
     $announcementFeedPlugin =& $this->getAnnouncementFeedPlugin();
     if (!$announcementsEnabled || !$announcementFeedPlugin->getEnabled()) {
         return false;
     }
     // Make sure the feed type is specified and valid
     $type = array_shift($args);
     $typeMap = array('rss' => 'rss.tpl', 'rss2' => 'rss2.tpl', 'atom' => 'atom.tpl');
     $mimeTypeMap = array('rss' => 'application/rdf+xml', 'rss2' => 'application/rss+xml', 'atom' => 'application/atom+xml');
     if (!isset($typeMap[$type])) {
         return false;
     }
     // Get limit setting, if any
     $limitRecentItems = $announcementFeedPlugin->getSetting($journal->getJournalId(), 'limitRecentItems');
     $recentItems = (int) $announcementFeedPlugin->getSetting($journal->getJournalId(), 'recentItems');
     $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
     $journalId = $journal->getJournalId();
     if ($limitRecentItems && $recentItems > 0) {
         import('db.DBResultRange');
         $rangeInfo =& new DBResultRange($recentItems, 1);
         $announcements =& $announcementDao->getAnnouncementsNotExpiredByJournalId($journalId, $rangeInfo);
     } else {
         $announcements =& $announcementDao->getAnnouncementsNotExpiredByJournalId($journalId);
     }
     // Get date of most recent announcement
     $lastDateUpdated = $announcementFeedPlugin->getSetting($journal->getJournalId(), 'dateUpdated');
     if ($announcements->wasEmpty()) {
         if (empty($lastDateUpdated)) {
             $dateUpdated = Core::getCurrentDate();
             $announcementFeedPlugin->updateSetting($journal->getJournalId(), 'dateUpdated', $dateUpdated, 'string');
         } else {
             $dateUpdated = $lastDateUpdated;
         }
     } else {
         $mostRecentAnnouncement =& $announcementDao->getMostRecentAnnouncementByJournalId($journalId);
         $dateUpdated = $mostRecentAnnouncement->getDatetimePosted();
         if (empty($lastDateUpdated) || strtotime($dateUpdated) > strtotime($lastDateUpdated)) {
             $announcementFeedPlugin->updateSetting($journal->getJournalId(), 'dateUpdated', $dateUpdated, 'string');
         }
     }
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('selfUrl', Request::getCompleteUrl());
     $templateMgr->assign('dateUpdated', $dateUpdated);
     $templateMgr->assign_by_ref('announcements', $announcements->toArray());
     $templateMgr->assign_by_ref('journal', $journal);
     $templateMgr->display($this->getTemplatePath() . $typeMap[$type], $mimeTypeMap[$type]);
     return true;
 }
 /**
  * Fetch the actual RSS feed
  */
 function notificationFeed($args)
 {
     if (isset($args[0]) && isset($args[1])) {
         $type = $args[0];
         $token = $args[1];
     } else {
         return false;
     }
     $this->setupTemplate(true);
     $application = PKPApplication::getApplication();
     $appName = $application->getNameKey();
     $site =& Request::getSite();
     $siteTitle = $site->getLocalizedTitle();
     $notificationDao =& DAORegistry::getDAO('NotificationDAO');
     $notificationSettingsDao =& DAORegistry::getDAO('NotificationSettingsDAO');
     $userId = $notificationSettingsDao->getUserIdByRSSToken($token);
     $notifications = $notificationDao->getByUserId($userId);
     // Make sure the feed type is specified and valid
     $typeMap = array('rss' => 'rss.tpl', 'rss2' => 'rss2.tpl', 'atom' => 'atom.tpl');
     $mimeTypeMap = array('rss' => 'application/rdf+xml', 'rss2' => 'application/rss+xml', 'atom' => 'application/atom+xml');
     if (!isset($typeMap[$type])) {
         return false;
     }
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $version = $versionDao->getCurrentVersion();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('version', $version->getVersionString());
     $templateMgr->assign('selfUrl', Request::getCompleteUrl());
     $templateMgr->assign('locale', AppLocale::getPrimaryLocale());
     $templateMgr->assign('appName', $appName);
     $templateMgr->assign('siteTitle', $siteTitle);
     $templateMgr->assign_by_ref('notifications', $notifications->toArray());
     $templateMgr->display(Core::getBaseDir() . DIRECTORY_SEPARATOR . 'lib' . DIRECTORY_SEPARATOR . 'pkp' . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR . 'notification' . DIRECTORY_SEPARATOR . $typeMap[$type], $mimeTypeMap[$type]);
     return true;
 }
 /**
  * Handle fetch requests for this plugin.
  */
 function fetch($args)
 {
     // Make sure we're within a Conference context
     $conference =& Request::getConference();
     $schedConf =& Request::getSchedConf();
     if (!$conference) {
         return false;
     }
     // Make sure announcements and plugin are enabled
     $announcementsEnabled = $conference->getSetting('enableAnnouncements');
     $announcementFeedPlugin =& $this->getAnnouncementFeedPlugin();
     if (!$announcementsEnabled || !$announcementFeedPlugin->getEnabled()) {
         return false;
     }
     // Make sure the feed type is specified and valid
     $type = array_shift($args);
     $typeMap = array('rss' => 'rss.tpl', 'rss2' => 'rss2.tpl', 'atom' => 'atom.tpl');
     $mimeTypeMap = array('rss' => 'application/rdf+xml', 'rss2' => 'application/rss+xml', 'atom' => 'application/atom+xml');
     if (!isset($typeMap[$type])) {
         return false;
     }
     // Get limit setting, if any
     $limitRecentItems = $announcementFeedPlugin->getSetting($conference->getId(), 0, 'limitRecentItems');
     $recentItems = (int) $announcementFeedPlugin->getSetting($conference->getId(), 0, 'recentItems');
     $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
     $conferenceId = $conference->getId();
     if ($schedConf) {
         $schedConfId = $schedConf->getId();
     } else {
         $schedConfId = 0;
     }
     if ($limitRecentItems && $recentItems > 0) {
         import('db.DBResultRange');
         $rangeInfo = new DBResultRange($recentItems, 1);
         $announcements =& $announcementDao->getAnnouncementsNotExpiredByConferenceId($conferenceId, $schedConfId, $rangeInfo);
     } else {
         $announcements =& $announcementDao->getAnnouncementsNotExpiredByConferenceId($conferenceId, $schedConfId);
     }
     // Get date of most recent announcement
     $lastDateUpdated = $announcementFeedPlugin->getSetting($conference->getId(), $schedConfId, 'dateUpdated');
     if ($announcements->wasEmpty()) {
         if (empty($lastDateUpdated)) {
             $dateUpdated = Core::getCurrentDate();
             $announcementFeedPlugin->updateSetting($conference->getId(), $schedConfId, 'dateUpdated', $dateUpdated, 'string');
         } else {
             $dateUpdated = $lastDateUpdated;
         }
     } else {
         $mostRecentAnnouncement =& $announcementDao->getMostRecentAnnouncementByAssocId(ASSOC_TYPE_SCHED_CONF, $schedConfId);
         $dateUpdated = $mostRecentAnnouncement->getDatetimePosted();
         if (empty($lastDateUpdated) || strtotime($dateUpdated) > strtotime($lastDateUpdated)) {
             $announcementFeedPlugin->updateSetting($conference->getId(), $schedConfId, 'dateUpdated', $dateUpdated, 'string');
         }
     }
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $version =& $versionDao->getCurrentVersion();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('selfUrl', Request::getCompleteUrl());
     $templateMgr->assign('dateUpdated', $dateUpdated);
     $templateMgr->assign('ocsVersion', $version->getVersionString());
     $templateMgr->assign_by_ref('announcements', $announcements->toArray());
     $templateMgr->assign_by_ref('conference', $conference);
     $templateMgr->assign_by_ref('schedConf', $schedConf);
     $templateMgr->display($this->getTemplatePath() . $typeMap[$type], $mimeTypeMap[$type]);
     return true;
 }
Example #5
0
 /**
  * Get the HTML contents for this block.
  * @param $templateMgr object
  * @return $string
  */
 function getContents(&$templateMgr)
 {
     // Make sure we're within a Journal context
     $journal =& Request::getJournal();
     if (!$journal) {
         return false;
     }
     // Make sure announcements and plugin are enabled
     //$announcementsEnabled = $journal->getSetting('enableAnnouncements');
     $announcementBlockPlugin =& $this;
     //if (!$announcementsEnabled || !$announcementBlockPlugin->getEnabled()) return false;
     // Make sure the block type is specified and valid
     /*		
     $type = array_shift($args);
     $typeMap = array(
     	        'rss' => 'rss.tpl',
     	        'rss2' => 'rss2.tpl',
     	        'atom' => 'atom.tpl'
     );
     $mimeTypeMap = array(
     	        'rss' => 'application/rdf+xml',
     	        'rss2' => 'application/rss+xml',
     	        'atom' => 'application/atom+xml'
     );
     if (!isset($typeMap[$type])) return false;
     */
     // Get limit setting, if any
     // $limitRecentItems = $announcementBlockPlugin->getSetting($journal->getId(), 'limitRecentItems');
     // $recentItems = (int) $announcementBlockPlugin->getSetting($journal->getId(), 'recentItems');
     $limitRecentItems = true;
     $recentItems = 5;
     $announcementDao =& DAORegistry::getDAO('AnnouncementDAO');
     $journalId = $journal->getId();
     if ($limitRecentItems && $recentItems > 0) {
         import('lib.pkp.classes.db.DBResultRange');
         $rangeInfo = new DBResultRange($recentItems, 1);
         $announcements =& $announcementDao->getAnnouncementsNotExpiredByAssocId(ASSOC_TYPE_JOURNAL, $journalId, $rangeInfo);
     } else {
         $announcements =& $announcementDao->getAnnouncementsNotExpiredByAssocId(ASSOC_TYPE_JOURNAL, $journalId);
     }
     // Get date of most recent announcement
     // $lastDateUpdated = $announcementBlockPlugin->getSetting($journal->getId(), 'dateUpdated');
     $lastDateUpdated = '';
     if ($announcements->wasEmpty()) {
         if (empty($lastDateUpdated)) {
             $dateUpdated = Core::getCurrentDate();
             $announcementBlockPlugin->updateSetting($journal->getId(), 'dateUpdated', $dateUpdated, 'string');
         } else {
             $dateUpdated = $lastDateUpdated;
         }
     } else {
         $mostRecentAnnouncement =& $announcementDao->getMostRecentAnnouncementByAssocId(ASSOC_TYPE_JOURNAL, $journalId);
         $dateUpdated = $mostRecentAnnouncement->getDatetimePosted();
         if (empty($lastDateUpdated) || strtotime($dateUpdated) > strtotime($lastDateUpdated)) {
             $announcementBlockPlugin->updateSetting($journal->getId(), 'dateUpdated', $dateUpdated, 'string');
         }
     }
     $versionDao =& DAORegistry::getDAO('VersionDAO');
     $version =& $versionDao->getCurrentVersion();
     $templateMgr =& TemplateManager::getManager();
     $templateMgr->assign('ojsVersion', $version->getVersionString());
     $templateMgr->assign('selfUrl', Request::getCompleteUrl());
     $templateMgr->assign('dateUpdated', $dateUpdated);
     $templateMgr->assign_by_ref('news', $announcements->toArray());
     $templateMgr->assign_by_ref('journal', $journal);
     return parent::getContents($templateMgr);
 }
 /**
  * Constructor.
  * Initialize template engine and assign basic template variables.
  */
 function TemplateManager()
 {
     parent::Smarty();
     import('file.PublicFileManager');
     import('cache.CacheManager');
     // Set up Smarty configuration
     $baseDir = Core::getBaseDir();
     $cachePath = CacheManager::getFileCachePath();
     $this->template_dir = $baseDir . DIRECTORY_SEPARATOR . 'templates';
     $this->compile_dir = $cachePath . DIRECTORY_SEPARATOR . 't_compile';
     $this->config_dir = $cachePath . DIRECTORY_SEPARATOR . 't_config';
     $this->cache_dir = $cachePath . DIRECTORY_SEPARATOR . 't_cache';
     // Assign common variables
     $this->styleSheets = array();
     $this->assign_by_ref('stylesheets', $this->styleSheets);
     $this->cacheability = CACHEABILITY_NO_STORE;
     // Safe default
     $this->assign('defaultCharset', Config::getVar('i18n', 'client_charset'));
     $this->assign('baseUrl', Request::getBaseUrl());
     $this->assign('pageTitle', 'common.openJournalSystems');
     $this->assign('requestedPage', Request::getRequestedPage());
     $this->assign('currentUrl', Request::getCompleteUrl());
     $this->assign('dateFormatTrunc', Config::getVar('general', 'date_format_trunc'));
     $this->assign('dateFormatShort', Config::getVar('general', 'date_format_short'));
     $this->assign('dateFormatLong', Config::getVar('general', 'date_format_long'));
     $this->assign('datetimeFormatShort', Config::getVar('general', 'datetime_format_short'));
     $this->assign('datetimeFormatLong', Config::getVar('general', 'datetime_format_long'));
     // Are we using implicit authentication?
     $this->assign('implicitAuth', Config::getVar('security', 'implicit_auth'));
     $locale = Locale::getLocale();
     $this->assign('currentLocale', $locale);
     if (!defined('SESSION_DISABLE_INIT')) {
         /* Kludge to make sure no code that tries to connect to the database is executed
          * (e.g., when loading installer pages). */
         $this->assign('isUserLoggedIn', Validation::isLoggedIn());
         $journal =& Request::getJournal();
         $site =& Request::getSite();
         $versionDAO =& DAORegistry::getDAO('VersionDAO');
         $currentVersion = $versionDAO->getCurrentVersion();
         $this->assign('currentVersionString', $currentVersion->getVersionString());
         $siteFilesDir = Request::getBaseUrl() . '/' . PublicFileManager::getSiteFilesPath();
         $this->assign('sitePublicFilesDir', $siteFilesDir);
         $this->assign('publicFilesDir', $siteFilesDir);
         // May be overridden by journal
         $siteStyleFilename = PublicFileManager::getSiteFilesPath() . '/' . $site->getSiteStyleFilename();
         if (file_exists($siteStyleFilename)) {
             $this->addStyleSheet(Request::getBaseUrl() . '/' . $siteStyleFilename);
         }
         if (isset($journal)) {
             $this->assign_by_ref('currentJournal', $journal);
             $journalTitle = $journal->getJournalTitle();
             $this->assign('siteTitle', $journalTitle);
             $this->assign('publicFilesDir', Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId()));
             $this->assign('primaryLocale', $journal->getPrimaryLocale());
             $this->assign('alternateLocales', $journal->getSetting('alternateLocales'));
             // Assign additional navigation bar items
             $navMenuItems =& $journal->getLocalizedSetting('navItems');
             $this->assign_by_ref('navMenuItems', $navMenuItems);
             // Assign journal page header
             $this->assign('displayPageHeaderTitle', $journal->getJournalPageHeaderTitle());
             $this->assign('displayPageHeaderLogo', $journal->getJournalPageHeaderLogo());
             $this->assign('alternatePageHeader', $journal->getLocalizedSetting('journalPageHeader'));
             $this->assign('metaSearchDescription', $journal->getLocalizedSetting('searchDescription'));
             $this->assign('metaSearchKeywords', $journal->getLocalizedSetting('searchKeywords'));
             $this->assign('metaCustomHeaders', $journal->getLocalizedSetting('customHeaders'));
             $this->assign('numPageLinks', $journal->getSetting('numPageLinks'));
             $this->assign('itemsPerPage', $journal->getSetting('itemsPerPage'));
             $this->assign('enableAnnouncements', $journal->getSetting('enableAnnouncements'));
             // Load and apply theme plugin, if chosen
             $themePluginPath = $journal->getSetting('journalTheme');
             if (!empty($themePluginPath)) {
                 // Load and activate the theme
                 $themePlugin =& PluginRegistry::loadPlugin('themes', $themePluginPath);
                 if ($themePlugin) {
                     $themePlugin->activate($this);
                 }
             }
             // Assign stylesheets and footer
             $journalStyleSheet = $journal->getSetting('journalStyleSheet');
             if ($journalStyleSheet) {
                 $this->addStyleSheet(Request::getBaseUrl() . '/' . PublicFileManager::getJournalFilesPath($journal->getJournalId()) . '/' . $journalStyleSheet['uploadName']);
             }
             import('payment.ojs.OJSPaymentManager');
             $paymentManager =& OJSPaymentManager::getManager();
             $this->assign('journalPaymentsEnabled', $paymentManager->isConfigured());
             $this->assign('pageFooter', $journal->getLocalizedSetting('journalPageFooter'));
         } else {
             // Add the site-wide logo, if set for this locale or the primary locale
             $this->assign('displayPageHeaderTitle', $site->getSitePageHeaderTitle());
             $this->assign('siteTitle', $site->getSiteTitle());
             $this->assign('itemsPerPage', Config::getVar('interface', 'items_per_page'));
             $this->assign('numPageLinks', Config::getVar('interface', 'page_links'));
         }
         if (!$site->getJournalRedirect()) {
             $this->assign('hasOtherJournals', true);
         }
     }
     // If there's a locale-specific stylesheet, add it.
     if (($localeStyleSheet = Locale::getLocaleStyleSheet($locale)) != null) {
         $this->addStyleSheet(Request::getBaseUrl() . '/' . $localeStyleSheet);
     }
     // Register custom functions
     $this->register_modifier('translate', array('Locale', 'translate'));
     $this->register_modifier('strip_unsafe_html', array('String', 'stripUnsafeHtml'));
     $this->register_modifier('String_substr', array('String', 'substr'));
     $this->register_modifier('to_array', array(&$this, 'smartyToArray'));
     $this->register_modifier('escape', array(&$this, 'smartyEscape'));
     $this->register_modifier('explode', array(&$this, 'smartyExplode'));
     $this->register_modifier('assign', array(&$this, 'smartyAssign'));
     $this->register_function('translate', array(&$this, 'smartyTranslate'));
     $this->register_function('flush', array(&$this, 'smartyFlush'));
     $this->register_function('call_hook', array(&$this, 'smartyCallHook'));
     $this->register_function('html_options_translate', array(&$this, 'smartyHtmlOptionsTranslate'));
     $this->register_block('iterate', array(&$this, 'smartyIterate'));
     $this->register_function('call_progress_function', array(&$this, 'smartyCallProgressFunction'));
     $this->register_function('page_links', array(&$this, 'smartyPageLinks'));
     $this->register_function('page_info', array(&$this, 'smartyPageInfo'));
     $this->register_function('get_help_id', array(&$this, 'smartyGetHelpId'));
     $this->register_function('icon', array(&$this, 'smartyIcon'));
     $this->register_function('help_topic', array(&$this, 'smartyHelpTopic'));
     $this->register_function('get_debug_info', array(&$this, 'smartyGetDebugInfo'));
     $this->register_function('assign_mailto', array(&$this, 'smartyAssignMailto'));
     $this->register_function('display_template', array(&$this, 'smartyDisplayTemplate'));
     $this->register_function('url', array(&$this, 'smartyUrl'));
     $this->initialized = false;
 }