classes/install/form/UpgradeForm.inc.php

Go to the documentation of this file.
00001 <?php
00002 
00015 //$Id$
00016 
00017 import('install.Upgrade');
00018 import('form.Form');
00019 
00020 class UpgradeForm extends Form {
00021 
00025    function UpgradeForm() {
00026       parent::Form('install/upgrade.tpl');
00027       $this->addCheck(new FormValidatorPost($this));
00028    }
00029 
00033    function display() {
00034       $templateMgr =& TemplateManager::getManager();
00035       $templateMgr->assign_by_ref('version', VersionCheck::getCurrentCodeVersion());
00036 
00037       parent::display();
00038    }
00039 
00043    function execute() {
00044       $templateMgr =& TemplateManager::getManager();
00045       $installer = new Upgrade($this->_data);
00046 
00047       // FIXME Use logger?
00048 
00049       // FIXME Mostly common with InstallForm
00050 
00051       if ($installer->execute()) {
00052          if (!$installer->wroteConfig()) {
00053             // Display config file contents for manual replacement
00054             $templateMgr->assign(array('writeConfigFailed' => true, 'configFileContents' => $installer->getConfigContents()));
00055          }
00056 
00057          $templateMgr->assign('notes', $installer->getNotes());
00058          $templateMgr->assign_by_ref('newVersion', $installer->getNewVersion());
00059          $templateMgr->display('install/upgradeComplete.tpl');
00060 
00061       } else {
00062          switch ($installer->getErrorType()) {
00063             case INSTALLER_ERROR_DB:
00064                $this->dbInstallError($installer->getErrorMsg());
00065                break;
00066             default:
00067                $this->installError($installer->getErrorMsg());
00068                break;
00069          }
00070       }
00071 
00072       $installer->destroy();
00073    }
00074 
00075    // FIXME Common with InstallForm
00076 
00081    function installError($errorMsg) {
00082       $templateMgr =& TemplateManager::getManager();
00083       $templateMgr->assign(array('isInstallError' => true, 'errorMsg' => $errorMsg));
00084       $this->display();
00085    }
00086 
00091    function dbInstallError($errorMsg) {
00092       $templateMgr =& TemplateManager::getManager();
00093       $templateMgr->assign(array('isInstallError' => true, 'dbErrorMsg' => empty($errorMsg) ? __('common.error.databaseErrorUnknown') : $errorMsg));
00094       $this->display();
00095    }
00096 
00097 }
00098 
00099 ?>

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