Module: nagvis Branch: master Commit: 92acee65e81286224ddb7e5d24819bab27f00e0a URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=92acee65e81286224ddb7e5d24819bab27f00e0a
Author: Lars Michelsen <[email protected]> Date: Fri Sep 17 18:25:27 2010 +0200 Some code cleanups --- share/server/core/classes/CoreUriHandler.php | 67 ++++++++------------------ 1 files changed, 20 insertions(+), 47 deletions(-) diff --git a/share/server/core/classes/CoreUriHandler.php b/share/server/core/classes/CoreUriHandler.php index 2414254..ae6085a 100644 --- a/share/server/core/classes/CoreUriHandler.php +++ b/share/server/core/classes/CoreUriHandler.php @@ -53,13 +53,11 @@ class CoreUriHandler { $sReturn = false; // Transform parameter aliases - if(isset($this->aAliases[$sKey])) { + if(isset($this->aAliases[$sKey])) $sKey = $this->aAliases[$sKey]; - } - if($this->isSetAndNotEmpty($sKey)) { + if($this->isSetAndNotEmpty($sKey)) $sReturn = $this->aOpts[$sKey]; - } $this->aOpts[$sKey] = $sVal; @@ -72,15 +70,13 @@ class CoreUriHandler { public function get($sKey) { // Transform parameter aliases - if(isset($this->aAliases[$sKey])) { + if(isset($this->aAliases[$sKey])) $sKey = $this->aAliases[$sKey]; - } - if($this->isSetAndNotEmpty($sKey)) { + if($this->isSetAndNotEmpty($sKey)) return $this->aOpts[$sKey]; - } else { + else return false; - } } public function parseModSpecificUri($aKeys) { @@ -89,26 +85,15 @@ class CoreUriHandler { $bValid = true; if($sMatch !== '') { // When param not set initialize it as empty string - if(!isset($_GET[$key])) { + if(!isset($_GET[$key])) $_GET[$key] = ''; - } // Validate single value or multiple (array) - if(is_array($_GET[$key])) { - foreach($_GET[$key] AS $val) { - if(preg_match($sMatch, $val)) { - $bValid = true; - } else { - $bValid = false; - } - } - } else { - if(preg_match($sMatch, $_GET[$key])) { - $bValid = true; - } else { - $bValid = false; - } - } + if(is_array($_GET[$key])) + foreach($_GET[$key] AS $val) + $bValid = preg_match($sMatch, $val); + else + $bValid = preg_match($sMatch, $_GET[$key]); } if($bValid) { @@ -126,53 +111,41 @@ class CoreUriHandler { // Remove the first slash and then explode by slashes //$this->aOpts = explode('/', substr($sRequest,1)); - if(isset($_GET['mod'])) { + if(isset($_GET['mod'])) $this->aOpts['mod'] = $_GET['mod']; - } - if(isset($_GET['act'])) { + if(isset($_GET['act'])) $this->aOpts['act'] = $_GET['act']; - } } private function setDefaults() { // Handle default options when no module given - if(!$this->isSetAndNotEmpty('mod')) { + if(!$this->isSetAndNotEmpty('mod')) $this->aOpts['mod'] = $this->CORE->getMainCfg()->getValue('global', 'startmodule'); - } // Handle default options when no action given - if(!$this->isSetAndNotEmpty('act')) { + if(!$this->isSetAndNotEmpty('act')) $this->aOpts['act'] = $this->CORE->getMainCfg()->getValue('global', 'startaction'); - } } private function validate() { $bValid = true; // Validate each param - foreach($this->aOpts AS $val) { - if(!preg_match(MATCH_URI_PART, $val)) { + foreach($this->aOpts AS $val) + if(!preg_match(MATCH_URI_PART, $val)) $bValid = false; - } - } // If one param is invalid send the user to 404 page - if($bValid === false) { + if($bValid === false) new GlobalMessage('ERROR', $this->CORE->getLang()->getText('The given url is not valid')); - } } public function isSetAndNotEmpty($sKey) { // Transform parameter aliases - if(isset($this->aAliases[$sKey])) { + if(isset($this->aAliases[$sKey])) $sKey = $this->aAliases[$sKey]; - } - if(isset($this->aOpts[$sKey]) && $this->aOpts[$sKey] != '') { - return true; - } else { - return false; - } + return isset($this->aOpts[$sKey]) && $this->aOpts[$sKey] != ''); } } ------------------------------------------------------------------------------ Start uncovering the many advantages of virtual appliances and start using them to simplify application deployment and accelerate your shift to cloud computing. http://p.sf.net/sfu/novell-sfdev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
