Module: nagvis
Branch: master
Commit: ccb3f6786696f1f88a7607578cf1fecf2ed475d6
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=ccb3f6786696f1f88a7607578cf1fecf2ed475d6

Author: Lars Michelsen <[email protected]>
Date:   Fri Sep 17 18:46:04 2010 +0200

#277 Added defaultshow parameter which can be used by all modules but it only 
used by the Map and AutoMap frontend modules

---

 docs/en_US/nagvis_config_format_description.html   |    5 ++++
 etc/nagvis.ini.php-sample                          |    3 ++
 .../nagvis-js/classes/FrontendModAutoMap.php       |    6 ++++-
 .../frontend/nagvis-js/classes/FrontendModMap.php  |    8 +++++-
 share/server/core/classes/CoreModule.php           |    4 +-
 share/server/core/classes/CoreUriHandler.php       |   10 ++++++--
 share/server/core/classes/GlobalMainCfg.php        |   22 +++++++++++--------
 7 files changed, 41 insertions(+), 17 deletions(-)

diff --git a/docs/en_US/nagvis_config_format_description.html 
b/docs/en_US/nagvis_config_format_description.html
index 13c9658..ae4689e 100644
--- a/docs/en_US/nagvis_config_format_description.html
+++ b/docs/en_US/nagvis_config_format_description.html
@@ -113,6 +113,11 @@
                <tr>
                <td>startaction</td><td>view</td><td>The default action to do 
when none is given by the user <font color="#ff0000">(New in 1.5)</font></td>
                </tr>
+               <td>startshow</td><td></td>
+               <td>
+                       The startshow parameter is only used by some views at 
the moment. 
+                       It is used by the Map and the AutoMap modules. <font 
color="#ff0000">(New in 1.5.2)</font></td>
+    </tr>
                </table>
                
                <a name="paths"></a><h3> paths </h3>
diff --git a/etc/nagvis.ini.php-sample b/etc/nagvis.ini.php-sample
index ce7bb61..494e1c6 100644
--- a/etc/nagvis.ini.php-sample
+++ b/etc/nagvis.ini.php-sample
@@ -101,6 +101,9 @@
 ; special parameters.
 ;startmodule="Overview"
 ;startaction="view"
+; The startshow parameter is only used by some views at the moment. It is used
+; by the Map and the AutoMap modules.
+;startshow=""
 
 ; Path definitions
 [paths]
diff --git a/share/frontend/nagvis-js/classes/FrontendModAutoMap.php 
b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php
index e7518cc..a9a49f2 100644
--- a/share/frontend/nagvis-js/classes/FrontendModAutoMap.php
+++ b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php
@@ -56,7 +56,11 @@ class FrontendModAutoMap extends FrontendModule {
                               'enableContext' => MATCH_BOOLEAN_EMPTY,
                               'enableHover' => MATCH_BOOLEAN_EMPTY);
                
-               $aVals = $this->getCustomOptions($aOpts);
+               // There might be a default map when none is given
+               $aDefaults = Array('show' => 
$this->CORE->getMainCfg()->getValue('global', 'startshow'));
+               
+               // getCustomOptions fetches and validates the values    
+               $aVals = $this->getCustomOptions($aOpts, $aDefaults);
                $this->name = $aVals['show'];
                $this->rotation = $aVals['rotation'];
                $this->rotationStep = $aVals['rotationStep'];
diff --git a/share/frontend/nagvis-js/classes/FrontendModMap.php 
b/share/frontend/nagvis-js/classes/FrontendModMap.php
index 35ed106..0dabd69 100644
--- a/share/frontend/nagvis-js/classes/FrontendModMap.php
+++ b/share/frontend/nagvis-js/classes/FrontendModMap.php
@@ -43,9 +43,13 @@ class FrontendModMap extends FrontendModule {
                               'rotationStep' => MATCH_INTEGER_EMPTY,
                               'enableHeader' => MATCH_BOOLEAN_EMPTY,
                               'enableContext' => MATCH_BOOLEAN_EMPTY,
-                              'enableHover' => MATCH_BOOLEAN_EMPTY);
+                                                                        
'enableHover' => MATCH_BOOLEAN_EMPTY);
+
+               // There might be a default map when none is given
+               $aDefaults = Array('show' => 
$this->CORE->getMainCfg()->getValue('global', 'startshow'));
                
-               $aVals = $this->getCustomOptions($aOpts);
+               // getCustomOptions fetches and validates the values    
+               $aVals = $this->getCustomOptions($aOpts, $aDefaults);
                $this->name = $aVals['show'];
                $this->search = $aVals['search'];
                $this->rotation = $aVals['rotation'];
diff --git a/share/server/core/classes/CoreModule.php 
b/share/server/core/classes/CoreModule.php
index ba5a565..833fc4e 100644
--- a/share/server/core/classes/CoreModule.php
+++ b/share/server/core/classes/CoreModule.php
@@ -130,14 +130,14 @@ abstract class CoreModule {
         *
         * @author  Lars Michelsen <[email protected]>
         */
-       protected function getCustomOptions($aKeys) {
+       protected function getCustomOptions($aKeys, $aDefaults = Array()) {
                // Initialize on first call
                if($this->UHANDLER === null) {
                        $this->initUriHandler();
                }
                
                // Load the specific params to the UriHandler
-               $this->UHANDLER->parseModSpecificUri($aKeys);
+               $this->UHANDLER->parseModSpecificUri($aKeys, $aDefaults);
                
                // Now get those params
                $aReturn = Array();
diff --git a/share/server/core/classes/CoreUriHandler.php 
b/share/server/core/classes/CoreUriHandler.php
index ae6085a..42b95b7 100644
--- a/share/server/core/classes/CoreUriHandler.php
+++ b/share/server/core/classes/CoreUriHandler.php
@@ -79,14 +79,18 @@ class CoreUriHandler {
                        return false;
        }
        
-       public function parseModSpecificUri($aKeys) {
+       public function parseModSpecificUri($aKeys, $aDefaults = Array()) {
                foreach($aKeys AS $key => $sMatch) {
                        // Validate the value
                        $bValid = true;
                        if($sMatch !== '') {
                                // When param not set initialize it as empty 
string
+                               // or with the given defaults when some given.
                                if(!isset($_GET[$key]))
-                                       $_GET[$key] = '';
+                                       if(isset($aDefaults[$key]))
+                                               $_GET[$key] = $aDefaults[$key];
+                                       else
+                                               $_GET[$key] = '';
                                
                                // Validate single value or multiple (array)
                                if(is_array($_GET[$key]))
@@ -145,7 +149,7 @@ class CoreUriHandler {
                if(isset($this->aAliases[$sKey]))
                        $sKey = $this->aAliases[$sKey];
                
-               return isset($this->aOpts[$sKey]) && $this->aOpts[$sKey] != '');
+               return isset($this->aOpts[$sKey]) && $this->aOpts[$sKey] != '';
        }
 }
 
diff --git a/share/server/core/classes/GlobalMainCfg.php 
b/share/server/core/classes/GlobalMainCfg.php
index fc4e4d6..17df69d 100644
--- a/share/server/core/classes/GlobalMainCfg.php
+++ b/share/server/core/classes/GlobalMainCfg.php
@@ -122,17 +122,21 @@ class GlobalMainCfg {
                                        'default' => '',
                                        'match' => MATCH_STRING),
                                'sesscookieduration' => Array('must' => 1,
-                                       'editable' => 1,
-                                       'default' => '86400',
-                                       'match' => MATCH_STRING),
+                                       'editable'    => 1,
+                                       'default'     => '86400',
+                                       'match'       => MATCH_STRING),
                                'startmodule' => Array('must' => 1,
-                                       'editable' => 1,
-                                       'default' => 'Overview',
-                                       'match' => MATCH_STRING),
+                                       'editable'    => 1,
+                                       'default'     => 'Overview',
+                                       'match'       => MATCH_STRING),
                                'startaction' => Array('must' => 1,
-                                       'editable' => 1,
-                                       'default' => 'view',
-                                       'match' => MATCH_STRING)),
+                                       'editable'    => 1,
+                                       'default'     => 'view',
+                                       'match'       => MATCH_STRING),
+                               'startshow'   => Array('must' => 0,
+                                       'editable'    => 1,
+                                       'default'     => '',
+                                       'match'       => MATCH_STRING_EMPTY)),
                        'defaults' => Array(
                                'backend' => Array('must' => 0,
                                        'editable' => 0,


------------------------------------------------------------------------------
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

Reply via email to