00001 <?php
00002
00015
00016
00017
00018 import('install.Upgrade');
00019 import('form.Form');
00020
00021 class UpgradeForm extends Form {
00022
00026 function UpgradeForm() {
00027 parent::Form('install/upgrade.tpl');
00028 $this->addCheck(new FormValidatorPost($this));
00029 }
00030
00034 function display() {
00035 $templateMgr = &TemplateManager::getManager();
00036 $templateMgr->assign_by_ref('version', VersionCheck::getCurrentCodeVersion());
00037
00038 parent::display();
00039 }
00040
00044 function readInputData() {
00045 $this->readUserVars(array(
00046 'manualInstall'
00047 ));
00048 }
00049
00053 function execute() {
00054 $templateMgr = &TemplateManager::getManager();
00055 $installer = &new Upgrade($this->_data);
00056
00057
00058
00059
00060
00061 if ($installer->execute()) {
00062 if ($this->getData('manualInstall')) {
00063
00064 $templateMgr->assign(array('manualInstall' => true, 'installSql' => $installer->getSQL()));
00065
00066 }
00067 if (!$installer->wroteConfig()) {
00068
00069 $templateMgr->assign(array('writeConfigFailed' => true, 'configFileContents' => $installer->getConfigContents()));
00070 }
00071
00072 $templateMgr->assign('notes', $installer->getNotes());
00073 $templateMgr->assign_by_ref('newVersion', $installer->getNewVersion());
00074 $templateMgr->display('install/upgradeComplete.tpl');
00075
00076 } else {
00077 switch ($installer->getErrorType()) {
00078 case INSTALLER_ERROR_DB:
00079 $this->dbInstallError($installer->getErrorMsg());
00080 break;
00081 default:
00082 $this->installError($installer->getErrorMsg());
00083 break;
00084 }
00085 }
00086
00087 $installer->destroy();
00088 }
00089
00090
00091
00096 function installError($errorMsg) {
00097 $templateMgr = &TemplateManager::getManager();
00098 $templateMgr->assign(array('isInstallError' => true, 'errorMsg' => $errorMsg));
00099 $this->display();
00100 }
00101
00106 function dbInstallError($errorMsg) {
00107 $templateMgr = &TemplateManager::getManager();
00108 $templateMgr->assign(array('isInstallError' => true, 'dbErrorMsg' => empty($errorMsg) ? Locale::translate('common.error.databaseErrorUnknown') : $errorMsg));
00109 $this->display();
00110 }
00111
00112 }
00113
00114 ?>