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

Author: Lars Michelsen <[email protected]>
Date:   Wed Sep 16 19:23:06 2009 +0200

Added the possibility to a) prevent reloading of the html messagebox and b) it 
is now possible to redirect the user after some time

---

 .../classes/frontend/GlobalFrontendMessage.php     |    7 ++++---
 .../classes/frontend/GlobalFrontendMessageBox.php  |   20 +++++++++++++++++---
 2 files changed, 21 insertions(+), 6 deletions(-)

diff --git 
a/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessage.php 
b/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessage.php
index 59e7d8e..9b1b1e5 100644
--- a/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessage.php
+++ b/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessage.php
@@ -35,21 +35,22 @@ class GlobalFrontendMessage {
         * @param   string      $message
         * @param   string      $pathHtmlBase
         * @param   string      $title
+        * @param   string  $sRedirect
         * @access  public
         * @author  Michael Luebben <[email protected]>
         */
-       public function __construct($type, $message, $pathHtmlBase = NULL, 
$title = NULL) {
+       public function __construct($type, $message, $pathHtmlBase = NULL, 
$title = NULL, $sRedirect = '') {
                if($pathHtmlBase === NULL) {
                        $CORE = new GlobalCore();
                        $pathHtmlBase = $CORE->MAINCFG->getValue('paths', 
'htmlbase');
                }
                
                // New method
-               print(new GlobalFrontendMessageBox($type, $message, 
$pathHtmlBase, $title));
+               print(new GlobalFrontendMessageBox($type, $message, 
$pathHtmlBase, $title, true, $sRedirect));
                
                if($type == 'ERROR' || $type == 'INFO-STOP') {
                        exit(1);
                }
        }
 }
-?>
\ No newline at end of file
+?>
diff --git 
a/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessageBox.php 
b/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessageBox.php
index 5e29d1a..018a7c8 100644
--- a/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessageBox.php
+++ b/share/frontend/nagvis-js/classes/frontend/GlobalFrontendMessageBox.php
@@ -3,7 +3,7 @@
  *
  * GlobalFronendMessageBox.php - Class to render a messagebox in the frontend
  *
- * Copyright (c) 2004-2008 NagVis Project (Contact: [email protected])
+ * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected])
  *
  * License:
  *
@@ -48,6 +48,7 @@
  * @param   string   $message  Message
  *
  * @author  Michael Luebben <[email protected]>
+ * @author  Lars Michelsen <[email protected]>
  */
 class GlobalFrontendMessageBox {
        // Contains the page which will be printed
@@ -73,6 +74,8 @@ class GlobalFrontendMessageBox {
        private $type;
        private $message;
        private $title;
+       private $bReload;
+       private $bRedirect;
 
        /**
         * The contructor checks the type and builds the message box
@@ -81,13 +84,18 @@ class GlobalFrontendMessageBox {
         * @param   string      $message
         * @param   string      $pathHtmlBase
         * @param   string      $title
+        * @param   bool    $bReload
+        * @param   string  $sRedirect
         * @access  public
         * @author  Michael Luebben <[email protected]>
+        * @author  Lars Michelsen <[email protected]>
         */
-       public function __construct($type, $message, $pathHtmlBase, $title = 
NULL) {
+       public function __construct($type, $message, $pathHtmlBase, $title = 
NULL, $bReload = true, $sRedirect = '') {
                $this->type = strtolower($type);
                $this->message = $message;
                $this->pathHtmlBase = $pathHtmlBase;
+               $this->bReload = $bReload;
+               $this->sRedirect = $sRedirect;
                
                // Remap old types
                if($this->type == 'info-stop') {
@@ -135,7 +143,13 @@ class GlobalFrontendMessageBox {
         * @author  Michael Luebben <[email protected]>
         */
        private function buildHTMLMessage() {
-               $this->page .= '<meta http-equiv="refresh" content="60">';
+               if($this->bReload) {
+                       if($this->sRedirect = '') {
+                               $this->page .= '<meta http-equiv="refresh" 
content="60">';
+                       } else {
+                               $this->page .= '<meta http-equiv="refresh" 
content="5; URL='.$this->sRedirect.'">';
+                       }
+               }
                $this->page .= '<link rel="stylesheet" type="text/css" 
href="'.$this->pathHtmlBase.'/frontend/nagvis-js/css/style.css" />';
                $this->page .= '<div id="messageBoxDiv">'."\n";
                $this->page .= '   <table id="messageBox" 
class="'.$this->type.'" height="100%" width="100%" cellpadding="0" 
cellspacing="0">'."\n";


------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to