Bladeren bron

XML Modelization of the relations: declare the relations based on the XML (implicit declaration in XML, explicit in PHP -thus retrocompatible)

git-svn-id: http://svn.code.sf.net/p/itop/code/trunk@3522 a333f486-631f-4898-b8df-5754b55c2be0
romainq 10 jaren geleden
bovenliggende
commit
a8d2759375

+ 2 - 2
datamodels/1.x/itop-config-mgmt-1.0.0/main.itop-config-mgmt.php

@@ -17,8 +17,8 @@
 //   along with iTop. If not, see <http://www.gnu.org/licenses/>
 
 
-MetaModel::RegisterRelation("impacts", array("description"=>"Objects impacted by", "verb_down"=>"impacts", "verb_up"=>"depends on"));
-MetaModel::RegisterRelation("depends on", array("description"=>"That impacts ", "verb_down"=>"depends on", "verb_up"=>"impacts"));
+MetaModel::RegisterRelation('impacts');
+MetaModel::RegisterRelation('depends on');
 
 // Starting with iTop 1.2 you can restrict the list of organizations displayed in the drop-down list
 // by specifying a query as shown below. Note that this is NOT a security settings, since the

+ 0 - 3
datamodels/2.x/itop-config-mgmt/main.itop-config-mgmt.php

@@ -17,9 +17,6 @@
 //   along with iTop. If not, see <http://www.gnu.org/licenses/>
 
 
-MetaModel::RegisterRelation("impacts", array("description"=>"Objects impacted by", "verb_down"=>"impacts", "verb_up"=>"depends on"));
-MetaModel::RegisterRelation("depends on", array("description"=>"That impacts ", "verb_down"=>"depends on", "verb_up"=>"impacts"));
-
 // Starting with iTop 1.2 you can restrict the list of organizations displayed in the drop-down list
 // by specifying a query as shown below. Note that this is NOT a security settings, since the
 // choice 'All Organizations' will always be available in the menu

+ 17 - 1
setup/compiler.class.inc.php

@@ -34,6 +34,7 @@ class MFCompiler
 	protected $aLog;
 	protected $sMainPHPCode; // Code that goes into core/main.php
 	protected $aSnippets;
+	protected $aRelations;
 
 	public function __construct($oModelFactory)
 	{
@@ -45,6 +46,7 @@ class MFCompiler
 		$this->sMainPHPCode .= " * This file was automatically generated by the compiler on ".date('Y-m-d H:i:s')." -- DO NOT EDIT\n";
 		$this->sMainPHPCode .= " */\n";
 		$this->aSnippets = array();
+		$this->aRelations = array();
 	}
 
 	protected function Log($sText)
@@ -443,7 +445,20 @@ EOF;
 				$this->sMainPHPCode .= $aSnippet['content']."\n";
 			}
 		}
-		
+
+		if (count($this->aRelations) > 0)
+		{
+			$this->sMainPHPCode .= "\n";
+			$this->sMainPHPCode .= "/**\n";
+			$this->sMainPHPCode .= " * Relations\n";
+			$this->sMainPHPCode .= " */\n";
+			foreach($this->aRelations as $sRelationCode => $aData)
+			{
+				$sRelCodeSafe = addslashes($sRelationCode);
+				$this->sMainPHPCode .= "MetaModel::RegisterRelation('$sRelCodeSafe');\n";
+			}
+		}
+
 		// Write core/main.php
 		SetupUtils::builddir($sTempTargetDir.'/core');
 		$sPHPFile = $sTempTargetDir.'/core/main.php';
@@ -1397,6 +1412,7 @@ EOF;
 				if ($oRelation->tagName != 'relation') continue;
 
 				$sRelationId = $oRelation->getAttribute('id');
+				$this->aRelations[$sRelationId] = array('id' => $sRelationId);
 
 				$oNeighbours = $oRelation->GetUniqueElement('neighbours');
 				foreach($oNeighbours->childNodes as $oNeighbour)