4 * @file classes/install/form/UpgradeForm.inc.php
6 * Copyright (c) 2003-2008 John Willinsky
7 * Distributed under the GNU GPL v2. For full terms see the file docs/COPYING.
10 * @ingroup install_form
12 * @brief Form for system upgrades.
15 // $Id: UpgradeForm.inc.php,v 1.4 2009/09/22 19:22:09 asmecher Exp $
18 import('install.Upgrade');
21 class UpgradeForm
extends Form
{
26 function UpgradeForm() {
27 parent
::Form('install/upgrade.tpl');
28 $this->addCheck(new FormValidatorPost($this));
35 $templateMgr =& TemplateManager
::getManager();
36 $templateMgr->assign_by_ref('version', VersionCheck
::getCurrentCodeVersion());
42 * Perform installation.
45 $templateMgr =& TemplateManager
::getManager();
46 $installer = new Upgrade($this->_data
);
50 // FIXME Mostly common with InstallForm
52 if ($installer->execute()) {
53 if (!$installer->wroteConfig()) {
54 // Display config file contents for manual replacement
55 $templateMgr->assign(array('writeConfigFailed' => true, 'configFileContents' => $installer->getConfigContents()));
58 $templateMgr->assign('notes', $installer->getNotes());
59 $templateMgr->assign_by_ref('newVersion', $installer->getNewVersion());
60 $templateMgr->display('install/upgradeComplete.tpl');
63 switch ($installer->getErrorType()) {
64 case INSTALLER_ERROR_DB
:
65 $this->dbInstallError($installer->getErrorMsg());
68 $this->installError($installer->getErrorMsg());
73 $installer->destroy();
76 // FIXME Common with InstallForm
79 * Fail with a generic installation error.
80 * @param $errorMsg string
82 function installError($errorMsg) {
83 $templateMgr =& TemplateManager
::getManager();
84 $templateMgr->assign(array('isInstallError' => true, 'errorMsg' => $errorMsg));
89 * Fail with a database installation error.
90 * @param $errorMsg string
92 function dbInstallError($errorMsg) {
93 $templateMgr =& TemplateManager
::getManager();
94 $templateMgr->assign(array('isInstallError' => true, 'dbErrorMsg' => empty($errorMsg) ? Locale
::translate('common.error.databaseErrorUnknown') : $errorMsg));