From adaf3a376cb6ace8e6d415fda0f6b7b54ed13b95 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Wed, 20 Oct 2010 15:55:30 +0000 Subject: [PATCH] Fixed Trac #258: cleanup of application context parameters. SVN:trunk[908] --- application/applicationcontext.class.inc.php | 28 +++++++++++++++++--- application/cmdbabstract.class.inc.php | 15 +++++++++-- application/displayblock.class.inc.php | 28 ++++++++++++++------ application/itopwebpage.class.inc.php | 23 ++++++++-------- application/menunode.class.inc.php | 9 ++++--- application/template.class.inc.php | 2 +- js/utils.js | 4 +-- pages/UI.php | 14 ++++++---- pages/UniversalSearch.php | 4 +-- pages/audit.php | 3 +-- pages/csvimport.php | 3 +-- pages/navigator.php | 4 +-- pages/run_query.php | 4 +-- pages/schema.php | 4 +-- 14 files changed, 92 insertions(+), 53 deletions(-) diff --git a/application/applicationcontext.class.inc.php b/application/applicationcontext.class.inc.php index fd29c7ab5..97bb0cd6c 100644 --- a/application/applicationcontext.class.inc.php +++ b/application/applicationcontext.class.inc.php @@ -57,9 +57,10 @@ class ApplicationContext if (empty(self::$aDefaultValues)) { self::$aDefaultValues = array(); + $aContext = utils::ReadParam('c', array()); foreach($this->aNames as $sName) { - $sValue = utils::ReadParam($sName, ''); + $sValue = isset($aContext[$sName]) ? $aContext[$sName] : ''; // TO DO: check if some of the context parameters are mandatory (or have default values) if (!empty($sValue)) { @@ -70,6 +71,20 @@ class ApplicationContext $this->aValues = self::$aDefaultValues; } + /** + * Returns the current value for the given parameter + * @param string $sParamName Name of the parameter to read + * @return mixed The value for this parameter + */ + public function GetCurrentValue($sParamName, $defaultValue = '') + { + if (isset($this->aValues[$sParamName])) + { + return $this->aValues[$sParamName]; + } + return $defaultValue; + } + /** * Returns the context as string with the format name1=value1&name2=value2.... * return string The context as a string to be appended to an href property @@ -79,7 +94,7 @@ class ApplicationContext $aParams = array(); foreach($this->aValues as $sName => $sValue) { - $aParams[] = $sName.'='.urlencode($sValue); + $aParams[] = "c[$sName]".'='.urlencode($sValue); } return implode("&", $aParams); } @@ -93,7 +108,7 @@ class ApplicationContext $sContext = ""; foreach($this->aValues as $sName => $sValue) { - $sContext .= "\n"; + $sContext .= "\n"; } return $sContext; } @@ -104,7 +119,12 @@ class ApplicationContext */ public function GetAsHash() { - return $this->aValues; + $aReturn = array(); + foreach($this->aValues as $sName => $sValue) + { + $aReturn["c[$sName]"] = $sValue; + } + return $aReturn; } /** diff --git a/application/cmdbabstract.class.inc.php b/application/cmdbabstract.class.inc.php index 64693fa20..e8236ff7b 100644 --- a/application/cmdbabstract.class.inc.php +++ b/application/cmdbabstract.class.inc.php @@ -899,7 +899,8 @@ EOF } $aOptions[MetaModel::GetName($sClassName)] = "