Author: Lars Michelsen <[email protected]>
Date: Tue Jul 5 20:48:17 2011 +0200
Committer: Lars Michelsen <[email protected]>
Commit-Date: Tue Jul 5 20:48:17 2011 +0200
Documentation link in header menu only points to available docs. Fallback is
en_US
---
ChangeLog | 1 +
TODO | 3 --
.../nagvis-js/classes/NagVisHeaderMenu.php | 20 +++++++++++++++-
share/server/core/classes/GlobalCore.php | 24 ++++++++++++++-----
share/server/core/classes/GlobalMainCfg.php | 6 +++++
share/server/core/defines/matches.php | 1 +
share/userfiles/templates/default.header.html | 4 +-
7 files changed, 45 insertions(+), 14 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index ab399d1..214848c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -22,6 +22,7 @@ Frontend
* Labels of lines with line_type=14 have more offset now to look better when
using horizontal lines
* While objects are unlocked the hover menus are disabled
* Controls are now resizable using the config option controls_size in
[global] section in nagvis.ini.php
+ * Documentation link in header menu only points to available docs. Fallback
is en_US
* Bugfix: Added missing controls to services which are displayed as gadgets
* Bugfix: Fixed parsing of label_type=14 lines (Thanks to Laurent Lebatard)
* Bugfix: Label positioning in case of weathermap lines (Thanks to Laurent
Lebatard)
diff --git a/TODO b/TODO
index 3b77136..b7551f9 100644
--- a/TODO
+++ b/TODO
@@ -1,9 +1,6 @@
This is a small file for storing quick thoughts about new features and needed
changes:
===============================================================================
-- Doku Link im Header darf nur auf Sprachen zeigen, die auch existieren
-- GröÃe der Controls soll konfigurierbar sein. Dazu reicht eine Option in
der Hauptkonfiguration
-
- Backends:
- Zusätzlich beliebige Variablen vom Backend holen lassen
Pro Objekt "Custom Vars" für Context- und Hover-Menus einbauen. Diese
werden dann pro Objekt
diff --git a/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
b/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
index 08536e2..8b0e614 100644
--- a/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
+++ b/share/frontend/nagvis-js/classes/NagVisHeaderMenu.php
@@ -263,6 +263,21 @@ class NagVisHeaderMenu {
}
/**
+ * Checks if a documentation is available for the current language.
+ * It either returns the language tag for the current language when a
+ * documentation exists or en_US as fallback when no docs exist
+ *
+ * @author Lars Michelsen <[email protected]>
+ */
+ private function getDocLanguage() {
+ $lang = $this->CORE->getLang()->getCurrentLanguage();
+ if(in_array($lang, $this->CORE->getAvailableDocs()))
+ return $lang;
+ else
+ return 'en_US';
+ }
+
+ /**
* PRIVATE getStaticMacros()
*
* Get all static macros for the template code
@@ -282,7 +297,8 @@ class NagVisHeaderMenu {
'langSearch' => $this->CORE->getLang()->getText('Search'),
'langUserMgmt' => $this->CORE->getLang()->getText('Manage
Users'),
'langManageRoles' => $this->CORE->getLang()->getText('Manage
Roles'),
- 'currentLanguage' => $this->CORE->getLang()->getCurrentLanguage(),
+ 'currentLanguage' =>
$this->CORE->getLang()->getCurrentLanguage(),
+ 'docLanguage' => $this->getDocLanguage(),
'langChooseLanguage' => $this->CORE->getLang()->getText('Choose
Language'),
'langUser' => $this->CORE->getLang()->getText('User menu'),
'langActions' => $this->CORE->getLang()->getText('Actions'),
@@ -346,4 +362,4 @@ class NagVisHeaderMenu {
return
GlobalCore::getInstance()->checkReadable($this->pathTemplateFile, $printErr);
}
}
-?>
\ No newline at end of file
+?>
diff --git a/share/server/core/classes/GlobalCore.php
b/share/server/core/classes/GlobalCore.php
index 44d455c..804fa26 100644
--- a/share/server/core/classes/GlobalCore.php
+++ b/share/server/core/classes/GlobalCore.php
@@ -210,6 +210,16 @@ class GlobalCore {
}
/**
+ * Returns languages of all available documentations
+ *
+ * @return Array list
+ * @author Lars Michelsen <[email protected]>
+ */
+ public function getAvailableDocs() {
+ return self::listDirectory(self::getMainCfg()->getValue('paths',
'doc'), MATCH_DOC_DIR);
+ }
+
+ /**
* Reads all available backends
*
* @return Array Html
@@ -386,28 +396,28 @@ class GlobalCore {
private function listDirectory($dir, $allowRegex = null, $ignoreList =
null, $allowPartRegex = null, $returnPart = null, $setKey = null, $printErr =
true) {
$files = Array();
- if($returnPart === null)
+ if($returnPart === null)
$returnPart = 1;
- if($setKey === null)
+ if($setKey === null)
$setKey = false;
- if(!self::checkExisting($dir, $printErr))
+ if(!self::checkExisting($dir, $printErr))
return $files;
if($handle = opendir($dir)) {
- while (false !== ($file = readdir($handle))) {
+ while (false !== ($file = readdir($handle))) {
if($allowRegex && !preg_match($allowRegex, $file, $arrRet))
continue;
if($ignoreList && isset($ignoreList[$file]))
continue;
- if($allowPartRegex && !preg_match($allowPartRegex, $arrRet[1]))
+ if($allowPartRegex && !preg_match($allowPartRegex, $arrRet[1]))
continue;
if($setKey)
$files[$arrRet[$returnPart]] = $arrRet[$returnPart];
else
$files[] = $arrRet[$returnPart];
- }
+ }
if($files)
natcasesort($files);
@@ -662,4 +672,4 @@ class GlobalCore {
return json_encode($aArr);
}
}
-?>
\ No newline at end of file
+?>
diff --git a/share/server/core/classes/GlobalMainCfg.php
b/share/server/core/classes/GlobalMainCfg.php
index ec2d787..b4fab20 100644
--- a/share/server/core/classes/GlobalMainCfg.php
+++ b/share/server/core/classes/GlobalMainCfg.php
@@ -442,6 +442,11 @@ class GlobalMainCfg {
'default' => '',
'field_type' => 'hidden',
'match' => MATCH_STRING_PATH),
+ 'doc' => Array('must' => 0,
+ 'editable' => 0,
+ 'default' => '',
+ 'field_type' => 'hidden',
+ 'match' => MATCH_STRING_PATH),
'var' => Array('must' => 0,
'editable' => 0,
'default' => '',
@@ -1090,6 +1095,7 @@ class GlobalMainCfg {
$this->validConfig['paths']['language']['default'] =
$base.HTDOCS_DIR.'/frontend/nagvis-js/locale';
$this->validConfig['paths']['class']['default'] =
$base.HTDOCS_DIR.'/server/core/classes/';
+ $this->validConfig['paths']['doc']['default'] =
$base.HTDOCS_DIR.'/docs';
$this->validConfig['paths']['htmlcss']['default'] =
$htmlBase.'/frontend/nagvis-js/css/';
diff --git a/share/server/core/defines/matches.php
b/share/server/core/defines/matches.php
index 6f4b520..79ac148 100644
--- a/share/server/core/defines/matches.php
+++ b/share/server/core/defines/matches.php
@@ -61,6 +61,7 @@ define('MATCH_LANGUAGE_EMPTY', '/^[a-zA-Z0-9\-_]*$/');
define('MATCH_LANGUAGE_FILE', '/^([^\.].*)/');
define('MATCH_ICONSET', '/^(.+)_ok.(png|gif|jpg)$/');
define('MATCH_BACKEND_FILE', '/^GlobalBackend([^MI].+)\.php$/');
+define('MATCH_DOC_DIR', '/^([a-z]{2}_[A-Z]{2})/');
define('MATCH_MAP_NAME', '/^[0-9A-Za-z_\-]+$/');
define('MATCH_MAP_NAME_EMPTY', '/^[0-9A-Za-z_\-]*$/');
diff --git a/share/userfiles/templates/default.header.html
b/share/userfiles/templates/default.header.html
index b521ddd..7a7730e 100644
--- a/share/userfiles/templates/default.header.html
+++ b/share/userfiles/templates/default.header.html
@@ -133,7 +133,7 @@
<li onmouseover="ddMenu('support',1)" onmouseout="ddMenuHide(['support'])"
class="dropdown">
<span id="support-ddheader">{$langNeedHelp} <img
src="{$pathTemplateImages}default.header_down.png" alt="∇" /></span>
<ul id="support-ddcontent">
- <li><a
href="{$pathBase}/docs/{$currentLanguage}/index.html">{$langOnlineDoc}</a></li>
+ <li><a
href="{$pathBase}/docs/{$docLanguage}/index.html">{$langOnlineDoc}</a></li>
<li><a
href="http://www.nagios-portal.org/wbb/index.php?page=Board&boardID=42">{$langForum}</a></li>
<li><a href="{$pathBase}/frontend/nagvis-js/index.php?mod=Info"
class="underline">{$langSupportInfo}</a></li>
</ul>
@@ -163,4 +163,4 @@
</ul>
</div>
<div id="headerspacer"></div>
-<script type="text/javascript">addDOMLoadEvent(function()\{sidebarDraw();
headerDraw();});</script>
\ No newline at end of file
+<script type="text/javascript">addDOMLoadEvent(function()\{sidebarDraw();
headerDraw();});</script>
------------------------------------------------------------------------------
All of the data generated in your IT infrastructure is seriously valuable.
Why? It contains a definitive record of application performance, security
threats, fraudulent activity, and more. Splunk takes this data and makes
sense of it. IT sense. And common sense.
http://p.sf.net/sfu/splunk-d2d-c2
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins