00001 <?php
00002
00015
00016
00017
00018 class SectionHandler extends ManagerHandler {
00019
00023 function sections() {
00024 parent::validate();
00025 parent::setupTemplate(true);
00026
00027 $journal = &Request::getJournal();
00028 $rangeInfo = &Handler::getRangeInfo('sections');
00029 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00030 $sections = &$sectionDao->getJournalSections($journal->getJournalId(), $rangeInfo);
00031
00032 $templateMgr = &TemplateManager::getManager();
00033 $templateMgr->assign('pageHierarchy', array(array(Request::url(null, 'manager'), 'manager.journalManagement')));
00034 $templateMgr->assign_by_ref('sections', $sections);
00035 $templateMgr->assign('helpTopicId','journal.managementPages.sections');
00036 $templateMgr->display('manager/sections/sections.tpl');
00037 }
00038
00042 function createSection() {
00043 SectionHandler::editSection();
00044 }
00045
00050 function editSection($args = array()) {
00051 parent::validate();
00052 parent::setupTemplate(true);
00053
00054 import('manager.form.SectionForm');
00055
00056 $sectionForm = &new SectionForm(!isset($args) || empty($args) ? null : ((int) $args[0]));
00057 if ($sectionForm->isLocaleResubmit()) {
00058 $sectionForm->readInputData();
00059 } else {
00060 $sectionForm->initData();
00061 }
00062 $sectionForm->display();
00063 }
00064
00068 function updateSection($args) {
00069 parent::validate();
00070
00071 import('manager.form.SectionForm');
00072 $sectionForm = &new SectionForm(!isset($args) || empty($args) ? null : ((int) $args[0]));
00073
00074 switch (Request::getUserVar('editorAction')) {
00075 case 'addSectionEditor':
00076 $sectionForm->includeSectionEditor((int) Request::getUserVar('userId'));
00077 $canExecute = false;
00078 break;
00079 case 'removeSectionEditor':
00080 $sectionForm->omitSectionEditor((int) Request::getUserVar('userId'));
00081 $canExecute = false;
00082 break;
00083 default:
00084 $canExecute = true;
00085 break;
00086 }
00087
00088 $sectionForm->readInputData();
00089 if ($canExecute && $sectionForm->validate()) {
00090 $sectionForm->execute();
00091 Request::redirect(null, null, 'sections');
00092
00093 } else {
00094 parent::setupTemplate(true);
00095 $sectionForm->display();
00096 }
00097 }
00098
00103 function deleteSection($args) {
00104 parent::validate();
00105
00106 if (isset($args) && !empty($args)) {
00107 $journal = &Request::getJournal();
00108
00109 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00110 $sectionDao->deleteSectionById($args[0], $journal->getJournalId());
00111 }
00112
00113 Request::redirect(null, null, 'sections');
00114 }
00115
00119 function moveSection() {
00120 parent::validate();
00121
00122 $journal = &Request::getJournal();
00123
00124 $sectionDao = &DAORegistry::getDAO('SectionDAO');
00125 $section = &$sectionDao->getSection(Request::getUserVar('sectionId'), $journal->getJournalId());
00126
00127 if ($section != null) {
00128 $section->setSequence($section->getSequence() + (Request::getUserVar('d') == 'u' ? -1.5 : 1.5));
00129 $sectionDao->updateSection($section);
00130 $sectionDao->resequenceSections($journal->getJournalId());
00131 }
00132
00133 Request::redirect(null, null, 'sections');
00134 }
00135
00136 }
00137 ?>