diff --git a/application/menunode.class.inc.php b/application/menunode.class.inc.php index 0fb26ee4e..f5104a4ee 100644 --- a/application/menunode.class.inc.php +++ b/application/menunode.class.inc.php @@ -87,22 +87,31 @@ class ApplicationMenu * Main function to add a menu entry into the application, can be called during the definition * of the data model objects */ - static public function InsertMenu(MenuNode $oMenuNode, $iParentIndex = -1, $fRank) + static public function InsertMenu(MenuNode $oMenuNode, $iParentIndex, $fRank) { $index = self::GetMenuIndexById($oMenuNode->GetMenuId()); if ($index == -1) { // The menu does not already exist, insert it $index = count(self::$aMenusIndex); - self::$aMenusIndex[$index] = array( 'node' => $oMenuNode, 'children' => array()); + if ($iParentIndex == -1) { + $sParentId = ''; self::$aRootMenus[] = array ('rank' => $fRank, 'index' => $index); } else { + $sParentId = self::$aMenusIndex[$iParentIndex]['node']->GetMenuId(); self::$aMenusIndex[$iParentIndex]['children'][] = array ('rank' => $fRank, 'index' => $index); } + + // Note: At the time when 'parent', 'rank' and 'source_file' have been added for the reflection API, + // they were not used to display the menus (redundant or unused) + // + $aBacktrace = debug_backtrace(); + $sFile = $aBacktrace[2]["file"]; + self::$aMenusIndex[$index] = array('node' => $oMenuNode, 'children' => array(), 'parent' => $sParentId, 'rank' => $fRank, 'source_file' => $sFile); } else { @@ -111,6 +120,14 @@ class ApplicationMenu } return $index; } + + /** + * Reflection API - Get menu entries + */ + static public function ReflectionMenuNodes() + { + return self::$aMenusIndex; + } /** * Entry point to display the whole menu into the web page, used by iTopWebPage @@ -289,6 +306,11 @@ abstract class MenuNode protected $sMenuId; protected $index; + /** + * Properties reflecting how the node has been declared + */ + protected $aReflectionProperties; + /** * Class of objects to check if the menu is enabled, null if none */ @@ -323,12 +345,25 @@ abstract class MenuNode public function __construct($sMenuId, $iParentIndex = -1, $fRank = 0, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null) { $this->sMenuId = $sMenuId; + $this->aReflectionProperties = array(); + if (strlen($sEnableClass) > 0) + { + $this->aReflectionProperties['enable_class'] = $sEnableClass; + $this->aReflectionProperties['enable_action'] = $iActionCode; + $this->aReflectionProperties['enable_permission'] = $iAllowedResults; + $this->aReflectionProperties['enable_stimulus'] = $sEnableStimulus; + } $this->m_aEnableClasses = array($sEnableClass); $this->m_aEnableActions = array($iActionCode); $this->m_aEnableActionResults = array($iAllowedResults); $this->m_aEnableStimuli = array($sEnableStimulus); $this->index = ApplicationMenu::InsertMenu($this, $iParentIndex, $fRank); } + + public function ReflectionProperties() + { + return $this->aReflectionProperties; + } public function GetMenuId() { @@ -479,6 +514,7 @@ class TemplateMenuNode extends MenuNode { parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus); $this->sTemplateFile = $sTemplateFile; + $this->aReflectionProperties['template_file'] = $sTemplateFile; } public function GetHyperlink($aExtraParams) @@ -537,6 +573,8 @@ class OQLMenuNode extends MenuNode $this->sOQL = $sOQL; $this->bSearch = $bSearch; $this->m_aParams = array(); + $this->aReflectionProperties['oql'] = $sOQL; + $this->aReflectionProperties['do_search'] = $bSearch; // Enhancement: we could set as the "enable" condition that the user has enough rights to "read" the objects // of the class specified by the OQL... } @@ -548,6 +586,10 @@ class OQLMenuNode extends MenuNode public function SetParameters($aParams) { $this->m_aParams = $aParams; + foreach($aParams as $sKey => $value) + { + $this->aReflectionProperties[$sKey] = $value; + } } public function RenderContent(WebPage $oPage, $aExtraParams = array()) @@ -614,6 +656,7 @@ class SearchMenuNode extends MenuNode parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus); $this->sPageTitle = "Menu:$sMenuId+"; $this->sClass = $sClass; + $this->aReflectionProperties['class'] = $sClass; } public function RenderContent(WebPage $oPage, $aExtraParams = array()) @@ -653,6 +696,7 @@ class WebPageMenuNode extends MenuNode { parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus); $this->sHyperlink = $sHyperlink; + $this->aReflectionProperties['url'] = $sHyperlink; } public function GetHyperlink($aExtraParams) @@ -690,6 +734,7 @@ class NewObjectMenuNode extends MenuNode { parent::__construct($sMenuId, $iParentIndex, $fRank); $this->sClass = $sClass; + $this->aReflectionProperties['class'] = $sClass; } public function GetHyperlink($aExtraParams) diff --git a/core/attributedef.class.inc.php b/core/attributedef.class.inc.php index e1a2d4515..2f6c82f50 100644 --- a/core/attributedef.class.inc.php +++ b/core/attributedef.class.inc.php @@ -116,6 +116,8 @@ abstract class AttributeDefinition $this->m_aParams = $aParams; $this->ConsistencyCheck(); } + + // Left here for backward compatibility, deprecated in 2.0 public function OverloadParams($aParams) { foreach ($aParams as $sParam => $value) @@ -130,6 +132,12 @@ abstract class AttributeDefinition } } } + + public function GetParams() + { + return $this->m_aParams; + } + public function SetHostClass($sHostClass) { $this->m_sHostClass = $sHostClass; @@ -141,7 +149,7 @@ abstract class AttributeDefinition // Note: I could factorize this code with the parameter management made for the AttributeDef class // to be overloaded - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array(); } @@ -444,7 +452,7 @@ abstract class AttributeDefinition */ class AttributeLinkedSet extends AttributeDefinition { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("allowed_values", "depends_on", "linked_class", "ext_key_to_me", "count_min", "count_max")); } @@ -754,7 +762,7 @@ class AttributeLinkedSet extends AttributeDefinition */ class AttributeLinkedSetIndirect extends AttributeLinkedSet { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("ext_key_to_remote")); } @@ -771,7 +779,7 @@ class AttributeLinkedSetIndirect extends AttributeLinkedSet */ class AttributeDBFieldVoid extends AttributeDefinition { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("allowed_values", "depends_on", "sql")); } @@ -857,7 +865,7 @@ class AttributeDBFieldVoid extends AttributeDefinition */ class AttributeDBField extends AttributeDBFieldVoid { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("default_value", "is_null_allowed")); } @@ -872,7 +880,7 @@ class AttributeDBField extends AttributeDBFieldVoid */ class AttributeInteger extends AttributeDBField { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -968,7 +976,7 @@ class AttributeInteger extends AttributeDBField */ class AttributeDecimal extends AttributeDBField { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array('digits', 'decimals' /* including precision */)); } @@ -1063,7 +1071,7 @@ class AttributeDecimal extends AttributeDBField */ class AttributeBoolean extends AttributeInteger { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -1094,7 +1102,7 @@ class AttributeBoolean extends AttributeInteger */ class AttributeString extends AttributeDBField { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -1220,7 +1228,7 @@ class AttributeString extends AttributeDBField */ class AttributeClass extends AttributeString { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("class_category", "more_values")); } @@ -1272,7 +1280,7 @@ class AttributeClass extends AttributeString */ class AttributeApplicationLanguage extends AttributeString { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); } @@ -1362,7 +1370,7 @@ class AttributeFinalClass extends AttributeString */ class AttributePassword extends AttributeString { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -1924,7 +1932,7 @@ class AttributeTemplateHTML extends AttributeText */ class AttributeEnum extends AttributeString { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -2094,7 +2102,7 @@ class AttributeDateTime extends AttributeDBField return "Y-m-d H:i:s"; } - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -2405,7 +2413,7 @@ class AttributeDate extends AttributeDateTime return "Y-m-d"; } - static protected function ListExpectedParams() + static public function ListExpectedParams() { return parent::ListExpectedParams(); //return array_merge(parent::ListExpectedParams(), array()); @@ -2491,7 +2499,7 @@ class AttributeDeadline extends AttributeDateTime */ class AttributeExternalKey extends AttributeDBFieldVoid { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("targetclass", "is_null_allowed", "on_target_delete")); } @@ -2608,7 +2616,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey { protected $m_sTargetClass; - static protected function ListExpectedParams() + static public function ListExpectedParams() { $aParams = parent::ListExpectedParams(); $idx = array_search('targetclass', $aParams); @@ -2732,7 +2740,7 @@ class AttributeHierarchicalKey extends AttributeExternalKey */ class AttributeExternalField extends AttributeDefinition { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("extkey_attcode", "target_attcode")); } @@ -2959,7 +2967,7 @@ class AttributeExternalField extends AttributeDefinition */ class AttributeURL extends AttributeString { - static protected function ListExpectedParams() + static public function ListExpectedParams() { //return parent::ListExpectedParams(); return array_merge(parent::ListExpectedParams(), array("target")); @@ -2993,7 +3001,7 @@ class AttributeURL extends AttributeString */ class AttributeBlob extends AttributeDefinition { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("depends_on")); } @@ -3140,7 +3148,7 @@ class AttributeBlob extends AttributeDefinition */ class AttributeOneWayPassword extends AttributeDefinition { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array("depends_on")); } @@ -3413,7 +3421,7 @@ class AttributePropertySet extends AttributeTable */ class AttributeComputedFieldVoid extends AttributeDefinition { - static protected function ListExpectedParams() + static public function ListExpectedParams() { return array_merge(parent::ListExpectedParams(), array()); } diff --git a/core/filterdef.class.inc.php b/core/filterdef.class.inc.php index a56752299..a744c170e 100644 --- a/core/filterdef.class.inc.php +++ b/core/filterdef.class.inc.php @@ -50,6 +50,7 @@ abstract class FilterDefinition $this->ConsistencyCheck(); } + // Left here for backward compatibility, deprecated in 2.0 public function OverloadParams($aParams) { foreach ($aParams as $sParam => $value) diff --git a/core/metamodel.class.php b/core/metamodel.class.php index d88ea0b25..edd2675b1 100644 --- a/core/metamodel.class.php +++ b/core/metamodel.class.php @@ -1549,6 +1549,8 @@ if (!array_key_exists($sAttCode, self::$m_aAttribDefs[$sClass])) self::$m_aChildClasses[$sAncestorClass][] = $sTargetClass; } } + + // Left here for backward compatibility, deprecated in 2.0 public static function Init_OverloadAttributeParams($sAttCode, $aParams) { $sTargetClass = self::GetCallersPHPClass("Init"); diff --git a/core/valuesetdef.class.inc.php b/core/valuesetdef.class.inc.php index 421ce4b91..ce7e9ee12 100644 --- a/core/valuesetdef.class.inc.php +++ b/core/valuesetdef.class.inc.php @@ -208,6 +208,11 @@ class ValueSetObjects extends ValueSetDefinition { return 'Filter: '.$this->m_sFilterExpr; } + + public function GetFilterExpression() + { + return $this->m_sFilterExpr; + } } @@ -299,6 +304,13 @@ class ValueSetEnum extends ValueSetDefinition $this->m_values = $Values; } + // Helper to export the datat model + public function GetValueList() + { + $this->LoadValues($aArgs = array()); + return $this->m_aValues; + } + protected function LoadValues($aArgs) { if (is_array($this->m_values))