XML: the images specified in the branding or in module_designs can be given as a fileref or a path relative to the env-production directory

SVN:trunk[3861]
This commit is contained in:
Romain Quetiez
2016-01-15 09:21:32 +00:00
parent 6d23d64e8f
commit 161041d379

View File

@@ -451,7 +451,8 @@ EOF;
$this->CompilePortals($oPortalsNode, $sTempTargetDir, $sFinalTargetDir); $this->CompilePortals($oPortalsNode, $sTempTargetDir, $sFinalTargetDir);
// Create module design XML files // Create module design XML files
$this->CompileModuleDesigns($sTempTargetDir, $sFinalTargetDir); $oModuleDesignsNode = $this->oFactory->GetNodes('/itop_design/module_designs')->item(0);
$this->CompileModuleDesigns($oModuleDesignsNode, $sTempTargetDir, $sFinalTargetDir);
// Compile the XML parameters // Compile the XML parameters
$oParametersNode = $this->oFactory->GetNodes('/itop_design/module_parameters')->item(0); $oParametersNode = $this->oFactory->GetNodes('/itop_design/module_parameters')->item(0);
@@ -2152,14 +2153,7 @@ EOF;
{ {
if (($sIcon = $oBrandingNode->GetChildText($sNodeName)) && (strlen($sIcon) > 0)) if (($sIcon = $oBrandingNode->GetChildText($sNodeName)) && (strlen($sIcon) > 0))
{ {
if (substr($sIcon, 0, 8) == 'branding') $sSourceFile = $sTempTargetDir.'/'.$sIcon;
{
$sSourceFile = $sTempTargetDir.'/'.$sIcon;
}
else
{
$sSourceFile = APPROOT.$sIcon;
}
$sTargetFile = $sTempTargetDir.'/branding/'.$sTargetFile.'.png'; $sTargetFile = $sTempTargetDir.'/branding/'.$sTargetFile.'.png';
if (!file_exists($sSourceFile)) if (!file_exists($sSourceFile))
@@ -2167,17 +2161,17 @@ EOF;
throw new Exception("Branding $sNodeName: could not find the file $sIcon ($sSourceFile)"); throw new Exception("Branding $sNodeName: could not find the file $sIcon ($sSourceFile)");
} }
// Note: rename makes sense only when the file given as a file ref, otherwise it may be an item of the application (thus it must be kept there)
copy($sSourceFile, $sTargetFile); copy($sSourceFile, $sTargetFile);
} }
} }
protected function CompileBranding($oBrandingNode, $sTempTargetDir, $sFinalTargetDir) protected function CompileBranding($oBrandingNode, $sTempTargetDir, $sFinalTargetDir)
{ {
// Enable relative paths
SetupUtils::builddir($sTempTargetDir.'/branding');
if ($oBrandingNode) if ($oBrandingNode)
{ {
// Transform file refs into files in the images folder // Transform file refs into files in the images folder
SetupUtils::builddir($sTempTargetDir.'/branding');
$this->CompileFiles($oBrandingNode, $sTempTargetDir.'/branding', $sFinalTargetDir.'/branding', 'branding'); $this->CompileFiles($oBrandingNode, $sTempTargetDir.'/branding', $sFinalTargetDir.'/branding', 'branding');
$this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo', 'main-logo'); $this->CompileLogo($oBrandingNode, $sTempTargetDir, $sFinalTargetDir, 'main_logo', 'main-logo');
@@ -2281,11 +2275,11 @@ EOF;
} }
} }
protected function CompileModuleDesigns($sTempTargetDir, $sFinalTargetDir) protected function CompileModuleDesigns($oDesigns, $sTempTargetDir, $sFinalTargetDir)
{ {
SetupUtils::builddir($sTempTargetDir.'/core/module_designs'); SetupUtils::builddir($sTempTargetDir.'/core/module_designs/images');
$oDesigns = $this->oFactory->GetNodes('/itop_design/module_designs/module_design'); $this->CompileFiles($oDesigns, $sTempTargetDir.'/core/module_designs', $sFinalTargetDir.'/core/module_designs', 'core/module_designs');
foreach($oDesigns as $oDesign) foreach ($oDesigns->GetNodes('module_design') as $oDesign)
{ {
$oDoc = new ModuleDesign(); $oDoc = new ModuleDesign();
$oClone = $oDoc->importNode($oDesign->cloneNode(true), true); $oClone = $oDoc->importNode($oDesign->cloneNode(true), true);