00001 <?php
00002
00015
00016
00017
00018 import('rt.ojs.JournalRTAdmin');
00019
00020 class RTContextHandler extends RTAdminHandler {
00021 function createContext($args) {
00022 RTAdminHandler::validate();
00023
00024 $journal = Request::getJournal();
00025
00026 $rtDao = &DAORegistry::getDAO('RTDAO');
00027 $versionId = isset($args[0])?$args[0]:0;
00028 $version = &$rtDao->getVersion($versionId, $journal->getJournalId());
00029
00030 import('rt.ojs.form.ContextForm');
00031 $contextForm = &new ContextForm(null, $versionId);
00032
00033 if (isset($args[1]) && $args[1]=='save') {
00034 $contextForm->readInputData();
00035 $contextForm->execute();
00036 Request::redirect(null, null, 'contexts', $versionId);
00037 } else {
00038 RTAdminHandler::setupTemplate(true, $version);
00039 $contextForm->display();
00040 }
00041 }
00042
00043 function contexts($args) {
00044 RTAdminHandler::validate();
00045
00046 $journal = Request::getJournal();
00047
00048 $rtDao = &DAORegistry::getDAO('RTDAO');
00049 $rangeInfo = Handler::getRangeInfo('contexts');
00050
00051 $versionId = isset($args[0])?$args[0]:0;
00052 $version = &$rtDao->getVersion($versionId, $journal->getJournalId());
00053
00054 if ($version) {
00055 RTAdminHandler::setupTemplate(true, $version);
00056
00057 $templateMgr = &TemplateManager::getManager();
00058
00059 $templateMgr->assign_by_ref('version', $version);
00060
00061 $templateMgr->assign_by_ref('contexts', new ArrayItemIterator($version->getContexts(), $rangeInfo->getPage(), $rangeInfo->getCount()));
00062
00063 $templateMgr->assign('helpTopicId', 'journal.managementPages.readingTools.contexts');
00064 $templateMgr->display('rtadmin/contexts.tpl');
00065 }
00066 else Request::redirect(null, null, 'versions');
00067 }
00068
00069 function editContext($args) {
00070 RTAdminHandler::validate();
00071
00072 $rtDao = &DAORegistry::getDAO('RTDAO');
00073
00074 $journal = Request::getJournal();
00075 $versionId = isset($args[0])?$args[0]:0;
00076 $version = &$rtDao->getVersion($versionId, $journal->getJournalId());
00077 $contextId = isset($args[1])?$args[1]:0;
00078 $context = &$rtDao->getContext($contextId);
00079
00080 if (isset($version) && isset($context) && $context->getVersionId() == $version->getVersionId()) {
00081 import('rt.ojs.form.ContextForm');
00082 RTAdminHandler::setupTemplate(true, $version, $context);
00083 $contextForm = &new ContextForm($contextId, $versionId);
00084 $contextForm->initData();
00085 $contextForm->display();
00086 }
00087 else Request::redirect(null, null, 'contexts', $versionId);
00088
00089
00090 }
00091
00092 function deleteContext($args) {
00093 RTAdminHandler::validate();
00094
00095 $rtDao = &DAORegistry::getDAO('RTDAO');
00096
00097 $journal = Request::getJournal();
00098 $versionId = isset($args[0])?$args[0]:0;
00099 $version = &$rtDao->getVersion($versionId, $journal->getJournalId());
00100 $contextId = isset($args[1])?$args[1]:0;
00101 $context = &$rtDao->getContext($contextId);
00102
00103 if (isset($version) && isset($context) && $context->getVersionId() == $version->getVersionId()) {
00104 $rtDao->deleteContext($contextId, $versionId);
00105 }
00106
00107 Request::redirect(null, null, 'contexts', $versionId);
00108 }
00109
00110 function saveContext($args) {
00111 RTAdminHandler::validate();
00112
00113 $rtDao = &DAORegistry::getDAO('RTDAO');
00114
00115 $journal = Request::getJournal();
00116 $versionId = isset($args[0])?$args[0]:0;
00117 $version = &$rtDao->getVersion($versionId, $journal->getJournalId());
00118 $contextId = isset($args[1])?$args[1]:0;
00119 $context = &$rtDao->getContext($contextId);
00120
00121 if (isset($version) && isset($context) && $context->getVersionId() == $version->getVersionId()) {
00122 import('rt.ojs.form.ContextForm');
00123 $contextForm = &new ContextForm($contextId, $versionId);
00124 $contextForm->readInputData();
00125 $contextForm->execute();
00126 }
00127
00128 Request::redirect(null, null, 'contexts', $versionId);
00129 }
00130
00131 function moveContext($args) {
00132 RTAdminHandler::validate();
00133
00134 $rtDao = &DAORegistry::getDAO('RTDAO');
00135
00136 $journal = Request::getJournal();
00137 $versionId = isset($args[0])?$args[0]:0;
00138 $version = &$rtDao->getVersion($versionId, $journal->getJournalId());
00139 $contextId = isset($args[1])?$args[1]:0;
00140 $context = &$rtDao->getContext($contextId);
00141
00142 if (isset($version) && isset($context) && $context->getVersionId() == $version->getVersionId()) {
00143 $isDown = Request::getUserVar('dir')=='d';
00144 $context->setOrder($context->getOrder()+($isDown?1.5:-1.5));
00145 $rtDao->updateContext($context);
00146 $rtDao->resequenceContexts($version->getVersionId());
00147 }
00148
00149 Request::redirect(null, null, 'contexts', $versionId);
00150 }
00151 }
00152
00153 ?>