Open Monograph Press  1.1
 All Classes Namespaces Functions Variables Groups Pages
UpgradeForm.inc.php
1 <?php
2 
18 import('classes.install.Upgrade');
19 import('lib.pkp.classes.form.Form');
20 
21 class UpgradeForm extends Form {
22 
26  function UpgradeForm() {
27  parent::Form('install/upgrade.tpl');
28  $this->addCheck(new FormValidatorPost($this));
29  }
30 
34  function display() {
35  $templateMgr = TemplateManager::getManager();
36  $templateMgr->assign_by_ref('version', VersionCheck::getCurrentCodeVersion());
37 
38  parent::display();
39  }
40 
44  function execute() {
45  $templateMgr = TemplateManager::getManager();
46  $installer = new Upgrade($this->_data);
47 
48  // FIXME Use logger?
49 
50  // FIXME Mostly common with InstallForm
51 
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()));
56  }
57 
58  $templateMgr->assign('notes', $installer->getNotes());
59  $templateMgr->assign_by_ref('newVersion', $installer->getNewVersion());
60  $templateMgr->display('install/upgradeComplete.tpl');
61 
62  } else {
63  switch ($installer->getErrorType()) {
64  case INSTALLER_ERROR_DB:
65  $this->dbInstallError($installer->getErrorMsg());
66  break;
67  default:
68  $this->installError($installer->getErrorMsg());
69  break;
70  }
71  }
72 
73  $installer->destroy();
74  }
75 
76  // FIXME Common with InstallForm
77 
82  function installError($errorMsg) {
83  $templateMgr = TemplateManager::getManager();
84  $templateMgr->assign(array('isInstallError' => true, 'errorMsg' => $errorMsg));
85  $this->display();
86  }
87 
92  function dbInstallError($errorMsg) {
93  $templateMgr = TemplateManager::getManager();
94  $templateMgr->assign(array('isInstallError' => true, 'dbErrorMsg' => empty($errorMsg) ? __('common.error.databaseErrorUnknown') : $errorMsg));
95  $this->display();
96  }
97 
98 }
99 
100 ?>
addCheck($formValidator)
Definition: Form.inc.php:396
Form validation check to make sure the form is POSTed.
installError($errorMsg)
Class defining basic operations for handling HTML forms.
Definition: Form.inc.php:47
Perform system upgrade.
Definition: Upgrade.inc.php:19
Form for system upgrades.
dbInstallError($errorMsg)