|
@@ -87,22 +87,31 @@ class ApplicationMenu
|
|
* Main function to add a menu entry into the application, can be called during the definition
|
|
* Main function to add a menu entry into the application, can be called during the definition
|
|
* of the data model objects
|
|
* 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());
|
|
$index = self::GetMenuIndexById($oMenuNode->GetMenuId());
|
|
if ($index == -1)
|
|
if ($index == -1)
|
|
{
|
|
{
|
|
// The menu does not already exist, insert it
|
|
// The menu does not already exist, insert it
|
|
$index = count(self::$aMenusIndex);
|
|
$index = count(self::$aMenusIndex);
|
|
- self::$aMenusIndex[$index] = array( 'node' => $oMenuNode, 'children' => array());
|
|
|
|
|
|
+
|
|
if ($iParentIndex == -1)
|
|
if ($iParentIndex == -1)
|
|
{
|
|
{
|
|
|
|
+ $sParentId = '';
|
|
self::$aRootMenus[] = array ('rank' => $fRank, 'index' => $index);
|
|
self::$aRootMenus[] = array ('rank' => $fRank, 'index' => $index);
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
|
|
+ $sParentId = self::$aMenusIndex[$iParentIndex]['node']->GetMenuId();
|
|
self::$aMenusIndex[$iParentIndex]['children'][] = array ('rank' => $fRank, 'index' => $index);
|
|
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
|
|
else
|
|
{
|
|
{
|
|
@@ -111,6 +120,14 @@ class ApplicationMenu
|
|
}
|
|
}
|
|
return $index;
|
|
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
|
|
* Entry point to display the whole menu into the web page, used by iTopWebPage
|
|
@@ -290,6 +307,11 @@ abstract class MenuNode
|
|
protected $index;
|
|
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
|
|
* Class of objects to check if the menu is enabled, null if none
|
|
*/
|
|
*/
|
|
protected $m_aEnableClasses;
|
|
protected $m_aEnableClasses;
|
|
@@ -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)
|
|
public function __construct($sMenuId, $iParentIndex = -1, $fRank = 0, $sEnableClass = null, $iActionCode = null, $iAllowedResults = UR_ALLOWED_YES, $sEnableStimulus = null)
|
|
{
|
|
{
|
|
$this->sMenuId = $sMenuId;
|
|
$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_aEnableClasses = array($sEnableClass);
|
|
$this->m_aEnableActions = array($iActionCode);
|
|
$this->m_aEnableActions = array($iActionCode);
|
|
$this->m_aEnableActionResults = array($iAllowedResults);
|
|
$this->m_aEnableActionResults = array($iAllowedResults);
|
|
$this->m_aEnableStimuli = array($sEnableStimulus);
|
|
$this->m_aEnableStimuli = array($sEnableStimulus);
|
|
$this->index = ApplicationMenu::InsertMenu($this, $iParentIndex, $fRank);
|
|
$this->index = ApplicationMenu::InsertMenu($this, $iParentIndex, $fRank);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ public function ReflectionProperties()
|
|
|
|
+ {
|
|
|
|
+ return $this->aReflectionProperties;
|
|
|
|
+ }
|
|
|
|
|
|
public function GetMenuId()
|
|
public function GetMenuId()
|
|
{
|
|
{
|
|
@@ -479,6 +514,7 @@ class TemplateMenuNode extends MenuNode
|
|
{
|
|
{
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
|
|
$this->sTemplateFile = $sTemplateFile;
|
|
$this->sTemplateFile = $sTemplateFile;
|
|
|
|
+ $this->aReflectionProperties['template_file'] = $sTemplateFile;
|
|
}
|
|
}
|
|
|
|
|
|
public function GetHyperlink($aExtraParams)
|
|
public function GetHyperlink($aExtraParams)
|
|
@@ -537,6 +573,8 @@ class OQLMenuNode extends MenuNode
|
|
$this->sOQL = $sOQL;
|
|
$this->sOQL = $sOQL;
|
|
$this->bSearch = $bSearch;
|
|
$this->bSearch = $bSearch;
|
|
$this->m_aParams = array();
|
|
$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
|
|
// 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...
|
|
// of the class specified by the OQL...
|
|
}
|
|
}
|
|
@@ -614,6 +652,7 @@ class SearchMenuNode extends MenuNode
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
|
|
$this->sPageTitle = "Menu:$sMenuId+";
|
|
$this->sPageTitle = "Menu:$sMenuId+";
|
|
$this->sClass = $sClass;
|
|
$this->sClass = $sClass;
|
|
|
|
+ $this->aReflectionProperties['class'] = $sClass;
|
|
}
|
|
}
|
|
|
|
|
|
public function RenderContent(WebPage $oPage, $aExtraParams = array())
|
|
public function RenderContent(WebPage $oPage, $aExtraParams = array())
|
|
@@ -653,6 +692,7 @@ class WebPageMenuNode extends MenuNode
|
|
{
|
|
{
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank, $sEnableClass, $iActionCode, $iAllowedResults, $sEnableStimulus);
|
|
$this->sHyperlink = $sHyperlink;
|
|
$this->sHyperlink = $sHyperlink;
|
|
|
|
+ $this->aReflectionProperties['url'] = $sHyperlink;
|
|
}
|
|
}
|
|
|
|
|
|
public function GetHyperlink($aExtraParams)
|
|
public function GetHyperlink($aExtraParams)
|
|
@@ -690,6 +730,7 @@ class NewObjectMenuNode extends MenuNode
|
|
{
|
|
{
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank);
|
|
parent::__construct($sMenuId, $iParentIndex, $fRank);
|
|
$this->sClass = $sClass;
|
|
$this->sClass = $sClass;
|
|
|
|
+ $this->aReflectionProperties['class'] = $sClass;
|
|
}
|
|
}
|
|
|
|
|
|
public function GetHyperlink($aExtraParams)
|
|
public function GetHyperlink($aExtraParams)
|