Author: Lars Michelsen <[email protected]>
Date: Sat Feb 26 11:13:16 2011 +0100
Committer: Lars Michelsen <[email protected]>
Commit-Date: Sat Feb 26 10:13:16 2011 +0000
Recoded to cleaner css file handling of context/hover menus
---
share/frontend/nagvis-js/js/frontend.js | 64 ++++++++++++-----------
share/server/core/classes/CoreModGeneral.php | 5 +-
share/server/core/classes/NagVisContextMenu.php | 10 +++-
share/server/core/classes/NagVisHoverMenu.php | 10 +++-
4 files changed, 50 insertions(+), 39 deletions(-)
diff --git a/share/frontend/nagvis-js/js/frontend.js
b/share/frontend/nagvis-js/js/frontend.js
index f6398d8..b83b8c2 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -421,7 +421,6 @@ function getHoverTemplateChildCode(sTemplateCode) {
*/
function getHoverTemplates() {
var aUrlParts = [];
- var aTemplateObjects;
// Loop all map objects to get the used hover templates
for(var i in oMapObjects) {
@@ -435,32 +434,33 @@ function getHoverTemplates() {
}
// Build string for bulk fetching the templates
- for(var i in oHoverTemplates) {
- if(i !== 'Inherits') {
+ for(var i in oHoverTemplates)
+ if(i !== 'Inherits')
aUrlParts.push('&name[]='+i);
-
- // Load template css file
- // This is needed for some old browsers which do no
load css files
- // which are included in such fetched html code
- var oLink = document.createElement('link');
- oLink.href =
oGeneralProperties.path_templates+i+'.hover.css';
- oLink.rel = 'stylesheet';
- oLink.type = 'text/css';
-
document.getElementsByTagName("head")[0].appendChild(oLink);
- oLink = null;
- }
- }
// Get the needed templates via bulk request
- aTemplateObjects =
getBulkRequest(oGeneralProperties.path_server+'?mod=General&act=getHoverTemplate',
- aUrlParts,
oWorkerProperties.worker_request_max_length, true);
+ var aTemplateObjects =
getBulkRequest(oGeneralProperties.path_server+'?mod=General&act=getHoverTemplate',
+ aUrlParts,
oWorkerProperties.worker_request_max_length, true);
// Set the code to global object oHoverTemplates
if(aTemplateObjects.length > 0)
for(var i = 0, len = aTemplateObjects.length; i < len; i++) {
oHoverTemplates[aTemplateObjects[i].name] =
aTemplateObjects[i].code;
oHoverTemplatesChild[aTemplateObjects[i].name] =
getHoverTemplateChildCode(aTemplateObjects[i].code);
+
+ // Load css file is one is available
+ if(isset(aTemplateObjects[i].css_file)) {
+ // This is needed for some old browsers which
do no load css files
+ // which are included in such fetched html code
+ var oLink = document.createElement('link');
+ oLink.href = aTemplateObjects[i].css_file
+ oLink.rel = 'stylesheet';
+ oLink.type = 'text/css';
+
document.getElementsByTagName("head")[0].appendChild(oLink);
+ oLink = null;
+ }
}
+ aTemplateObjects = null;
}
/**
@@ -472,7 +472,6 @@ function getHoverTemplates() {
*/
function getContextTemplates() {
var aUrlParts = [];
- var aTemplateObjects;
// Loop all map objects to get the used templates
for(var i in oMapObjects)
@@ -486,29 +485,32 @@ function getContextTemplates() {
oContextTemplates[oMapObjects[i].conf.context_template]
= '';
// Build string for bulk fetching the templates
- for(var sName in oContextTemplates) {
- if(sName !== 'Inherits') {
+ for(var sName in oContextTemplates)
+ if(sName !== 'Inherits')
aUrlParts.push('&name[]='+sName);
-
- // Load template css file
- var oLink = document.createElement('link');
- oLink.href =
oGeneralProperties.path_templates+sName+'.context.css';
- oLink.rel = 'stylesheet';
- oLink.type = 'text/css';
-
document.getElementsByTagName("head")[0].appendChild(oLink);
- oLink = null;
- }
- }
// Get the needed templates via bulk request
- aTemplateObjects =
getBulkRequest(oGeneralProperties.path_server+'?mod=General&act=getContextTemplate',
aUrlParts, oWorkerProperties.worker_request_max_length, true);
+ var aTemplateObjects =
getBulkRequest(oGeneralProperties.path_server+'?mod=General&act=getContextTemplate',
aUrlParts, oWorkerProperties.worker_request_max_length, true);
// Set the code to global object oContextTemplates
if(aTemplateObjects.length > 0) {
for(var i = 0, len = aTemplateObjects.length; i < len; i++) {
oContextTemplates[aTemplateObjects[i].name] =
aTemplateObjects[i].code;
+
+ // Load css file is one is available
+ if(isset(aTemplateObjects[i].css_file)) {
+ // This is needed for some old browsers which
do no load css files
+ // which are included in such fetched html code
+ var oLink = document.createElement('link');
+ oLink.href = aTemplateObjects[i].css_file
+ oLink.rel = 'stylesheet';
+ oLink.type = 'text/css';
+
document.getElementsByTagName("head")[0].appendChild(oLink);
+ oLink = null;
+ }
}
}
+ aTemplateObjects = null;
}
/**
diff --git a/share/server/core/classes/CoreModGeneral.php
b/share/server/core/classes/CoreModGeneral.php
index d69b248..54284a1 100644
--- a/share/server/core/classes/CoreModGeneral.php
+++ b/share/server/core/classes/CoreModGeneral.php
@@ -110,8 +110,9 @@ class CoreModGeneral extends CoreModule {
else
$OBJ = new NagVisContextMenu($this->CORE,
$sName);
- $arrReturn[] = Array('name' => $sName,
- 'code' => str_replace("\r\n", "",
str_replace("\n", "", $OBJ->__toString())));
+ $arrReturn[] = Array('name' => $sName,
+ 'css_file' => $OBJ->getCssFile(),
+ 'code' => str_replace("\r\n",
"", str_replace("\n", "", $OBJ->__toString())));
}
return json_encode($arrReturn);
diff --git a/share/server/core/classes/NagVisContextMenu.php
b/share/server/core/classes/NagVisContextMenu.php
index 1df575a..26a5b9f 100644
--- a/share/server/core/classes/NagVisContextMenu.php
+++ b/share/server/core/classes/NagVisContextMenu.php
@@ -47,8 +47,8 @@ class NagVisContextMenu {
$this->OBJPAGE = $OBJ;
$this->templateName = $templateName;
- $this->pathHtmlBase =
$this->CORE->getMainCfg()->getValue('paths','htmlbase');
- $this->pathTemplateFile =
$this->CORE->getMainCfg()->getValue('paths','templates').$this->templateName.'.context.html';
+ $this->pathHtmlBase =
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase');
+ $this->pathTemplateFile =
$this->CORE->getMainCfg()->getPath('templates',
$this->templateName.'.context.html');
$this->CACHE = new GlobalFileCache($this->CORE,
$this->pathTemplateFile,
$this->CORE->getMainCfg()->getValue('paths','var').'context-'.$this->templateName.'-'.$this->CORE->getLang()->getCurrentLanguage().'.cache');
@@ -125,7 +125,7 @@ class NagVisContextMenu {
}
if(strpos($this->code,'[html_templates]') !== FALSE) {
- $this->code =
str_replace('[html_templates]',$this->CORE->getMainCfg()->getValue('paths','htmltemplates'),$this->code);
+ $this->code =
str_replace('[html_templates]',$this->CORE->getMainCfg()->getPath('templates',
'html'),$this->code);
}
if(strpos($this->code,'[html_template_images]') !== FALSE) {
@@ -168,5 +168,9 @@ class NagVisContextMenu {
private function checkTemplateExists($printErr) {
return
GlobalCore::getInstance()->checkExisting($this->pathTemplateFile, $printErr);
}
+
+ public function getCssFile() {
+ return $this->CORE->getMainCfg()->getPath('templates',
$this->templateName.'.context.css', 'html');
+ }
}
?>
diff --git a/share/server/core/classes/NagVisHoverMenu.php
b/share/server/core/classes/NagVisHoverMenu.php
index a277fcf..0a93bd2 100644
--- a/share/server/core/classes/NagVisHoverMenu.php
+++ b/share/server/core/classes/NagVisHoverMenu.php
@@ -48,8 +48,8 @@ class NagVisHoverMenu {
$this->templateName = $templateName;
- $this->pathHtmlBase =
$this->CORE->getMainCfg()->getValue('paths','htmlbase');
- $this->pathTemplateFile =
$this->CORE->getMainCfg()->getValue('paths','templates').$this->templateName.'.hover.html';
+ $this->pathHtmlBase =
$this->CORE->getMainCfg()->getValue('paths','htmlbase');
+ $this->pathTemplateFile =
$this->CORE->getMainCfg()->getPath('templates',
$this->templateName.'.hover.html');
$this->CACHE = new GlobalFileCache($this->CORE,
$this->pathTemplateFile,
$this->CORE->getMainCfg()->getValue('paths','var').'hover-'.$this->templateName.'-'.$this->CORE->getLang()->getCurrentLanguage().'.cache');
@@ -176,7 +176,7 @@ class NagVisHoverMenu {
}
if(strpos($this->code,'[html_templates]') !== FALSE) {
- $this->code =
str_replace('[html_templates]',$this->CORE->getMainCfg()->getValue('paths','htmltemplates'),$this->code);
+ $this->code =
str_replace('[html_templates]',$this->CORE->getMainCfg()->getPath('templates',
'', ''),$this->code);
}
if(strpos($this->code,'[html_template_images]') !== FALSE) {
@@ -219,5 +219,9 @@ class NagVisHoverMenu {
private function checkTemplateExists($printErr) {
return
GlobalCore::getInstance()->checkExisting($this->pathTemplateFile, $printErr);
}
+
+ public function getCssFile() {
+ return $this->CORE->getMainCfg()->getPath('templates',
$this->templateName.'.hover.css', 'html');
+ }
}
?>
------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins