mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 02:28:44 +02:00
Fixed the support of the toolkit
SVN:trunk[2258]
This commit is contained in:
@@ -27,7 +27,6 @@ class DOMFormatException extends Exception
|
||||
class MFCompiler
|
||||
{
|
||||
protected $oFactory;
|
||||
protected $aSourceDirs;
|
||||
|
||||
protected $aRootClasses;
|
||||
protected $aLog;
|
||||
|
||||
@@ -106,7 +106,7 @@ class MFModule
|
||||
*/
|
||||
class ModelFactory
|
||||
{
|
||||
protected $sRootDir;
|
||||
protected $aRootDirs;
|
||||
protected $oDOMDocument;
|
||||
protected $oRoot;
|
||||
protected $oModules;
|
||||
@@ -119,9 +119,9 @@ class ModelFactory
|
||||
static protected $aLoadErrors;
|
||||
|
||||
|
||||
public function __construct($sRootDir, $aRootNodeExtensions = array())
|
||||
public function __construct($aRootDirs, $aRootNodeExtensions = array())
|
||||
{
|
||||
$this->sRootDir = $sRootDir;
|
||||
$this->aRootDirs = $aRootDirs;
|
||||
$this->oDOMDocument = new MFDocument();
|
||||
$this->oRoot = $this->oDOMDocument->CreateElement('itop_design');
|
||||
$this->oRoot->setAttribute('xmlns:xsi', "http://www.w3.org/2001/XMLSchema-instance");
|
||||
@@ -1070,13 +1070,13 @@ EOF
|
||||
}
|
||||
|
||||
/**
|
||||
* Searches on disk in the root directory for module description files
|
||||
* Searches on disk in the root directories for module description files
|
||||
* and returns an array of MFModules
|
||||
* @return array Array of MFModules
|
||||
*/
|
||||
public function FindModules($sSubDirectory = '')
|
||||
public function FindModules()
|
||||
{
|
||||
$aAvailableModules = ModuleDiscovery::GetAvailableModules($this->sRootDir, array($sSubDirectory));
|
||||
$aAvailableModules = ModuleDiscovery::GetAvailableModules($this->aRootDirs);
|
||||
$aResult = array();
|
||||
foreach($aAvailableModules as $sId => $aModule)
|
||||
{
|
||||
|
||||
@@ -279,20 +279,25 @@ class RunTimeEnvironment
|
||||
$sSourceDirFull = APPROOT.$sSourceDir;
|
||||
if (!is_dir($sSourceDirFull))
|
||||
{
|
||||
throw new Exception("The source directory '$sSourceDir' does not exist (or could not be read)");
|
||||
throw new Exception("The source directory '$sSourceDirFull' does not exist (or could not be read)");
|
||||
}
|
||||
|
||||
$aDirsToCompile = array($sSourceDirFull);
|
||||
if (is_dir(APPROOT.'extensions'))
|
||||
{
|
||||
$aDirsToCompile[] = APPROOT.'extensions';
|
||||
}
|
||||
|
||||
$aRet = array();
|
||||
|
||||
// Determine the installed modules
|
||||
//
|
||||
$oSourceConfig = new Config(APPCONF.$sSourceEnv.'/'.ITOP_CONFIG_FILE);
|
||||
$oSourceEnv = new RunTimeEnvironment($sSourceEnv);
|
||||
$aAvailableModules = $oSourceEnv->AnalyzeInstallation($oSourceConfig, $sSourceDir); //TODO: use an absolute PATH
|
||||
$aAvailableModules = $oSourceEnv->AnalyzeInstallation($oSourceConfig, $aDirsToCompile);
|
||||
|
||||
// Do load the required modules
|
||||
//
|
||||
$oFactory = new ModelFactory($sSourceDirFull);
|
||||
$oFactory = new ModelFactory($aDirsToCompile);
|
||||
$aModules = $oFactory->FindModules();
|
||||
foreach($aModules as $foo => $oModule)
|
||||
{
|
||||
@@ -308,13 +313,11 @@ class RunTimeEnvironment
|
||||
return $aRet;
|
||||
}
|
||||
|
||||
public function CompileFrom($sSourceEnv, $sSourceDir = null)
|
||||
public function CompileFrom($sSourceEnv)
|
||||
{
|
||||
if (is_null($sSourceDir))
|
||||
{
|
||||
$oSourceConfig = new Config(utils::GetConfigFilePath($sSourceEnv));
|
||||
$sSourceDir = $oSourceConfig->Get('source_dir');
|
||||
}
|
||||
$oSourceConfig = new Config(utils::GetConfigFilePath($sSourceEnv));
|
||||
$sSourceDir = $oSourceConfig->Get('source_dir');
|
||||
|
||||
$sSourceDirFull = APPROOT.$sSourceDir;
|
||||
// Do load the required modules
|
||||
//
|
||||
@@ -347,9 +350,10 @@ class RunTimeEnvironment
|
||||
|
||||
$sTargetDir = APPROOT.'env-'.$this->sTargetEnv;
|
||||
self::MakeDirSafe($sTargetDir);
|
||||
$oMFCompiler = new MFCompiler($oFactory, $sSourceDirFull);
|
||||
$oMFCompiler = new MFCompiler($oFactory);
|
||||
$oMFCompiler->Compile($sTargetDir);
|
||||
|
||||
|
||||
require_once(APPROOT.'/core/dict.class.inc.php');
|
||||
MetaModel::ResetCache($this->sTargetEnv);
|
||||
}
|
||||
}
|
||||
@@ -546,9 +550,12 @@ class RunTimeEnvironment
|
||||
{
|
||||
if (!is_dir($sDir))
|
||||
{
|
||||
@mkdir($sDir);
|
||||
if (!@mkdir($sDir))
|
||||
{
|
||||
throw new Exception("Failed to create directory '$sTargetPath', please check the rights of the web server");
|
||||
}
|
||||
@chmod($sDir, 0770); // RWX for owner and group, nothing for others
|
||||
}
|
||||
@chmod($sDir, 0770); // RWX for owner and group, nothing for others
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user