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

Author: LaMi <[email protected]>
Date:   Sat Dec  5 13:16:32 2009 +0100

#159 It is now possible to add URLs to the background images using [ and ] for 
surrounding the url

---

 docs/en_US/map_config_format_description.html  |    8 +++-
 share/frontend/wui/classes/WuiViewMap.php      |    7 +--
 share/server/core/classes/GlobalBackground.php |   64 ++++++++++++++++++++---
 share/server/core/classes/GlobalIndexPage.php  |    6 +-
 share/server/core/classes/GlobalMapCfg.php     |    2 +-
 share/server/core/defines/global.php           |    1 +
 share/server/core/defines/matches.php          |    4 +-
 7 files changed, 70 insertions(+), 22 deletions(-)

diff --git a/docs/en_US/map_config_format_description.html 
b/docs/en_US/map_config_format_description.html
index 2f57469..d0c4bce 100644
--- a/docs/en_US/map_config_format_description.html
+++ b/docs/en_US/map_config_format_description.html
@@ -48,7 +48,13 @@
                <td> <b>allowed_user</b> </td><td> </td><td> Comma separated 
list of Nagios users who are allowed to view this map. Can be "EVERYONE" for no 
permission check.</td>
                </tr>
                <tr>
-               <td> map_image </td><td> </td><td> The name of the map image 
displayed in the background of the NagVis map, for example a Visio (TM) 
drawing. <font color="#ff0000">New in 1.4:</font> The value can even be 
&quot;none&quot; or empty for no background image.</td>
+                       <td>map_image</td>
+                       <td></td>
+                       <td>
+                               <p>The name of the map image displayed in the 
background of the NagVis map, for example a Visio (TM) drawing.</p>
+                               <p>The value can even be &quot;none&quot; or 
empty for no background image.</p>
+                               <p><font color="#ff0000">New in 1.5:</font> It 
is also possible to add URLs here. The URL has to be surrounded by [ and ].</p>
+                       </td>
                </tr>
                <tr>
                <td> alias </td><td> map name </td><td> The alias is the label 
for each map. If it is defined it is shown everywhere in NagVis frontend and 
WUI </td>
diff --git a/share/frontend/wui/classes/WuiViewMap.php 
b/share/frontend/wui/classes/WuiViewMap.php
index c35a356..e8acc35 100644
--- a/share/frontend/wui/classes/WuiViewMap.php
+++ b/share/frontend/wui/classes/WuiViewMap.php
@@ -55,14 +55,9 @@ class WuiViewMap {
                // Initialize template system
                $TMPL = New FrontendTemplateSystem($this->CORE);
                $TMPLSYS = $TMPL->getTmplSys();
-
-               $backgroundImg = '';
-               if($this->MAP->MAPCFG->BACKGROUND->getFileName() != 'none' && 
$this->MAP->MAPCFG->BACKGROUND->getFileName() != '') {
-                       $backgroundImg = 
$this->CORE->getMainCfg()->getValue('paths', 'htmlmap') . 
$this->MAP->MAPCFG->BACKGROUND->getFileName();
-               }
                
                $aData = Array(
-                               'backgroundImg' => $backgroundImg,
+                               'backgroundImg' => 
$this->MAP->MAPCFG->BACKGROUND->getFile(),
                                'base' => 
$this->CORE->getMainCfg()->getValue('paths', 'htmlbase'),
                                'generalProperties' => 
$this->CORE->getMainCfg()->parseGeneralProperties(),
                                'mapName' => $this->name,
diff --git a/share/server/core/classes/GlobalBackground.php 
b/share/server/core/classes/GlobalBackground.php
index 8b23961..c2d1b4d 100644
--- a/share/server/core/classes/GlobalBackground.php
+++ b/share/server/core/classes/GlobalBackground.php
@@ -3,7 +3,7 @@
  *
  * GlobalBackground.php - Class for global background image handling
  *
- * Copyright (c) 2004-2008 NagVis Project (Contact: [email protected])
+ * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected])
  *
  * License:
  *
@@ -28,6 +28,9 @@
 class GlobalBackground {
        protected $CORE;
        protected $image;
+       protected $path;
+       protected $webPath;
+       protected $type;
        
        /**
         * Constructor
@@ -38,6 +41,8 @@ class GlobalBackground {
        public function __construct($CORE, $image) {
                $this->CORE = $CORE;
                $this->image = $image;
+               
+               $this->fetchPath();
        }
        
        /**
@@ -46,21 +51,62 @@ class GlobalBackground {
         * @return      String File Name
         * @author      Lars Michelsen <[email protected]>
         */
-       public function getFileName() {
+       private function getFileName() {
                return $this->image;
        }
        
        /**
+        * Gets the locationtype of the file
+        *
+        * @return      String File Name
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function getFileType() {
+               return $this->type;
+       }
+       
+       /**
+        * Fetches the path and saves it on initial load
+        *
+        * @return      String File Name
+        * @author      Lars Michelsen <[email protected]>
+        */
+       private function fetchPath() {
+               if($this->getFileName() != '' && $this->getFileName() != 
'none') {
+                       // Extract url when used to show an url
+                       if(preg_match('/^\[(http.*)\]$/', $this->getFileName(), 
$match) > 0) {
+                               $this->type = 'url';
+                               
+                               $this->path = $match[1];
+                               $this->webPath = $match[1];
+                       } else {
+                               $this->type = 'local';
+                               
+                               $this->path = 
$this->CORE->getMainCfg()->getValue('paths', 'map').$this->getFileName();
+                               $this->webPath = 
$this->CORE->getMainCfg()->getValue('paths', 'htmlmap').$this->getFileName();
+                       }
+               } else {
+                       $this->type = 'none';
+                       
+                       $this->path = '';
+                       $this->webPath = '';
+               }
+       }
+       
+       /**
         * Gets the background file
         *
+        * @param   Boolean Get web path or alternatively the physical path
         * @return  String  HTML Path to background file
         * @author  Lars Michelsen <[email protected]>
         */
-       public function getFile() {
-               $sReturn = '';
-               if($this->getFileName() != '' && $this->getFileName() != 
'none') {
-                       $sReturn = $this->CORE->getMainCfg()->getValue('paths', 
'htmlmap').$this->getFileName();
+       public function getFile($bWebPath = true) {
+               if($bWebPath) {
+                       $sReturn = $this->webPath;
+               } else {
+                       $sReturn = $this->path;
                }
+               
                return $sReturn;
        }
        
@@ -73,7 +119,7 @@ class GlobalBackground {
         */
        protected function checkFileExists($printErr) {
                if($this->image != '') {
-                       
if(file_exists($this->CORE->getMainCfg()->getValue('paths', 
'map').$this->image)) {
+                       if(file_exists($this->path)) {
                                return TRUE;
                        } else {
                                if($printErr) {
@@ -95,7 +141,7 @@ class GlobalBackground {
         */
        protected function checkFileReadable($printErr) {
                if($this->image != '') {
-                       if($this->checkFileExists($printErr) && 
is_readable($this->CORE->getMainCfg()->getValue('paths', 'map').$this->image)) {
+                       if($this->checkFileExists($printErr) && 
is_readable($this->path)) {
                                return TRUE;
                        } else {
                                if($printErr) {
@@ -117,7 +163,7 @@ class GlobalBackground {
         */
        protected function checkFileWriteable($printErr) {
                if($this->image != '') {
-                       if($this->checkFileExists($printErr) && 
is_writable($this->CORE->getMainCfg()->getValue('paths', 'map').$this->image)) {
+                       if($this->checkFileExists($printErr) && 
is_writable($this->path)) {
                                return TRUE;
                        } else {
                                if($printErr) {
diff --git a/share/server/core/classes/GlobalIndexPage.php 
b/share/server/core/classes/GlobalIndexPage.php
index e438707..2344801 100644
--- a/share/server/core/classes/GlobalIndexPage.php
+++ b/share/server/core/classes/GlobalIndexPage.php
@@ -209,10 +209,10 @@ class GlobalIndexPage {
                                                
                                                // Only handle thumbnail image 
when told to do so
                                                
if($this->CORE->getMainCfg()->getValue('index','showmapthumbs') == 1) {
-                                                       $imgPath = 
$this->CORE->getMainCfg()->getValue('paths','map').$MAPCFG->BACKGROUND->getFileName();
-                                                       $imgPathHtml = 
$this->CORE->getMainCfg()->getValue('paths','htmlmap').$MAPCFG->BACKGROUND->getFileName();
+                                                       $imgPath = 
$MAPCFG->BACKGROUND->getFile(GET_PHYSICAL_PATH);
+                                                       $imgPathHtml = 
$MAPCFG->BACKGROUND->getFile();
                                                        
-                                                       
if($this->CORE->checkGd(0) && $MAPCFG->BACKGROUND->getFileName() != '') {
+                                                       
if($this->CORE->checkGd(0) && $MAPCFG->BACKGROUND->getFileType() == 'local') {
                                                                $sThumbFile = 
$mapName.'-thumb.'.$this->getFileType($imgPath);
                                                                $sThumbPath = 
$this->CORE->getMainCfg()->getValue('paths','sharedvar').$sThumbFile;
                                                                $sThumbPathHtml 
= $this->CORE->getMainCfg()->getValue('paths','htmlsharedvar').$sThumbFile;
diff --git a/share/server/core/classes/GlobalMapCfg.php 
b/share/server/core/classes/GlobalMapCfg.php
index a4935bf..05120bb 100644
--- a/share/server/core/classes/GlobalMapCfg.php
+++ b/share/server/core/classes/GlobalMapCfg.php
@@ -62,7 +62,7 @@ class GlobalMapCfg {
                                'allowed_user' => Array('must' => 1,
                                        'match' => MATCH_STRING),
                                'map_image' => Array('must' => 0,
-                                       'match' => 
MATCH_PNG_GIF_JPG_FILE_OR_NONE,
+                                       'match' => 
MATCH_PNG_GIF_JPG_FILE_OR_URL_NONE,
                                        'field_type' => 'dropdown'),
                                'alias' => Array('must' => 0,
                                        'default' => $name,
diff --git a/share/server/core/defines/global.php 
b/share/server/core/defines/global.php
index f7813c2..09e2045 100644
--- a/share/server/core/defines/global.php
+++ b/share/server/core/defines/global.php
@@ -70,6 +70,7 @@ define('SESSION_NAME', 'nagvis_session');
 // Other basic constants
 define('REQUIRES_AUTHORISATION', true);
 define('GET_STATE', true);
+define('GET_PHYSICAL_PATH', false);
 define('DONT_GET_OBJECT_STATE', false);
 define('DONT_GET_SINGLE_MEMBER_STATES', false);
 define('IS_VIEW', true);
diff --git a/share/server/core/defines/matches.php 
b/share/server/core/defines/matches.php
index accbe1b..b0c4837 100644
--- a/share/server/core/defines/matches.php
+++ b/share/server/core/defines/matches.php
@@ -3,7 +3,7 @@
  *
  * matches.php - File for global match constants
  *
- * Copyright (c) 2004-2008 NagVis Project (Contact: [email protected])
+ * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected])
  *
  * License:
  *
@@ -45,7 +45,7 @@ define('MATCH_COLOR', '/^(#?[0-9a-f]{3,6}|transparent)$/i');
 define('MATCH_OBJECTTYPE', 
'/^(?:global|host|service|hostgroup|servicegroup|map|textbox|shape|line|template)$/i');
 define('MATCH_PNGFILE', '/^(.+)\.png$/i');
 define('MATCH_PNG_GIF_JPG_FILE', '/^(.+)\.(png|gif|jpg)$/i');
-define('MATCH_PNG_GIF_JPG_FILE_OR_NONE', '/^((.+)\.(png|gif|jpg)|none)$/i');
+define('MATCH_PNG_GIF_JPG_FILE_OR_URL_NONE', 
'/^((.+)\.(png|gif|jpg)|\[[0-9a-z\s\:\+\[\]\(\)\=\%\?\&\_\.\-...@\=\/\\\]+\]|none)$/i');
 define('MATCH_PNG_GIF_JPG_FILE_OR_URL', 
'/^((.+)\.(png|gif|jpg)|\[[0-9a-z\s\:\+\[\]\(\)\=\%\?\&\_\.\-...@\=\/\\\]+\])$/i');
 define('MATCH_ROTATION_STEP_TYPES_EMPTY', '/^(?:map|automap|url)?$/');
 define('MATCH_LANGUAGE_EMPTY', '/^[a-zA-Z0-9-_]*$/');


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

Reply via email to