00001 <?php
00002
00015
00016
00017 import('pages.manager.ManagerHandler');
00018
00019 class SchedConfSetupHandler extends ManagerHandler {
00023 function SchedConfSetupHandler() {
00024 parent::ManagerHandler();
00025 }
00026
00032 function schedConfSetup($args) {
00033 $this->validate();
00034 $this->setupTemplate(true);
00035
00036 $step = isset($args[0]) ? (int) $args[0] : 0;
00037
00038 if ($step >= 1 && $step <= 3) {
00039
00040 $formClass = "SchedConfSetupStep{$step}Form";
00041 import("manager.form.schedConfSetup.$formClass");
00042
00043 $setupForm = new $formClass();
00044 if ($setupForm->isLocaleResubmit()) {
00045 $setupForm->readInputData();
00046 } else {
00047 $setupForm->initData();
00048 }
00049 $setupForm->display();
00050
00051 } else {
00052 $templateMgr =& TemplateManager::getManager();
00053 $templateMgr->assign('helpTopicId','conference.currentConferences.setup');
00054 $templateMgr->display('manager/schedConfSetup/index.tpl');
00055 }
00056 }
00057
00062 function saveSchedConfSetup($args) {
00063 $this->validate();
00064
00065 $step = isset($args[0]) ? (int) $args[0] : 0;
00066
00067 if ($step >= 1 && $step <= 3) {
00068
00069 $this->setupTemplate(true);
00070
00071 $formClass = "SchedConfSetupStep{$step}Form";
00072 import("manager.form.schedConfSetup.$formClass");
00073
00074 $setupForm = new $formClass();
00075 $setupForm->readInputData();
00076 $formLocale = $setupForm->getFormLocale();
00077
00078
00079 switch ($step) {
00080 case 1:
00081 if (Request::getUserVar('addSponsor')) {
00082
00083 $editData = true;
00084 $sponsors = $setupForm->getData('sponsors');
00085 array_push($sponsors, array());
00086 $setupForm->setData('sponsors', $sponsors);
00087
00088 } else if (($delSponsor = Request::getUserVar('delSponsor')) && count($delSponsor) == 1) {
00089
00090 $editData = true;
00091 list($delSponsor) = array_keys($delSponsor);
00092 $delSponsor = (int) $delSponsor;
00093 $sponsors = $setupForm->getData('sponsors');
00094 array_splice($sponsors, $delSponsor, 1);
00095 $setupForm->setData('sponsors', $sponsors);
00096
00097 } else if (Request::getUserVar('addContributor')) {
00098
00099 $editData = true;
00100 $contributors = $setupForm->getData('contributors');
00101 array_push($contributors, array());
00102 $setupForm->setData('contributors', $contributors);
00103
00104 } else if (($delContributor = Request::getUserVar('delContributor')) && count($delContributor) == 1) {
00105
00106 $editData = true;
00107 list($delContributor) = array_keys($delContributor);
00108 $delContributor = (int) $delContributor;
00109 $contributors = $setupForm->getData('contributors');
00110 array_splice($contributors, $delContributor, 1);
00111 $setupForm->setData('contributors', $contributors);
00112 }
00113 break;
00114 case 2:
00115 if ($action = Request::getUserVar('paperTypeAction')) {
00116 $editData = true;
00117 $setupForm->readInputData();
00118 $paperTypeId = Request::getUserVar('paperTypeId');
00119 switch ($action) {
00120 case 'movePaperTypeUp':
00121 case 'movePaperTypeDown':
00122 if (isset($setupForm->_data['paperTypes'][$paperTypeId]['seq'])) $setupForm->_data['paperTypes'][$paperTypeId]['seq'] += ($action == 'movePaperTypeUp'?-1.5:1.5);
00123 uasort($setupForm->_data['paperTypes'], 'seqSortFunction');
00124 break;
00125 case 'deletePaperType':
00126 unset($setupForm->_data['paperTypes'][$paperTypeId]);
00127 break;
00128 case 'createPaperType':
00129 $setupForm->_data['paperTypes']['a' . count($setupForm->_data['paperTypes'])] = array();
00130 break;
00131 }
00132 } elseif (Request::getUserVar('addChecklist')) {
00133
00134 $editData = true;
00135 $checklist = $setupForm->getData('submissionChecklist');
00136 if (!isset($checklist[$formLocale]) || !is_array($checklist[$formLocale])) {
00137 $checklist[$formLocale] = array();
00138 $lastOrder = 0;
00139 } else {
00140 $lastOrder = $checklist[$formLocale][count($checklist[$formLocale])-1]['order'];
00141 }
00142 array_push($checklist[$formLocale], array('order' => $lastOrder+1));
00143 $setupForm->setData('submissionChecklist', $checklist);
00144
00145 } else if (($delChecklist = Request::getUserVar('delChecklist')) && count($delChecklist) == 1) {
00146
00147 $editData = true;
00148 list($delChecklist) = array_keys($delChecklist);
00149 $delChecklist = (int) $delChecklist;
00150 $checklist = $setupForm->getData('submissionChecklist');
00151 if (!isset($checklist[$formLocale])) $checklist[$formLocale] = array();
00152 array_splice($checklist[$formLocale], $delChecklist, 1);
00153 $setupForm->setData('submissionChecklist', $checklist);
00154 }
00155
00156 if (!isset($editData)) {
00157
00158 $checklist = $setupForm->getData('submissionChecklist');
00159 if (isset($checklist[$formLocale]) && is_array($checklist[$formLocale])) {
00160 usort($checklist[$formLocale], create_function('$a,$b','return $a[\'order\'] == $b[\'order\'] ? 0 : ($a[\'order\'] < $b[\'order\'] ? -1 : 1);'));
00161 }
00162 $setupForm->setData('submissionChecklist', $checklist);
00163 }
00164 break;
00165 }
00166
00167 if (!isset($editData) && $setupForm->validate()) {
00168 $setupForm->execute();
00169 Request::redirect(null, null, null, 'schedConfSetupSaved', $step);
00170 } else {
00171 $setupForm->display();
00172 }
00173
00174 } else {
00175 Request::redirect();
00176 }
00177 }
00178
00182 function schedConfSetupSaved($args) {
00183 $this->validate();
00184
00185 $step = isset($args[0]) ? (int) $args[0] : 0;
00186
00187 if ($step >= 1 && $step <= 3) {
00188 $this->setupTemplate(true);
00189 $templateMgr =& TemplateManager::getManager();
00190 $templateMgr->assign('setupStep', $step);
00191 $templateMgr->assign('helpTopicId', 'conference.currentConferences.setup');
00192 if ($step == 3) $templateMgr->assign('showSetupHints',true);
00193 $templateMgr->display('manager/schedConfSetup/settingsSaved.tpl');
00194 }
00195 }
00196 }
00197
00198 function seqSortFunction($a, $b) {
00199 return 2*($a['seq'] - $b['seq']);
00200 }
00201
00202 ?>