mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-24 02:58:43 +02:00
Core: a module can have its own design defined in XML (/itop_design/modules_designs/module_design) and accessed at run time via the class ModuleDesign. Switching to XML version 1.3.
SVN:trunk[3820]
This commit is contained in:
@@ -18,6 +18,8 @@
|
||||
|
||||
|
||||
require_once(APPROOT.'setup/setuputils.class.inc.php');
|
||||
require_once(APPROOT.'core/moduledesign.class.inc.php');
|
||||
|
||||
|
||||
class DOMFormatException extends Exception
|
||||
{
|
||||
@@ -429,7 +431,10 @@ EOF;
|
||||
// Compile the portals
|
||||
$oPortalsNode = $this->oFactory->GetNodes('/itop_design/portals')->item(0);
|
||||
$this->CompilePortals($oPortalsNode, $sTempTargetDir, $sFinalTargetDir);
|
||||
|
||||
|
||||
// Create module design XML files
|
||||
$this->CompileModuleDesigns($sTempTargetDir, $sFinalTargetDir);
|
||||
|
||||
// Compile the XML parameters
|
||||
$oParametersNode = $this->oFactory->GetNodes('/itop_design/module_parameters')->item(0);
|
||||
$this->CompileParameters($oParametersNode, $sTempTargetDir, $sFinalTargetDir);
|
||||
@@ -2221,6 +2226,19 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
protected function CompileModuleDesigns($sTempTargetDir, $sFinalTargetDir)
|
||||
{
|
||||
SetupUtils::builddir($sTempTargetDir.'/core/module_designs');
|
||||
$oDesigns = $this->oFactory->GetNodes('/itop_design/module_designs/module_design');
|
||||
foreach($oDesigns as $oDesign)
|
||||
{
|
||||
$oDoc = new ModuleDesign();
|
||||
$oClone = $oDoc->importNode($oDesign->cloneNode(true), true);
|
||||
$oDoc->appendChild($oClone);
|
||||
$oDoc->save($sTempTargetDir.'/core/module_designs/'.$oDesign->getAttribute('id').'.xml');
|
||||
}
|
||||
}
|
||||
|
||||
protected function LoadSnippets()
|
||||
{
|
||||
$oSnippets = $this->oFactory->GetNodes('/itop_design/snippets/snippet');
|
||||
@@ -2252,7 +2270,7 @@ EOF;
|
||||
{
|
||||
$this->aSnippets[$sModuleId] = array('before' => array(), 'after' => array());
|
||||
}
|
||||
|
||||
|
||||
$fOrder = (float) $oSnippet->GetChildText('rank', 0);
|
||||
$sContent = $oSnippet->GetChildText('content', '');
|
||||
if ($fOrder < 0)
|
||||
@@ -2278,5 +2296,3 @@ EOF;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
* }
|
||||
*/
|
||||
|
||||
define('ITOP_DESIGN_LATEST_VERSION', '1.2');
|
||||
define('ITOP_DESIGN_LATEST_VERSION', '1.3'); // iTop > 2.2.0
|
||||
|
||||
class iTopDesignFormat
|
||||
{
|
||||
@@ -55,6 +55,12 @@ class iTopDesignFormat
|
||||
'1.2' => array(
|
||||
'previous' => '1.1',
|
||||
'go_to_previous' => 'From12To11',
|
||||
'next' => '1.3',
|
||||
'go_to_next' => 'From12To13',
|
||||
),
|
||||
'1.3' => array(
|
||||
'previous' => '1.2',
|
||||
'go_to_previous' => 'From13To12',
|
||||
'next' => null,
|
||||
'go_to_next' => null,
|
||||
),
|
||||
@@ -473,6 +479,30 @@ class iTopDesignFormat
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Upgrade the format from version 1.2 to 1.3
|
||||
* @return void (Errors are logged)
|
||||
*/
|
||||
protected function From12To13($oFactory)
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Downgrade the format from version 1.3 to 1.2
|
||||
* @return void (Errors are logged)
|
||||
*/
|
||||
protected function From13To12($oFactory)
|
||||
{
|
||||
$oXPath = new DOMXPath($this->oDocument);
|
||||
|
||||
$oNodeList = $oXPath->query('/itop_design/module_designs/module_design');
|
||||
foreach ($oNodeList as $oNode)
|
||||
{
|
||||
$this->LogWarning('The module design defined in '.self::GetItopNodePath($oNode).' will be lost.');
|
||||
$this->DeleteNode($oNode);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Delete a node from the DOM and make sure to also remove the immediately following line break (DOMText), if any.
|
||||
* This prevents generating empty lines in the middle of the XML
|
||||
|
||||
Reference in New Issue
Block a user