pages/manager/ManagerSetupHandler.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('pages.manager.ManagerHandler');
00018 
00019 class ManagerSetupHandler extends ManagerHandler {
00023    function ManagerSetupHandler() {
00024       parent::ManagerHandler();
00025    }
00026 
00032    function setup($args) {
00033       $this->validate();
00034       $this->setupTemplate(true);
00035 
00036       $step = isset($args[0]) ? (int) $args[0] : 0;
00037 
00038       if ($step >= 1 && $step <= 6) {
00039 
00040          $formClass = "ConferenceSetupStep{$step}Form";
00041          import("manager.form.setup.$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.generalManagement.websiteManagement');
00054          $templateMgr->display('manager/setup/index.tpl');
00055       }
00056    }
00057 
00062    function saveSetup($args) {
00063       $this->validate();
00064 
00065       $step = isset($args[0]) ? (int) $args[0] : 0;
00066 
00067       if ($step >= 1 && $step <= 6) {
00068 
00069          $this->setupTemplate(true);
00070 
00071          $formClass = "ConferenceSetupStep{$step}Form";
00072          import("manager.form.setup.$formClass");
00073 
00074          $setupForm = new $formClass();
00075          $setupForm->readInputData();
00076          $formLocale = $setupForm->getFormLocale();
00077 
00078          // Check for any special cases before trying to save
00079          switch ($step) {
00080             case 1:
00081                if (Request::getUserVar('addCustomAboutItem')) {
00082                   // Add a custom about item
00083                   $editData = true;
00084                   $customAboutItems = $setupForm->getData('customAboutItems');
00085                   $customAboutItems[$formLocale][] = array();
00086                   $setupForm->setData('customAboutItems', $customAboutItems);
00087 
00088                } else if (($delCustomAboutItem = Request::getUserVar('delCustomAboutItem')) && count($delCustomAboutItem) == 1) {
00089                   // Delete a custom about item
00090                   $editData = true;
00091                   list($delCustomAboutItem) = array_keys($delCustomAboutItem);
00092                   $delCustomAboutItem = (int) $delCustomAboutItem;
00093                   $customAboutItems = $setupForm->getData('customAboutItems');
00094                   if (!isset($customAboutItems[$formLocale])) $customAboutItems[$formLocale][] = array();
00095                   array_splice($customAboutItems[$formLocale], $delCustomAboutItem, 1);
00096                   $setupForm->setData('customAboutItems', $customAboutItems);
00097                }
00098                break;
00099             case 2:
00100                if (Request::getUserVar('uploadHomepageImage')) {
00101                   if ($setupForm->uploadImage('homepageImage', $formLocale)) {
00102                      $editData = true;
00103                   } else {
00104                      $setupForm->addError('homepageImage', __('manager.setup.homepageImageInvalid'));
00105                   }
00106 
00107                } else if (Request::getUserVar('deleteHomepageImage')) {
00108                   $editData = true;
00109                   $setupForm->deleteImage('homepageImage', $formLocale);
00110                }
00111                break;
00112             case 3:  
00113                if (Request::getUserVar('uploadHomeHeaderTitleImage')) {
00114                   if ($setupForm->uploadImage('homeHeaderTitleImage', $formLocale)) {
00115                      $editData = true;
00116                   } else {
00117                      $setupForm->addError('homeHeaderTitleImage', __('manager.setup.homeTitleImageInvalid'));
00118                   }
00119 
00120                } else if (Request::getUserVar('deleteHomeHeaderTitleImage')) {
00121                   $editData = true;
00122                   $setupForm->deleteImage('homeHeaderTitleImage', $formLocale);
00123 
00124                } else if (Request::getUserVar('uploadHomeHeaderLogoImage')) {
00125                   if ($setupForm->uploadImage('homeHeaderLogoImage', $formLocale)) {
00126                      $editData = true;
00127                   } else {
00128                      $setupForm->addError('homeHeaderLogoImage', __('manager.setup.homeHeaderImageInvalid'));
00129                   }
00130 
00131                } else if (Request::getUserVar('deleteHomeHeaderLogoImage')) {
00132                   $editData = true;
00133                   $setupForm->deleteImage('homeHeaderLogoImage', $formLocale);
00134 
00135                } else if (Request::getUserVar('uploadConferenceFavicon')) {
00136                   if ($setupForm->uploadImage('conferenceFavicon', $formLocale)) {
00137                      $editData = true;
00138                   } else {
00139                      $setupForm->addError('conferenceFavicon', __('manager.setup.layout.faviconInvalid'));
00140                   }
00141 
00142                } else if (Request::getUserVar('deleteConferenceFavicon')) {
00143                   $editData = true;
00144                   $setupForm->deleteImage('conferenceFavicon', $formLocale);
00145 
00146                } else if (Request::getUserVar('uploadPageHeaderTitleImage')) {
00147                   if ($setupForm->uploadImage('pageHeaderTitleImage', $formLocale)) {
00148                      $editData = true;
00149                   } else {
00150                      $setupForm->addError('pageHeaderTitleImage', __('manager.setup.pageHeaderTitleImageInvalid'));
00151                   }
00152 
00153                } else if (Request::getUserVar('deletePageHeaderTitleImage')) {
00154                   $editData = true;
00155                   $setupForm->deleteImage('pageHeaderTitleImage', $formLocale);
00156 
00157                } else if (Request::getUserVar('uploadPageHeaderLogoImage')) {
00158                   if ($setupForm->uploadImage('pageHeaderLogoImage', $formLocale)) {
00159                      $editData = true;
00160                   } else {
00161                      $setupForm->addError('pageHeaderLogoImage', __('manager.setup.pageHeaderLogoImageInvalid'));
00162                   }
00163 
00164                } else if (Request::getUserVar('deletePageHeaderLogoImage')) {
00165                   $editData = true;
00166                   $setupForm->deleteImage('pageHeaderLogoImage', $formLocale);
00167 
00168                } else if (Request::getUserVar('addNavItem')) {
00169                   // Add a navigation bar item
00170                   $editData = true;
00171                   $navItems = $setupForm->getData('navItems');
00172                   $navItems[$formLocale][] = array();
00173                   $setupForm->setData('navItems', $navItems);
00174 
00175                } else if (($delNavItem = Request::getUserVar('delNavItem')) && count($delNavItem) == 1) {
00176                   // Delete a  navigation bar item
00177                   $editData = true;
00178                   list($delNavItem) = array_keys($delNavItem);
00179                   $delNavItem = (int) $delNavItem;
00180                   $navItems = $setupForm->getData('navItems');
00181                   if (is_array($navItems) && is_array($navItems[$formLocale])) {
00182                      array_splice($navItems[$formLocale], $delNavItem, 1);
00183                      $setupForm->setData('navItems', $navItems);
00184                   }
00185                }
00186                break;
00187             case '4':
00188                if (Request::getUserVar('uploadConferenceStyleSheet')) {
00189                   if ($setupForm->uploadStyleSheet('conferenceStyleSheet')) {
00190                      $editData = true;
00191                   } else {
00192                      $setupForm->addError('conferenceStyleSheet', __('manager.setup.conferenceStyleSheetInvalid'));
00193                   }
00194                } else if (Request::getUserVar('deleteConferenceStyleSheet')) {
00195                   $editData = true;
00196                   $setupForm->deleteImage('conferenceStyleSheet');
00197                }
00198                break;
00199          }
00200 
00201          if (!isset($editData) && $setupForm->validate()) {
00202             $setupForm->execute();
00203             Request::redirect(null, null, null, 'setupSaved', $step);
00204          } else {
00205             $setupForm->display();
00206          }
00207 
00208       } else {
00209          Request::redirect();
00210       }
00211    }
00212 
00216    function setupSaved($args) {
00217       $this->validate();
00218 
00219       $step = isset($args[0]) ? (int) $args[0] : 0;
00220 
00221       if ($step >= 1 && $step <= 6) {
00222          $this->setupTemplate(true);
00223          $templateMgr =& TemplateManager::getManager();
00224          $templateMgr->assign('setupStep', $step);
00225          $templateMgr->assign('helpTopicId', 'conference.generalManagement.websiteManagement');
00226 
00227          if($step == 6) {
00228             $conference =& Request::getConference();
00229             $templateMgr->assign('showSetupHints',true);
00230          }
00231          $templateMgr->display('manager/setup/settingsSaved.tpl');
00232       } else {
00233          Request::redirect(null, null, 'index');
00234       }
00235    }
00236 }
00237 
00238 ?>

Generated on 25 Jul 2013 for Open Conference Systems by  doxygen 1.4.7