mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 10:38:45 +02:00
The path to Graphviz' dot program is now prompted interactively during the setup, since Graphviz is now mandatory for displaying the impact analysis.
SVN:trunk[3643]
This commit is contained in:
@@ -162,7 +162,7 @@ class Config
|
||||
'default' => '/usr/bin/dot',
|
||||
'value' => '',
|
||||
'source_of_value' => '',
|
||||
'show_in_conf_sample' => false,
|
||||
'show_in_conf_sample' => true,
|
||||
),
|
||||
'php_path' => array(
|
||||
'type' => 'string',
|
||||
@@ -1750,6 +1750,10 @@ class Config
|
||||
{
|
||||
$this->Set('app_root_url', $aParamValues['application_path']);
|
||||
}
|
||||
if (isset($aParamValues['graphviz_path']))
|
||||
{
|
||||
$this->Set('graphviz_path', $aParamValues['graphviz_path']);
|
||||
}
|
||||
if (isset($aParamValues['mode']) && isset($aParamValues['language']))
|
||||
{
|
||||
if (($aParamValues['mode'] == 'install') || $this->GetDefaultLanguage() == '')
|
||||
|
||||
@@ -329,6 +329,7 @@ class ApplicationInstaller
|
||||
$sDBName = $aDBParams['name'];
|
||||
$sDBPrefix = $aDBParams['prefix'];
|
||||
$sUrl = $this->oParams->Get('url', '');
|
||||
$sGraphvizPath = $this->oParams->Get('graphviz_path', '');
|
||||
$sLanguage = $this->oParams->Get('language', '');
|
||||
$aSelectedModules = $this->oParams->Get('selected_modules', array());
|
||||
$bOldAddon = $this->oParams->Get('old_addon', false);
|
||||
@@ -336,7 +337,7 @@ class ApplicationInstaller
|
||||
$sPreviousConfigFile = $this->oParams->Get('previous_configuration_file', '');
|
||||
$sDataModelVersion = $this->oParams->Get('datamodel_version', '0.0.0');
|
||||
|
||||
self::DoCreateConfig($sMode, $sTargetDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion);
|
||||
self::DoCreateConfig($sMode, $sTargetDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion, $sGraphvizPath);
|
||||
|
||||
$aResult = array(
|
||||
'status' => self::INFO,
|
||||
@@ -937,7 +938,7 @@ class ApplicationInstaller
|
||||
SetupPage::log_info("ending data load session");
|
||||
}
|
||||
|
||||
protected static function DoCreateConfig($sMode, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion)
|
||||
protected static function DoCreateConfig($sMode, $sModulesDir, $sDBServer, $sDBUser, $sDBPwd, $sDBName, $sDBPrefix, $sUrl, $sLanguage, $aSelectedModules, $sTargetEnvironment, $bOldAddon, $sSourceDir, $sPreviousConfigFile, $sDataModelVersion, $sGraphvizPath)
|
||||
{
|
||||
$aParamValues = array(
|
||||
'mode' => $sMode,
|
||||
@@ -949,6 +950,7 @@ class ApplicationInstaller
|
||||
'db_prefix' => $sDBPrefix,
|
||||
'application_path' => $sUrl,
|
||||
'language' => $sLanguage,
|
||||
'graphviz_path' => $sGraphvizPath,
|
||||
'selected_modules' => implode(',', $aSelectedModules),
|
||||
);
|
||||
|
||||
|
||||
@@ -84,7 +84,7 @@ body {
|
||||
}
|
||||
|
||||
h1 {
|
||||
color: #1C94C4;
|
||||
color: #555555;
|
||||
font-size: 16pt;
|
||||
}
|
||||
h2 {
|
||||
|
||||
@@ -433,6 +433,55 @@ class SetupUtils
|
||||
return $aResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that graphviz can be launched
|
||||
* @param string $GraphvizPath The path where graphviz' dot program is installed
|
||||
* @return CheckResult The result of the check
|
||||
*/
|
||||
static function CheckGraphviz($sGraphvizPath)
|
||||
{
|
||||
$oResult = null;
|
||||
SetupPage::log('Info - CheckGraphviz');
|
||||
|
||||
// availability of exec()
|
||||
//
|
||||
$aDisabled = explode(', ', ini_get('disable_functions'));
|
||||
SetupPage::log('Info - PHP functions disabled: '.implode(', ', $aDisabled));
|
||||
if (in_array('exec', $aDisabled))
|
||||
{
|
||||
$aResult[] = new CheckResult(CheckResult::ERROR, "The PHP exec() function has been disabled on this server");
|
||||
}
|
||||
|
||||
// availability of dot / dot.exe
|
||||
if (empty($sGraphvizPath))
|
||||
{
|
||||
$sGraphvizPath = 'dot';
|
||||
}
|
||||
$sCommand = "$sGraphvizPath -V 2>&1";
|
||||
|
||||
$aOutput = array();
|
||||
$iRetCode = 0;
|
||||
exec($sCommand, $aOutput, $iRetCode);
|
||||
if ($iRetCode == 0)
|
||||
{
|
||||
$oResult = new CheckResult(CheckResult::INFO, "dot is present: ".$aOutput[0]);
|
||||
}
|
||||
elseif ($iRetCode == 1)
|
||||
{
|
||||
$oResult = new CheckResult(CheckResult::WARNING, "dot could not be found: ".implode(' ', $aOutput)." - Please make sure it is installed and in the path.");
|
||||
}
|
||||
else
|
||||
{
|
||||
$oResult = new CheckResult(CheckResult::WARNING, "dot could not be executed (retcode=$iRetCode): Please make sure it is installed and in the path");
|
||||
}
|
||||
foreach($aOutput as $sLine)
|
||||
{
|
||||
SetupPage::log('Info - '.$sGraphvizPath.' -V said: '.$sLine);
|
||||
}
|
||||
|
||||
return $oResult;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function to retrieve the system's temporary directory
|
||||
* Emulates sys_get_temp_dir if neeed (PHP < 5.2.1)
|
||||
@@ -710,6 +759,7 @@ class SetupUtils
|
||||
'db_pwd' => $oPrevConf->GetDBPwd(),
|
||||
'db_name' => $oPrevConf->GetDBName(),
|
||||
'db_prefix' => $oPrevConf->GetDBSubname(),
|
||||
'graphviz_path' => $oPrevConf->Get('graphviz_path'),
|
||||
);
|
||||
}
|
||||
|
||||
@@ -997,7 +1047,7 @@ EOF
|
||||
{
|
||||
$aWarnings[] = $oCheck->sLabel;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (count($aErrors) > 0)
|
||||
{
|
||||
$oPage->add_ready_script('$("#wiz_form").data("db_connection", "error");');
|
||||
|
||||
@@ -219,6 +219,7 @@ class WizStepInstallOrUpgrade extends WizardStep
|
||||
$sDBPwd = $aPreviousInstance['db_pwd'];
|
||||
$sDBName = $aPreviousInstance['db_name'];
|
||||
$sDBPrefix = $aPreviousInstance['db_prefix'];
|
||||
$this->oWizard->SaveParameter('graphviz_path', $aPreviousInstance['graphviz_path']);
|
||||
$sStyle = '';
|
||||
$sPreviousVersionDir = APPROOT;
|
||||
}
|
||||
@@ -918,6 +919,7 @@ class WizStepMiscParams extends WizardStep
|
||||
{
|
||||
$this->oWizard->SaveParameter('default_language', '');
|
||||
$this->oWizard->SaveParameter('application_url', '');
|
||||
$this->oWizard->SaveParameter('graphviz_path', '');
|
||||
$this->oWizard->SaveParameter('sample_data', 'yes');
|
||||
return array('class' => 'WizStepModulesChoice', 'state' => 'start_install');
|
||||
}
|
||||
@@ -926,6 +928,8 @@ class WizStepMiscParams extends WizardStep
|
||||
{
|
||||
$sDefaultLanguage = $this->oWizard->GetParameter('default_language', $this->oWizard->GetParameter('admin_language'));
|
||||
$sApplicationURL = $this->oWizard->GetParameter('application_url', utils::GetDefaultUrlAppRoot());
|
||||
$sDefaultGraphvizPath = (strtolower(substr(PHP_OS, 0, 3)) === 'win') ? 'C:\\Program Files\\Graphviz\\bin\\dot.exe' : '/usr/bin/dot';
|
||||
$sGraphvizPath = $this->oWizard->GetParameter('graphviz_path', $sDefaultGraphvizPath);
|
||||
$sSampleData = $this->oWizard->GetParameter('sample_data', 'yes');
|
||||
$oPage->add('<h2>Additional parameters</h2>');
|
||||
$oPage->add('<fieldset>');
|
||||
@@ -946,6 +950,14 @@ class WizStepMiscParams extends WizardStep
|
||||
$oPage->add('</table>');
|
||||
$oPage->add('</fieldset>');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Path to Graphviz\' dot application</legend>');
|
||||
$oPage->add('<table>');
|
||||
$oPage->add('<tr><td>Path: </td><td><input id="graphviz_path" name="graphviz_path" type="text" size="35" maxlength="1024" value="'.htmlentities($sGraphvizPath, ENT_QUOTES, 'UTF-8').'"><span id="v_graphviz_path"/></td><tr>');
|
||||
$oPage->add('<tr><td colspan="2"><a href="http://www.graphviz.org" target="_blank">Graphviz</a> is required to display the impact analysis graph (i.e. impacts / depends on).</td><tr>');
|
||||
$oPage->add('<tr><td colspan="2"><span id="graphviz_status"></span></td><tr>');
|
||||
$oPage->add('</table>');
|
||||
$oPage->add('</fieldset>');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Sample Data</legend>');
|
||||
$sChecked = ($sSampleData == 'yes') ? ' checked ' : '';
|
||||
$oPage->p('<input id="sample_data_yes" name="sample_data" type="radio" value="yes"'.$sChecked.'><label for="sample_data_yes"> I am installing a <b>demo or test</b> instance, populate the database with some demo data.');
|
||||
@@ -955,10 +967,52 @@ class WizStepMiscParams extends WizardStep
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$('#application_url').bind('change keyup', function() { WizardUpdateButtons(); } );
|
||||
$('#graphviz_path').bind('change keyup init', function() { WizardUpdateButtons(); WizardAsyncAction('check_graphviz', { graphviz_path: $('#graphviz_path').val() }); } ).trigger('init');
|
||||
$('#btn_next').click(function() {
|
||||
bRet = true;
|
||||
if ($(this).attr('data-graphviz') != 'ok')
|
||||
{
|
||||
bRet = confirm('The impact analysis will not be displayed properly. Are you sure you want to continue?');
|
||||
}
|
||||
return bRet;
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
|
||||
{
|
||||
switch($sCode)
|
||||
{
|
||||
case 'check_graphviz':
|
||||
$sGraphvizPath = $aParameters['graphviz_path'];
|
||||
$oCheck = SetupUtils::CheckGraphviz($sGraphvizPath);
|
||||
$sMessage = json_encode($oCheck->sLabel);
|
||||
switch($oCheck->iSeverity)
|
||||
{
|
||||
case CheckResult::INFO:
|
||||
$sStatus = 'ok';
|
||||
$sMessage = json_encode('<img src="../images/validation_ok.png"> '.$oCheck->sLabel);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case CheckResult::ERROR:
|
||||
case CheckResult::WARNING:
|
||||
$sStatus = 'ko';
|
||||
$sMessage = json_encode('<img src="../images/error.png"> '.$oCheck->sLabel);
|
||||
|
||||
}
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$("#graphviz_status").html($sMessage);
|
||||
$('#btn_next').attr('data-graphviz', '$sStatus');
|
||||
EOF
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the "Next" button should be enabled interactively
|
||||
* @return string A piece of javascript code returning either true or false
|
||||
@@ -976,6 +1030,16 @@ EOF
|
||||
{
|
||||
$("#v_application_url").html('');
|
||||
}
|
||||
bGraphviz = ($('#graphviz_path').val() != '');
|
||||
if (!bGraphviz)
|
||||
{
|
||||
// Does not prevent to move forward
|
||||
$("#v_graphviz_path").html('<img src="../images/validation_error.png" title="Impact analysis will not display properly"/>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#v_graphviz_path").html('');
|
||||
}
|
||||
return bRet;
|
||||
EOF
|
||||
;
|
||||
@@ -1000,12 +1064,15 @@ class WizStepUpgradeMiscParams extends WizardStep
|
||||
public function ProcessParams($bMoveForward = true)
|
||||
{
|
||||
$this->oWizard->SaveParameter('application_url', '');
|
||||
$this->oWizard->SaveParameter('graphviz_path', '');
|
||||
return array('class' => 'WizStepModulesChoice', 'state' => 'start_upgrade');
|
||||
}
|
||||
|
||||
public function Display(WebPage $oPage)
|
||||
{
|
||||
$sApplicationURL = $this->oWizard->GetParameter('application_url', utils::GetDefaultUrlAppRoot());
|
||||
$sDefaultGraphvizPath = (strtolower(substr(PHP_OS, 0, 3)) === 'win') ? 'C:\\Program Files\\Graphviz\\bin\\dot.exe' : '/usr/bin/dot';
|
||||
$sGraphvizPath = $this->oWizard->GetParameter('graphviz_path', $sDefaultGraphvizPath);
|
||||
$oPage->add('<h2>Additional parameters</h2>');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Application URL</legend>');
|
||||
@@ -1014,13 +1081,63 @@ class WizStepUpgradeMiscParams extends WizardStep
|
||||
$oPage->add('<tr><td colspan="2">Change the value above if the end-users will be accessing the application by another path due to a specific configuration of the web server.</td><tr>');
|
||||
$oPage->add('</table>');
|
||||
$oPage->add('</fieldset>');
|
||||
$oPage->add('<fieldset>');
|
||||
$oPage->add('<legend>Path to Graphviz\' dot application</legend>');
|
||||
$oPage->add('<table>');
|
||||
$oPage->add('<tr><td>Path: </td><td><input id="graphviz_path" name="graphviz_path" type="text" size="35" maxlength="1024" value="'.htmlentities($sGraphvizPath, ENT_QUOTES, 'UTF-8').'"><span id="v_graphviz_path"/></td><tr>');
|
||||
$oPage->add('<tr><td colspan="2"><a href="http://www.graphviz.org" target="_blank">Graphviz</a> is required to display the impact analysis graph (i.e. impacts / depends on).</td><tr>');
|
||||
$oPage->add('<tr><td colspan="2"><span id="graphviz_status"></span></td><tr>');
|
||||
$oPage->add('</table>');
|
||||
$oPage->add('</fieldset>');
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$('#application_url').bind('change keyup', function() { WizardUpdateButtons(); } );
|
||||
$('#graphviz_path').bind('change keyup init', function() { WizardUpdateButtons(); WizardAsyncAction('check_graphviz', { graphviz_path: $('#graphviz_path').val() }); } ).trigger('init');
|
||||
$('#btn_next').click(function() {
|
||||
bRet = true;
|
||||
if ($(this).attr('data-graphviz') != 'ok')
|
||||
{
|
||||
bRet = confirm('The impact analysis will not be displayed properly. Are you sure you want to continue?');
|
||||
}
|
||||
return bRet;
|
||||
});
|
||||
EOF
|
||||
);
|
||||
}
|
||||
|
||||
public function AsyncAction(WebPage $oPage, $sCode, $aParameters)
|
||||
{
|
||||
switch($sCode)
|
||||
{
|
||||
case 'check_graphviz':
|
||||
$sGraphvizPath = $aParameters['graphviz_path'];
|
||||
$oCheck = SetupUtils::CheckGraphviz($sGraphvizPath);
|
||||
$sMessage = json_encode($oCheck->sLabel);
|
||||
switch($oCheck->iSeverity)
|
||||
{
|
||||
case CheckResult::INFO:
|
||||
$sStatus = 'ok';
|
||||
$sMessage = json_encode('<img src="../images/validation_ok.png"> '.$oCheck->sLabel);
|
||||
|
||||
break;
|
||||
|
||||
default:
|
||||
case CheckResult::ERROR:
|
||||
case CheckResult::WARNING:
|
||||
$sStatus = 'ko';
|
||||
$sMessage = json_encode('<img src="../images/error.png"> '.$oCheck->sLabel);
|
||||
|
||||
}
|
||||
$oPage->add_ready_script(
|
||||
<<<EOF
|
||||
$("#graphviz_status").html($sMessage);
|
||||
$('#btn_next').attr('data-graphviz', '$sStatus');
|
||||
EOF
|
||||
);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tells whether the "Next" button should be enabled interactively
|
||||
* @return string A piece of javascript code returning either true or false
|
||||
@@ -1038,6 +1155,16 @@ EOF
|
||||
{
|
||||
$("#v_application_url").html('');
|
||||
}
|
||||
bGraphviz = ($('#graphviz_path').val() != '');
|
||||
if (!bGraphviz)
|
||||
{
|
||||
// Does not prevent to move forward
|
||||
$("#v_graphviz_path").html('<img src="../images/validation_error.png" title="Impact analysis will not display properly"/>');
|
||||
}
|
||||
else
|
||||
{
|
||||
$("#v_graphviz_path").html('');
|
||||
}
|
||||
return bRet;
|
||||
EOF
|
||||
;
|
||||
@@ -1864,6 +1991,7 @@ EOF
|
||||
}
|
||||
|
||||
$oPage->add('<li>URL to access the application: '.$aInstallParams['url'].'</li>');
|
||||
$oPage->add('<li>Graphviz\' dot path: '.$aInstallParams['graphviz_path'].'</li>');
|
||||
if ($aInstallParams['sample_data'] == 'yes')
|
||||
{
|
||||
$oPage->add('<li>Sample data will be loaded into the database.</li>');
|
||||
@@ -2027,6 +2155,7 @@ EOF
|
||||
'prefix' => $this->oWizard->GetParameter('db_prefix'),
|
||||
),
|
||||
'url' => $this->oWizard->GetParameter('application_url'),
|
||||
'graphviz_path' => $this->oWizard->GetParameter('graphviz_path'),
|
||||
'admin_account' => array (
|
||||
'user' => $this->oWizard->GetParameter('admin_user'),
|
||||
'pwd' => $this->oWizard->GetParameter('admin_pwd'),
|
||||
|
||||
Reference in New Issue
Block a user