public function CompileFrom($sSourceEnv, $bUseSymLinks = false)
 {
     $oSourceConfig = new Config(utils::GetConfigFilePath($sSourceEnv));
     $sSourceDir = $oSourceConfig->Get('source_dir');
     $sSourceDirFull = APPROOT . $sSourceDir;
     // Do load the required modules
     //
     $oFactory = new ModelFactory($sSourceDirFull);
     foreach ($this->GetMFModulesToCompile($sSourceEnv, $sSourceDir) as $oModule) {
         $sModule = $oModule->GetName();
         $oFactory->LoadModule($oModule);
         if ($oFactory->HasLoadErrors()) {
             break;
         }
     }
     if ($oFactory->HasLoadErrors()) {
         foreach ($oFactory->GetLoadErrors() as $sModuleId => $aErrors) {
             echo "<h3>Module: " . $sModuleId . "</h3>\n";
             foreach ($aErrors as $oXmlError) {
                 echo "<p>File: " . $oXmlError->file . " Line:" . $oXmlError->line . " Message:" . $oXmlError->message . "</p>\n";
             }
         }
     } else {
         $oFactory->ApplyChanges();
         //$oFactory->Dump();
         $sTargetDir = APPROOT . 'env-' . $this->sTargetEnv;
         self::MakeDirSafe($sTargetDir);
         $oMFCompiler = new MFCompiler($oFactory);
         $oMFCompiler->Compile($sTargetDir, null, $bUseSymLinks);
         require_once APPROOT . '/core/dict.class.inc.php';
         MetaModel::ResetCache(md5(APPROOT) . '-' . $this->sTargetEnv);
     }
 }
    /**
     * 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"> &lt;&lt; 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();
    }
示例#3
0
        case 'async_action':
            ini_set('max_execution_time', max(240, ini_get('max_execution_time')));
            // While running the setup it is desirable to see any error that may happen
            ini_set('display_errors', true);
            ini_set('display_startup_errors', true);
            require_once APPROOT . '/setup/wizardcontroller.class.inc.php';
            require_once APPROOT . '/setup/wizardsteps.class.inc.php';
            $sClass = utils::ReadParam('step_class', '');
            $sState = utils::ReadParam('step_state', '');
            $sActionCode = utils::ReadParam('code', '');
            $aParams = utils::ReadParam('params', array(), false, 'raw_data');
            $oPage = new ajax_page('');
            $oDummyController = new WizardController('');
            if (is_subclass_of($sClass, 'WizardStep')) {
                $oStep = new $sClass($oDummyController, $sState);
                $sConfigFile = utils::GetConfigFilePath();
                if (file_exists($sConfigFile) && !is_writable($sConfigFile) && $oStep->RequiresWritableConfig()) {
                    $oPage->error("<b>Error:</b> the configuration file '" . $sConfigFile . "' already exists and cannot be overwritten.");
                    $oPage->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.");
                    $oPage->output();
                } else {
                    $oStep->AsyncAction($oPage, $sActionCode, $aParams);
                }
            }
            $oPage->output();
            break;
        default:
            throw new Exception("Error unsupported operation '{$sOperation}'");
    }
} catch (Exception $e) {
    header("HTTP/1.0 500 Internal server error.");