public function Display(WebPage $oPage) { $sInstallMode = $this->oWizard->GetParameter('install_mode', ''); $sDBServer = $this->oWizard->GetParameter('db_server', ''); $sDBUser = $this->oWizard->GetParameter('db_user', ''); $sDBPwd = $this->oWizard->GetParameter('db_pwd', ''); $sDBName = $this->oWizard->GetParameter('db_name', ''); $sDBPrefix = $this->oWizard->GetParameter('db_prefix', ''); $bDBBackup = $this->oWizard->GetParameter('db_backup', false); $sDBBackupPath = $this->oWizard->GetParameter('db_backup_path', ''); $sPreviousVersionDir = ''; if ($sInstallMode == '') { $sDBBackupPath = APPROOT . 'data/' . ITOP_APPLICATION . strftime('-backup-%Y-%m-%d.zip'); $bDBBackup = true; $aPreviousInstance = SetupUtils::GetPreviousInstance(APPROOT); if ($aPreviousInstance['found']) { $sInstallMode = 'upgrade'; $sSourceDir = APPROOT; $sDBServer = $aPreviousInstance['db_server']; $sDBUser = $aPreviousInstance['db_user']; $sDBPwd = $aPreviousInstance['db_pwd']; $sDBName = $aPreviousInstance['db_name']; $sDBPrefix = $aPreviousInstance['db_prefix']; $sStyle = ''; $sPreviousVersionDir = APPROOT; } else { $sInstallMode = 'install'; } } $sPreviousVersionDir = $this->oWizard->GetParameter('previous_version_dir', $sPreviousVersionDir); $sUpgradeInfoStyle = ''; if ($sInstallMode == 'install') { $sUpgradeInfoStyle = ' style="display: none;" '; } $oPage->add('<h2>What do you want to do?</h2>'); $sChecked = $sInstallMode == 'install' ? ' checked ' : ''; $oPage->p('<input id="radio_install" type="radio" name="install_mode" value="install"' . $sChecked . '/><label for="radio_install"> Install a new ' . ITOP_APPLICATION . '</label>'); $sChecked = $sInstallMode == 'upgrade' ? ' checked ' : ''; $oPage->p('<input id="radio_update" type="radio" name="install_mode" value="upgrade"' . $sChecked . '/><label for="radio_update"> Upgrade an existing ' . ITOP_APPLICATION . ' instance</label>'); //$oPage->add('<fieldset id="upgrade_info"'.$sUpgradeInfoStyle.'>'); //$oPage->add('<legend>Information about the previous instance:</legend>'); $oPage->add('<table id="upgrade_info"' . $sUpgradeInfoStyle . '>'); $oPage->add('<tr><td>Location on the disk:</td><td><input id="previous_version_dir" type="text" name="previous_version_dir" value="' . htmlentities($sPreviousVersionDir, ENT_QUOTES, 'UTF-8') . '" size="25"/></td></tr>'); SetupUtils::DisplayDBParameters($oPage, false, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix); $aBackupChecks = SetupUtils::CheckBackupPrerequisites($sDBBackupPath); $bCanBackup = true; $sMySQLDumpMessage = ''; foreach ($aBackupChecks as $oCheck) { if ($oCheck->iSeverity == CheckResult::ERROR) { $bCanBackup = false; $sMySQLDumpMessage .= '<img src="../images/error.png"/> <b> Warning:</b> ' . $oCheck->sLabel; } else { $sMySQLDumpMessage .= '<img src="../images/validation_ok.png"/> ' . $oCheck->sLabel . ' '; } } $sChecked = $bCanBackup && $bDBBackup ? ' checked ' : ''; $sDisabled = $bCanBackup ? '' : ' disabled '; $oPage->add('<tr><td colspan="2"><input id="db_backup" type="checkbox" name="db_backup"' . $sChecked . $sDisabled . ' value="1"/><label for="db_backup"> Backup the ' . ITOP_APPLICATION . ' database before upgrading</label></td></tr>'); $oPage->add('<tr><td colspan="2">Save the backup to: <input id="db_backup_path" type="text" name="db_backup_path" ' . $sDisabled . 'value="' . htmlentities($sDBBackupPath, ENT_QUOTES, 'UTF-8') . '" size="25"/></td></tr>'); $fFreeSpace = SetupUtils::CheckDiskSpace($sDBBackupPath); $sMessage = ''; if ($fFreeSpace !== false) { $sMessage .= SetupUtils::HumanReadableSize($fFreeSpace) . ' free in ' . dirname($sDBBackupPath); } $oPage->add('<tr><td colspan="2">'); $oPage->add($sMySQLDumpMessage . '<br/><span id="backup_info" style="font-size:small;color:#696969;">' . $sMessage . '</span></td></tr>'); $oPage->add('</table>'); //$oPage->add('</fieldset>'); $oPage->add_ready_script(<<<EOF \t\$("#radio_update").bind('change', function() { if (this.checked ) { \$('#upgrade_info').show(); WizardUpdateButtons(); } else { \$('#upgrade_info').hide(); } }); \t\$("#radio_install").bind('change', function() { if (this.checked ) { \$('#upgrade_info').hide(); WizardUpdateButtons(); } else { \$('#upgrade_info').show(); } }); \t\$("#previous_version_dir").bind('change keyup', function() { WizardAsyncAction('check_path', { previous_version_dir: \$('#previous_version_dir').val() }); }); \t\$("#db_backup_path").bind('change keyup', function() { WizardAsyncAction('check_backup', { db_backup_path: \$('#db_backup_path').val() }); }); EOF ); }