00001 <?php
00002
00015
00016
00017
00018 class GatewayHandler extends Handler {
00019
00020 function index() {
00021 Request::redirect(null, 'index');
00022 }
00023
00024 function lockss() {
00025 parent::validate();
00026
00027 $journal = &Request::getJournal();
00028 $templateMgr = &TemplateManager::getManager();
00029
00030 if ($journal != null) {
00031 if (!$journal->getSetting('enableLockss')) {
00032 Request::redirect(null, 'index');
00033 }
00034
00035 $year = Request::getUserVar('year');
00036
00037 $issueDao = &DAORegistry::getDAO('IssueDAO');
00038
00039
00040 if (isset($year)) {
00041 $year = (int)$year;
00042 $result = &$issueDao->retrieve(
00043 'SELECT * FROM issues WHERE journal_id = ? AND year = ? AND published = 1 ORDER BY current DESC, year ASC, volume ASC, number ASC',
00044 array($journal->getJournalId(), $year)
00045 );
00046 if ($result->RecordCount() == 0) {
00047 unset($year);
00048 }
00049 }
00050
00051 if (!isset($year)) {
00052 $showInfo = true;
00053 $result = &$issueDao->retrieve(
00054 'SELECT MAX(year) FROM issues WHERE journal_id = ? AND published = 1',
00055 $journal->getJournalId()
00056 );
00057 list($year) = $result->fields;
00058 $result = &$issueDao->retrieve(
00059 'SELECT * FROM issues WHERE journal_id = ? AND year = ? AND published = 1 ORDER BY current DESC, year ASC, volume ASC, number ASC',
00060 array($journal->getJournalId(), $year)
00061 );
00062 } else {
00063 $showInfo = false;
00064 }
00065
00066 $issues = &new DAOResultFactory($result, $issueDao, '_returnIssueFromRow');
00067
00068 $prevYear = null;
00069 $nextYear = null;
00070 if (isset($year)) {
00071 $result = &$issueDao->retrieve(
00072 'SELECT MAX(year) FROM issues WHERE journal_id = ? AND published = 1 AND year < ?',
00073 array($journal->getJournalId(), $year)
00074 );
00075 list($prevYear) = $result->fields;
00076
00077 $result = &$issueDao->retrieve(
00078 'SELECT MIN(year) FROM issues WHERE journal_id = ? AND published = 1 AND year > ?',
00079 array($journal->getJournalId(), $year)
00080 );
00081 list($nextYear) = $result->fields;
00082 }
00083
00084 $templateMgr->assign_by_ref('journal', $journal);
00085 $templateMgr->assign_by_ref('issues', $issues);
00086 $templateMgr->assign('year', $year);
00087 $templateMgr->assign('prevYear', $prevYear);
00088 $templateMgr->assign('nextYear', $nextYear);
00089 $templateMgr->assign('showInfo', $showInfo);
00090
00091 $locales =& $journal->getSupportedLocaleNames();
00092 if (!isset($locales) || empty($locales)) {
00093 $localeNames = &Locale::getAllLocales();
00094 $primaryLocale = Locale::getPrimaryLocale();
00095 $locales = array($primaryLocale => $localeNames[$primaryLocale]);
00096 }
00097 $templateMgr->assign_by_ref('locales', $locales);
00098
00099 } else {
00100 $journalDao = &DAORegistry::getDAO('JournalDAO');
00101 $journals = &$journalDao->getEnabledJournals();
00102 $templateMgr->assign_by_ref('journals', $journals);
00103 }
00104
00105 $templateMgr->display('gateway/lockss.tpl');
00106 }
00107
00111 function plugin($args) {
00112 parent::validate();
00113 $pluginName = array_shift($args);
00114
00115 $plugins =& PluginRegistry::loadCategory('gateways');
00116 if (isset($pluginName) && isset($plugins[$pluginName])) {
00117 $plugin =& $plugins[$pluginName];
00118 if (!$plugin->fetch($args)) {
00119 Request::redirect(null, 'index');
00120 }
00121 }
00122 else Request::redirect(null, 'index');
00123 }
00124 }
00125
00126 ?>