Module: nagvis Branch: master Commit: 384e9bb8c464eb23c6024e5f8f0c4800c74d51bf URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=384e9bb8c464eb23c6024e5f8f0c4800c74d51bf
Author: LaMi <[email protected]> Date: Fri Dec 4 22:31:06 2009 +0100 #13 The header can be enabled/disabled by url now --- .../nagvis-js/classes/FrontendModAutoMap.php | 25 ++++++++++++++++- .../frontend/nagvis-js/classes/FrontendModMap.php | 29 +++++++++++++++++--- .../nagvis-js/classes/NagVisAutoMapView.php | 11 +++++++ share/frontend/nagvis-js/classes/NagVisMapView.php | 11 +++++++ share/server/core/defines/matches.php | 1 + 5 files changed, 72 insertions(+), 5 deletions(-) diff --git a/share/frontend/nagvis-js/classes/FrontendModAutoMap.php b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php index 1657b65..0631f48 100644 --- a/share/frontend/nagvis-js/classes/FrontendModAutoMap.php +++ b/share/frontend/nagvis-js/classes/FrontendModAutoMap.php @@ -4,6 +4,8 @@ class FrontendModAutoMap extends FrontendModule { private $opts; private $rotation = ''; + private $viewOpts = Array(); + public function __construct(GlobalCore $CORE) { $this->CORE = $CORE; @@ -24,8 +26,17 @@ class FrontendModAutoMap extends FrontendModule { $aVals = $this->getCustomOptions($aOpts); $this->name = $aVals['show']; $this->rotation = $aVals['rotation']; + + $this->viewOpts['enableHeader'] = $aVals['enableHeader']; + $this->viewOpts['enableContext'] = $aVals['enableContext']; + $this->viewOpts['enableHover'] = $aVals['enableHover']; + unset($aVals['show']); unset($aVals['rotation']); + unset($aVals['enableHeader']); + unset($aVals['enableContext']); + unset($aVals['enableHover']); + $this->opts = $aVals; // Register valid actions @@ -73,8 +84,17 @@ class FrontendModAutoMap extends FrontendModule { $INDEX->setCustomStylesheet($CORE->getMainCfg()->getValue('paths','htmlstyles') . $customStylesheet); } + // Header menu enabled/disabled by url? + if($this->viewOpts['enableHeader'] !== false && $this->viewOpts['enableHeader']) { + $showHeader = true; + } elseif($this->viewOpts['enableHeader'] !== false && !$this->viewOpts['enableHeader']) { + $showHeader = false; + } else { + $showHeader = $MAPCFG->getValue('global',0 ,'header_menu'); + } + // Need to parse the header menu? - if($MAPCFG->getValue('global',0 ,'header_menu')) { + if($showHeader) { // Parse the header menu $HEADER = new GlobalHeaderMenu($this->CORE, $this->AUTHORISATION, $MAPCFG->getValue('global',0 ,'header_template'), $MAPCFG); @@ -89,6 +109,9 @@ class FrontendModAutoMap extends FrontendModule { // Initialize map view $this->VIEW = new NagVisAutoMapView($this->CORE, $MAPCFG->getName()); + // Set view modificators (Hover, Context toggle) + $this->VIEW->setViewOpts($this->viewOpts); + // Render the automap $AUTOMAP = new NagVisAutoMap($this->CORE, $MAPCFG, $BACKEND, $this->opts, IS_VIEW); $this->VIEW->setContent($AUTOMAP->parseMap()); diff --git a/share/frontend/nagvis-js/classes/FrontendModMap.php b/share/frontend/nagvis-js/classes/FrontendModMap.php index 541c204..b5f8e52 100644 --- a/share/frontend/nagvis-js/classes/FrontendModMap.php +++ b/share/frontend/nagvis-js/classes/FrontendModMap.php @@ -4,19 +4,28 @@ class FrontendModMap extends FrontendModule { private $search = ''; private $rotation = ''; + private $viewOpts = Array(); + public function __construct(GlobalCore $CORE) { $this->CORE = $CORE; // Parse the view specific options $aOpts = Array('show' => MATCH_MAP_NAME, 'search' => MATCH_STRING_NO_SPACE_EMPTY, - 'rotation' => MATCH_ROTATION_NAME_EMPTY); + 'rotation' => MATCH_ROTATION_NAME_EMPTY, + 'enableHeader' => MATCH_BOOLEAN_EMPTY, + 'enableContext' => MATCH_BOOLEAN_EMPTY, + 'enableHover' => MATCH_BOOLEAN_EMPTY); $aVals = $this->getCustomOptions($aOpts); $this->name = $aVals['show']; $this->search = $aVals['search']; $this->rotation = $aVals['rotation']; + $this->viewOpts['enableHeader'] = $aVals['enableHeader']; + $this->viewOpts['enableContext'] = $aVals['enableContext']; + $this->viewOpts['enableHover'] = $aVals['enableHover']; + // Register valid actions $this->aActions = Array( 'view' => REQUIRES_AUTHORISATION @@ -59,8 +68,17 @@ class FrontendModMap extends FrontendModule { $INDEX->setCustomStylesheet($CORE->getMainCfg()->getValue('paths','htmlstyles') . $customStylesheet); } - // Need to parse the header menu? - if($MAPCFG->getValue('global',0 ,'header_menu')) { + // Header menu enabled/disabled by url? + if($this->viewOpts['enableHeader'] !== false && $this->viewOpts['enableHeader']) { + $showHeader = true; + } elseif($this->viewOpts['enableHeader'] !== false && !$this->viewOpts['enableHeader']) { + $showHeader = false; + } else { + $showHeader = $MAPCFG->getValue('global',0 ,'header_menu'); + } + + // Need to parse the header menu by config or url value? + if($showHeader) { // Parse the header menu $HEADER = new GlobalHeaderMenu($this->CORE, $this->AUTHORISATION, $MAPCFG->getValue('global',0 ,'header_template'), $MAPCFG); @@ -74,10 +92,13 @@ class FrontendModMap extends FrontendModule { // Initialize map view $this->VIEW = new NagVisMapView($this->CORE, $this->name); - + // The user is searching for an object $this->VIEW->setSearch($this->search); + // Set view modificators (Hover, Context toggle) + $this->VIEW->setViewOpts($this->viewOpts); + // Maybe it is needed to handle the requested rotation if($this->rotation != '') { // Only allow the rotation if the user is permitted to use it diff --git a/share/frontend/nagvis-js/classes/NagVisAutoMapView.php b/share/frontend/nagvis-js/classes/NagVisAutoMapView.php index 9ba4af3..dd54e5b 100644 --- a/share/frontend/nagvis-js/classes/NagVisAutoMapView.php +++ b/share/frontend/nagvis-js/classes/NagVisAutoMapView.php @@ -33,6 +33,7 @@ class NagVisAutoMapView { private $content = ''; private $aRotation = Array(); private $aParams = Array(); + private $aViewOpts = Array(); /** * Class Constructor @@ -71,6 +72,16 @@ class NagVisAutoMapView { } /** + * Set the view modificator options + * + * @param Array + * @author Lars Michelsen <[email protected]> + */ + public function setViewOpts($a) { + $this->aViewOpts = $a; + } + + /** * Parses the map and the objects for the nagvis-js frontend * * @return String String with JS Code diff --git a/share/frontend/nagvis-js/classes/NagVisMapView.php b/share/frontend/nagvis-js/classes/NagVisMapView.php index 06afeb5..6853ab3 100644 --- a/share/frontend/nagvis-js/classes/NagVisMapView.php +++ b/share/frontend/nagvis-js/classes/NagVisMapView.php @@ -30,6 +30,7 @@ class NagVisMapView { private $name = ''; private $search = ''; private $aRotation = Array(); + private $aViewOpts = Array(); /** * Class Constructor @@ -66,6 +67,16 @@ class NagVisMapView { } /** + * Set the view modificator options + * + * @param Array + * @author Lars Michelsen <[email protected]> + */ + public function setViewOpts($a) { + $this->aViewOpts = $a; + } + + /** * Parses the map and the objects for the nagvis-js frontend * * @return String String with JS Code diff --git a/share/server/core/defines/matches.php b/share/server/core/defines/matches.php index 2683047..accbe1b 100644 --- a/share/server/core/defines/matches.php +++ b/share/server/core/defines/matches.php @@ -39,6 +39,7 @@ define('MATCH_INTEGER', '/^[0-9]+$/'); define('MATCH_INTEGER_EMPTY', '/^[0-9]*$/'); define('MATCH_FLOAT', '/^[0-9]+[\.\,]*[0-9]*$/'); define('MATCH_BOOLEAN', '/^(?:1|0)$/i'); +define('MATCH_BOOLEAN_EMPTY', '/^(?:1|0)*$/i'); define('MATCH_COLOR', '/^(#?[0-9a-f]{3,6}|transparent)$/i'); define('MATCH_OBJECTTYPE', '/^(?:global|host|service|hostgroup|servicegroup|map|textbox|shape|line|template)$/i'); ------------------------------------------------------------------------------ Join us December 9, 2009 for the Red Hat Virtual Experience, a free event focused on virtualization and cloud computing. Attend in-depth sessions from your desk. Your couch. Anywhere. http://p.sf.net/sfu/redhat-sfdev2dev _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
