mirror of
https://github.com/Combodo/iTop.git
synced 2026-04-23 18:48:51 +02:00
XML Datamodel: new format (version + zlists changed) - not compatible with 2.0 alpha!!!
SVN:trunk[2342]
This commit is contained in:
@@ -242,6 +242,30 @@ EOF;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to form a valid ZList from the array built by GetNodeAsArrayOfItems()
|
||||
*/
|
||||
protected function ArrayOfItemsToZList(&$aItems)
|
||||
{
|
||||
$aTransformed = array();
|
||||
foreach ($aItems as $key => $value)
|
||||
{
|
||||
if (is_null($value))
|
||||
{
|
||||
$aTransformed[] = $key;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (is_array($value))
|
||||
{
|
||||
$this->ArrayOfItemsToZList($value);
|
||||
}
|
||||
$aTransformed[$key] = $value;
|
||||
}
|
||||
}
|
||||
$aItems = $aTransformed;
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper to format the flags for an attribute, in a given state
|
||||
* @param object $oAttNode DOM node containing the information to build the flags
|
||||
@@ -847,6 +871,7 @@ EOF;
|
||||
if ($oListNode)
|
||||
{
|
||||
$aAttributes = $oListNode->GetNodeAsArrayOfItems();
|
||||
$this->ArrayOfItemsToZList($aAttributes);
|
||||
|
||||
$sZAttributes = var_export($aAttributes, true);
|
||||
$sZlists .= " MetaModel::Init_SetZListItems('$sListCode', $sZAttributes);\n";
|
||||
|
||||
@@ -1384,18 +1384,34 @@ class MFElement extends DOMElement
|
||||
if ($oItems)
|
||||
{
|
||||
$res = array();
|
||||
$aRanks = array();
|
||||
foreach($oItems->childNodes as $oItem)
|
||||
{
|
||||
// When an attribute is missing
|
||||
if ($oItem->hasAttribute('id'))
|
||||
{
|
||||
$key = $oItem->getAttribute('id');
|
||||
if (array_key_exists($key, $res))
|
||||
{
|
||||
// Houston!
|
||||
throw new DOMFormatException("Tag ".$oItem->getNodePath().", id '$key' already used!!!");
|
||||
}
|
||||
$res[$key] = $oItem->GetNodeAsArrayOfItems();
|
||||
}
|
||||
else
|
||||
{
|
||||
$res[] = $oItem->GetNodeAsArrayOfItems();
|
||||
}
|
||||
$sRank = $oItem->GetChildText('rank');
|
||||
if ($sRank != '')
|
||||
{
|
||||
$aRanks[] = (float) $sRank;
|
||||
}
|
||||
else
|
||||
{
|
||||
$aRanks[] = max($aRanks) + 1;
|
||||
}
|
||||
array_multisort($aRanks, $res);
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user