/** * Displays the specified 'step' of the wizard * @param WizardStep $oStep The 'step' to display */ protected function DisplayStep(WizardStep $oStep) { $oPage = new SetupPage($oStep->GetTitle()); if ($oStep->RequiresWritableConfig()) { $sConfigFile = utils::GetConfigFilePath(); if (file_exists($sConfigFile)) { // The configuration file already exists if (!is_writable($sConfigFile)) { $oP = new SetupPage('Installation Cannot Continue'); $oP->add("<h2>Fatal error</h2>\n"); $oP->error("<b>Error:</b> the configuration file '" . $sConfigFile . "' already exists and cannot be overwritten."); $oP->p("The wizard cannot modify the configuration file for you. If you want to upgrade " . ITOP_APPLICATION . ", make sure that the file '<b>" . realpath($sConfigFile) . "</b>' can be modified by the web server."); $oP->output(); return; } } } $oPage->add_linked_script('../setup/setup.js'); $oPage->add_script("function CanMoveForward()\n{\n" . $oStep->JSCanMoveForward() . "\n}\n"); $oPage->add_script("function CanMoveBackward()\n{\n" . $oStep->JSCanMoveBackward() . "\n}\n"); $oPage->add('<form id="wiz_form" method="post">'); $oStep->Display($oPage); // Add the back / next buttons and the hidden form // to store the parameters $oPage->add('<input type="hidden" id="_class" name="_class" value="' . get_class($oStep) . '"/>'); $oPage->add('<input type="hidden" id="_state" name="_state" value="' . $oStep->GetState() . '"/>'); foreach ($this->aParameters as $sCode => $value) { $oPage->add('<input type="hidden" name="_params[' . $sCode . ']" value="' . htmlentities($value, ENT_QUOTES, 'UTF-8') . '"/>'); } $oPage->add('<input type="hidden" name="_steps" value="' . htmlentities(json_encode($this->aSteps), ENT_QUOTES, 'UTF-8') . '"/>'); $oPage->add('<table style="width:100%;"><tr>'); if (count($this->aSteps) > 0 && $oStep->CanMoveBackward()) { $oPage->add('<td style="text-align: left"><button id="btn_back" type="submit" name="operation" value="back"> << Back </button></td>'); } if ($oStep->CanMoveForward()) { $oPage->add('<td style="text-align:right;"><button id="btn_next" class="default" type="submit" name="operation" value="next">' . htmlentities($oStep->GetNextButtonLabel(), ENT_QUOTES, 'UTF-8') . '</button></td>'); } $oPage->add('</tr></table>'); $oPage->add("</form>"); $oPage->add('<div id="async_action" style="display:none;overflow:auto;max-height:100px;color:#F00;font-size:small;"></div>'); // The div may become visible in case of error // Hack to have the "Next >>" button, be the default button, since the first submit button in the form is the default one $oPage->add_ready_script(<<<EOF \$('form').each(function () { \tvar thisform = \$(this); \t\tthisform.prepend(thisform.find('button.default').clone().removeAttr('id').removeAttr('disabled').css({ \t\tposition: 'absolute', \t\tleft: '-999px', \t\ttop: '-999px', \t\theight: 0, \t\twidth: 0 \t})); }); \$('#btn_back').click(function() { \$('#wiz_form').data('back', true); }); \$('#wiz_form').submit(function() { \tif (\$(this).data('back')) \t{ \t\treturn CanMoveBackward(); \t} \telse \t{ \t\treturn CanMoveForward(); \t} }); \$('#wiz_form').data('back', false); WizardUpdateButtons(); EOF ); $oPage->output(); }