Module: nagvis Branch: master Commit: d61d817b4c6e82bc850fba45889a5b6af3cba966 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=d61d817b4c6e82bc850fba45889a5b6af3cba966
Author: LaMi <[email protected]> Date: Wed Mar 24 22:25:37 2010 +0100 Added some performance/memory improvements by reducing gettext calls --- share/server/core/classes/objects/NagVisHost.php | 3 + .../core/classes/objects/NagVisHostgroup.php | 3 + share/server/core/classes/objects/NagVisMapObj.php | 15 +++- share/server/core/classes/objects/NagVisObject.php | 80 ++++++++++++++------ .../server/core/classes/objects/NagVisService.php | 3 + .../core/classes/objects/NagVisServicegroup.php | 5 + 6 files changed, 81 insertions(+), 28 deletions(-) diff --git a/share/server/core/classes/objects/NagVisHost.php b/share/server/core/classes/objects/NagVisHost.php index fb625bd..42f2250 100644 --- a/share/server/core/classes/objects/NagVisHost.php +++ b/share/server/core/classes/objects/NagVisHost.php @@ -27,6 +27,9 @@ * @author Lars Michelsen <[email protected]> */ class NagVisHost extends NagiosHost { + protected static $langType = null; + protected static $langSelf = null; + protected static $langChild = null; /** * Class constructor diff --git a/share/server/core/classes/objects/NagVisHostgroup.php b/share/server/core/classes/objects/NagVisHostgroup.php index 70d434f..2669719 100644 --- a/share/server/core/classes/objects/NagVisHostgroup.php +++ b/share/server/core/classes/objects/NagVisHostgroup.php @@ -27,6 +27,9 @@ * @author Lars Michelsen <[email protected]> */ class NagVisHostgroup extends NagiosHostgroup { + protected static $langType = null; + protected static $langSelf = null; + protected static $langChild = null; /** * Class constructor diff --git a/share/server/core/classes/objects/NagVisMapObj.php b/share/server/core/classes/objects/NagVisMapObj.php index 24f4095..3c4f3ca 100644 --- a/share/server/core/classes/objects/NagVisMapObj.php +++ b/share/server/core/classes/objects/NagVisMapObj.php @@ -30,6 +30,10 @@ class NagVisMapObj extends NagVisStatefulObject { protected $MAPCFG; private $MAP; + protected static $langType = null; + protected static $langSelf = null; + protected static $langChild = null; + protected $members; protected $linkedMaps; @@ -372,16 +376,16 @@ class NagVisMapObj extends NagVisStatefulObject { private function fetchMapObjects() { foreach($this->MAPCFG->getValidObjectTypes() AS $type) { if($type != 'global' && $type != 'template' && is_array($objs = $this->MAPCFG->getDefinitions($type))){ + $typeKeys = $this->MAPCFG->getValidTypeKeys($type); foreach($objs AS $index => $objConf) { - $OBJ = ''; - // workaround - //$objConf['id'] = $objConf['object_id']; $objConf['id'] = $index; // merge with "global" settings - foreach($this->MAPCFG->getValidTypeKeys($type) AS $key) { - $objConf[$key] = $this->MAPCFG->getValue($type, $index, $key); + foreach($typeKeys AS $key) { + if(!isset($objConf[$key])) { + $objConf[$key] = $this->MAPCFG->getValue($type, $index, $key); + } } switch($type) { @@ -426,6 +430,7 @@ class NagVisMapObj extends NagVisStatefulObject { break; default: new GlobalMessage('ERROR', $this->CORE->getLang()->getText('unknownObject', 'TYPE~'.$type.',MAPNAME~'.$this->getName())); + $OBJ = null; break; } diff --git a/share/server/core/classes/objects/NagVisObject.php b/share/server/core/classes/objects/NagVisObject.php index 95ddd0b..766f90e 100644 --- a/share/server/core/classes/objects/NagVisObject.php +++ b/share/server/core/classes/objects/NagVisObject.php @@ -247,31 +247,65 @@ class NagVisObject { * FIXME: Find another place for that! This is a bad place for language strings! */ - // Get the child name label - switch($this->type) { - case 'host': - $sName = $this->CORE->getLang()->getText('hostname'); - $sChildName = $this->CORE->getLang()->getText('servicename'); - break; - case 'hostgroup': - $sName = $this->CORE->getLang()->getText('hostgroupname'); - $sChildName = $this->CORE->getLang()->getText('hostname'); - break; - case 'servicegroup': - $sName = $this->CORE->getLang()->getText('servicegroupname'); - $sChildName = $this->CORE->getLang()->getText('servicename'); - break; - default: - $sName = $this->CORE->getLang()->getText('mapname'); - $sChildName = $this->CORE->getLang()->getText('objectname'); - break; + if($this instanceof NagVisStatefulObject) { + switch($this->type) { + case 'host': + if(NagVisHost::$langType === null) { + NagVisHost::$langType = $this->CORE->getLang()->getText('host'); + NagVisHost::$langSelf = $this->CORE->getLang()->getText('hostname'); + NagVisHost::$langChild = $this->CORE->getLang()->getText('servicename'); + } + + $arr['lang_obj_type'] = NagVisHost::$langType; + $arr['lang_name'] = NagVisHost::$langSelf; + $arr['lang_child_name'] = NagVisHost::$langChild; + break; + case 'service': + if(NagVisService::$langType === null) { + NagVisService::$langType = $this->CORE->getLang()->getText('service'); + NagVisService::$langSelf = $this->CORE->getLang()->getText('servicename'); + } + + $arr['lang_obj_type'] = NagVisService::$langType; + $arr['lang_name'] = NagVisService::$langSelf; + break; + case 'hostgroup': + if(NagVisHostgroup::$langType === null) { + NagVisHostgroup::$langType = $this->CORE->getLang()->getText('hostgroup'); + NagVisHostgroup::$langSelf = $this->CORE->getLang()->getText('hostgroupname'); + NagVisHostgroup::$langChild = $this->CORE->getLang()->getText('hostname'); + } + + $arr['lang_obj_type'] = NagVisHostgroup::$langType; + $arr['lang_name'] = NagVisHostgroup::$langSelf; + $arr['lang_child_name'] = NagVisHostgroup::$langChild; + break; + case 'servicegroup': + if(NagVisServicegroup::$langType === null) { + NagVisServicegroup::$langType = $this->CORE->getLang()->getText('servicegroup'); + NagVisServicegroup::$langSelf = $this->CORE->getLang()->getText('servicegroupname'); + NagVisServicegroup::$langChild = $this->CORE->getLang()->getText('servicename'); + NagVisServicegroup::$langChild1 = $this->CORE->getLang()->getText('hostname'); + } + + $arr['lang_obj_type'] = NagVisServicegroup::$langType; + $arr['lang_name'] = NagVisServicegroup::$langSelf; + $arr['lang_child_name'] = NagVisServicegroup::$langChild; + break; + case 'map': + if(NagVisMapObj::$langType === null) { + NagVisMapObj::$langType = $this->CORE->getLang()->getText('map'); + NagVisMapObj::$langSelf = $this->CORE->getLang()->getText('mapname'); + NagVisMapObj::$langChild = $this->CORE->getLang()->getText('objectname'); + } + + $arr['lang_obj_type'] = NagVisServicegroup::$langType; + $arr['lang_name'] = NagVisServicegroup::$langSelf; + $arr['lang_child_name'] = NagVisServicegroup::$langChild; + break; + } } - $arr['lang_obj_type'] = $this->CORE->getLang()->getText($this->type); - $arr['lang_name'] = $sName; - $arr['lang_child_name'] = $sChildName; - $arr['lang_child_name1'] = $this->CORE->getLang()->getText('hostname'); - // I want only "name" in js if($this->type != 'shape' && $this->type != 'textbox' && $this->type != 'line') { $arr['name'] = $this->getName(); diff --git a/share/server/core/classes/objects/NagVisService.php b/share/server/core/classes/objects/NagVisService.php index 80517d9..be9dbc5 100644 --- a/share/server/core/classes/objects/NagVisService.php +++ b/share/server/core/classes/objects/NagVisService.php @@ -29,6 +29,9 @@ class NagVisService extends NagiosService { protected $gadget_url; + protected static $langType = null; + protected static $langSelf = null; + /** * Class constructor * diff --git a/share/server/core/classes/objects/NagVisServicegroup.php b/share/server/core/classes/objects/NagVisServicegroup.php index 2d81db9..83d9af1 100644 --- a/share/server/core/classes/objects/NagVisServicegroup.php +++ b/share/server/core/classes/objects/NagVisServicegroup.php @@ -27,6 +27,11 @@ * @author Lars Michelsen <[email protected]> */ class NagVisServicegroup extends NagiosServicegroup { + protected static $langType = null; + protected static $langSelf = null; + protected static $langChild = null; + protected static $langChild1 = null; + /** * Class constructor * ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
