00001 <?php
00002
00016
00017
00018
00019 import('classes.plugins.GatewayPlugin');
00020
00021 class WebFeedGatewayPlugin extends GatewayPlugin {
00027 function getName() {
00028 return 'WebFeedGatewayPlugin';
00029 }
00030
00031 function getDisplayName() {
00032 return Locale::translate('plugins.generic.webfeed.displayName');
00033 }
00034
00035 function getDescription() {
00036 return Locale::translate('plugins.generic.webfeed.description');
00037 }
00038
00043 function &getWebFeedPlugin() {
00044 $plugin =& PluginRegistry::getPlugin('generic', 'WebFeedPlugin');
00045 return $plugin;
00046 }
00047
00051 function getPluginPath() {
00052 $plugin =& $this->getWebFeedPlugin();
00053 return $plugin->getPluginPath();
00054 }
00055
00060 function getTemplatePath() {
00061 $plugin =& $this->getWebFeedPlugin();
00062 return $plugin->getTemplatePath() . 'templates/';
00063 }
00064
00068 function fetch($args) {
00069
00070 $journal =& Request::getJournal();
00071 if (!$journal) return false;
00072
00073
00074 $issueDao =& DAORegistry::getDAO('IssueDAO');
00075 $issue =& $issueDao->getCurrentIssue($journal->getJournalId());
00076 if (!$issue) return false;
00077
00078 $webFeedPlugin =& $this->getWebFeedPlugin();
00079 if (!$webFeedPlugin->getEnabled()) return false;
00080
00081
00082 $type = array_shift($args);
00083 $typeMap = array(
00084 'rss' => 'rss.tpl',
00085 'rss2' => 'rss2.tpl',
00086 'atom' => 'atom.tpl'
00087 );
00088 $mimeTypeMap = array(
00089 'rss' => 'application/rdf+xml',
00090 'rss2' => 'application/rss+xml',
00091 'atom' => 'application/atom+xml'
00092 );
00093 if (!isset($typeMap[$type])) return false;
00094
00095
00096 $displayItems = $webFeedPlugin->getSetting($journal->getJournalId(), 'displayItems');
00097 $recentItems = (int) $webFeedPlugin->getSetting($journal->getJournalId(), 'recentItems');
00098
00099 $publishedArticleDao =& DAORegistry::getDAO('PublishedArticleDAO');
00100 if ($displayItems == 'recent' && $recentItems > 0) {
00101 import('db.DBResultRange');
00102 $rangeInfo =& new DBResultRange($recentItems, 1);
00103 $publishedArticleObjects =& $publishedArticleDao->getPublishedArticlesByJournalId($journal->getJournalId(), $rangeInfo);
00104 while ($publishedArticle =& $publishedArticleObjects->next()) {
00105 $publishedArticles[]['articles'][] = &$publishedArticle;
00106 unset($publishedArticle);
00107 }
00108 } else {
00109 $publishedArticles = &$publishedArticleDao->getPublishedArticlesInSections($issue->getIssueId());
00110 }
00111
00112 $versionDao =& DAORegistry::getDAO('VersionDAO');
00113 $version =& $versionDao->getCurrentVersion();
00114
00115 $templateMgr = &TemplateManager::getManager();
00116 $templateMgr->assign('ojsVersion', $version->getVersionString());
00117 $templateMgr->assign_by_ref('publishedArticles', $publishedArticles);
00118 $templateMgr->assign_by_ref('journal', $journal);
00119 $templateMgr->assign_by_ref('issue', $issue);
00120 $templateMgr->assign('showToc', true);
00121
00122 $templateMgr->display($this->getTemplatePath() . $typeMap[$type], $mimeTypeMap[$type]);
00123
00124 return true;
00125 }
00126 }
00127
00128 ?>