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

Author: Lars Michelsen <[email protected]>
Date:   Sun Oct 18 23:15:31 2009 +0200

First steps to reimplement the url fetching feature

---

 .../frontend/nagvis-js/classes/FrontendModUrl.php  |   26 ++------
 .../classes/controller/GlobalControllerUrl.php     |   51 ----------------
 share/frontend/nagvis-js/js/frontend.js            |   11 ++-
 share/server/core/ajax_handler.php                 |    1 +
 share/server/core/classes/CoreModUrl.php           |   63 ++++++++++++++++++++
 share/server/core/classes/NagVisHoverUrl.php       |    2 +-
 share/server/core/classes/NagVisUrl.php            |    4 +-
 7 files changed, 80 insertions(+), 78 deletions(-)

diff --git a/share/frontend/nagvis-js/classes/FrontendModUrl.php 
b/share/frontend/nagvis-js/classes/FrontendModUrl.php
index 7be1782..0f60de5 100644
--- a/share/frontend/nagvis-js/classes/FrontendModUrl.php
+++ b/share/frontend/nagvis-js/classes/FrontendModUrl.php
@@ -1,17 +1,17 @@
 <?php
 class FrontendModUrl extends FrontendModule {
-       private $name = '';
        private $url = '';
        
        public function __construct(GlobalCore $CORE) {
                $this->CORE = $CORE;
 
-               $UHANDLER = new CoreUriHandler($this->CORE); 
-               $this->name = $UHANDLER->get('show');
-
-               // And parse the view specific options
-               $this->getUrlOptions($UHANDLER);
+               // Parse the view specific options
+               $aOpts = Array('show' => MATCH_STRING_URL);
+               
+               $aVals = $this->getCustomOptions($aOpts);
+               $this->url = $aVals['show'];
                
+               // Register valid actions
                $this->aActions = Array(
                        'view' => REQUIRES_AUTHORISATION
                );
@@ -31,20 +31,6 @@ class FrontendModUrl extends FrontendModule {
                
                return $sReturn;
        }
-
-       private function getUrlOptions(CoreUriHandler $UHANDLER) {
-               // FIXME: The array should contain orders for validating the 
given value
-               // the options should be validated by the uri handler
-               
-               // Parse view specific uri params
-               $aKeys = Array('url' => '');
-               
-               // Load the specific params to the UriHandler
-               $UHANDLER->parseModSpecificUri($aKeys);
-               
-               // Now get those params
-               $this->url = $UHANDLER->get('url');
-       }
        
        private function showViewDialog() {
                // Only show when map name given
diff --git 
a/share/frontend/nagvis-js/classes/controller/GlobalControllerUrl.php 
b/share/frontend/nagvis-js/classes/controller/GlobalControllerUrl.php
deleted file mode 100644
index 94c5e3a..0000000
--- a/share/frontend/nagvis-js/classes/controller/GlobalControllerUrl.php
+++ /dev/null
@@ -1,51 +0,0 @@
-<?php
-/*****************************************************************************
- *
- * GlobalControllerDefault.php - Global url controller for nagvis
- *
- * Copyright (c) 2004-2008 NagVis Project (Contact: [email protected])
- *
- * License:
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- *
- * This program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this program; if not, write to the Free Software
- * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
- *
- *****************************************************************************/
-
-/**
- * class GlobalControllerUrl
- *
- * @author  Michael Luebben <[email protected]>
- */
-class GlobalControllerUrl {
-
-       public function __construct($url) {
-               // Load the core
-               $CORE = new GlobalCore();
-
-               // Initialize the frontend
-               $FRONTEND = new NagVisFrontend($CORE);
-               
-               $URL = new NagVisUrl($CORE, $url);
-
-               // Build the page
-               $FRONTEND->addBodyLines($FRONTEND->parseJs('oRotationProperties 
= '.$FRONTEND->getRotationPropertiesJson(1).';'));
-               
$FRONTEND->getHeaderMenu($CORE->MAINCFG->getValue('index','headermenu'), 
$CORE->MAINCFG->getValue('index', 'headertemplate'));
-               $FRONTEND->addBodyLines($FRONTEND->parseJs($URL->parseJson()));
-               $FRONTEND->addBodyLines($URL->getContents());
-
-               // Print the page
-               $FRONTEND->printPage();
-       }
-}
-?>
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index ca7d3b3..41218e9 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -1596,11 +1596,14 @@ function parseAutomap(iMapCfgAge, mapName) {
  * @author  Lars Michelsen <[email protected]>
  */
 function parseUrl(sUrl) {
-       // FIXME: Fetch contents from server
+       // Fetch contents from server
+       var oUrlContents = 
getSyncRequest(oGeneralProperties.path_server+'?mod=Url&act=getContents&show='+escapeUrlValues(sUrl));
        
-       // FIXME: Clear the current contents
-       
-       // FIMXE: Add the contents to the page
+       if(typeof oUrlContents !== 'undefined' && oUrlContents.content) {
+               // Replace the current contents with the new url
+               var urlContainer = document.getElementById('url');
+               urlContainer.innerHTML = oUrlContents.content;
+       }
 }
 
 /**
diff --git a/share/server/core/ajax_handler.php 
b/share/server/core/ajax_handler.php
index 08c0e63..d5bf4e7 100644
--- a/share/server/core/ajax_handler.php
+++ b/share/server/core/ajax_handler.php
@@ -94,6 +94,7 @@ $MHANDLER->regModule('General');
 $MHANDLER->regModule('Overview');
 $MHANDLER->regModule('Map');
 $MHANDLER->regModule('AutoMap');
+$MHANDLER->regModule('Url');
 
 // Load the module
 $MODULE = $MHANDLER->loadModule($UHANDLER->get('mod'));
diff --git a/share/server/core/classes/CoreModUrl.php 
b/share/server/core/classes/CoreModUrl.php
new file mode 100644
index 0000000..25164eb
--- /dev/null
+++ b/share/server/core/classes/CoreModUrl.php
@@ -0,0 +1,63 @@
+<?php
+/*******************************************************************************
+ *
+ * CoreModUrl.php - Core module to handle ajax requests for urls
+ *
+ * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected])
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ 
******************************************************************************/
+
+/**
+ * @author Lars Michelsen <[email protected]>
+ */
+class CoreModUrl extends CoreModule {
+       private $url = null;
+       
+       public function __construct(GlobalCore $CORE) {
+               $this->CORE = $CORE;
+               
+               $aOpts = Array('show' => MATCH_STRING_URL);
+               $aVals = $this->getCustomOptions($aOpts);
+               $this->url = $aVals['show'];
+               
+               // Register valid actions
+               $this->aActions = Array(
+                       'getContents' => REQUIRES_AUTHORISATION
+               );
+       }
+       
+       public function handleAction() {
+               $sReturn = '';
+               
+               if($this->offersAction($this->sAction)) {
+                       switch($this->sAction) {
+                               case 'getContents':
+                                       $sReturn = $this->getContents();
+                               break;
+                       }
+               }
+               
+               return $sReturn;
+       }
+       
+       private function getContents() {
+               $URL = new NagVisUrl($this->CORE, $this->url);
+               return json_encode(Array('content' => $URL->getContents()));
+       }
+}
+?>
diff --git a/share/server/core/classes/NagVisHoverUrl.php 
b/share/server/core/classes/NagVisHoverUrl.php
index 67c1167..be46f35 100644
--- a/share/server/core/classes/NagVisHoverUrl.php
+++ b/share/server/core/classes/NagVisHoverUrl.php
@@ -85,7 +85,7 @@ class NagVisHoverUrl {
                // Reported here: 
http://news.gmane.org/find-root.php?message_id=%3cf60c42280909021938s7f36c0edhd66d3e9156a5d081%40mail.gmail.com%3e
                $aUrl = parse_url($this->url);
                if(!isset($aUrl['scheme']) || $aUrl['scheme'] == '') {
-                       echo new GlobalMessageBox('ERROR', 
$this->CORE->LANG->getText('problemReadingUrl', 'URL~'.$this->url.',MSG~Not 
allowed url'), $this->CORE->MAINCFG->getValue('paths','htmlbase'), 'error');
+                       echo new GlobalMessage('ERROR', 
$this->CORE->LANG->getText('problemReadingUrl', 'URL~'.$this->url.',MSG~Not 
allowed url'), null, 'error');
                        exit(1);
                }
 
diff --git a/share/server/core/classes/NagVisUrl.php 
b/share/server/core/classes/NagVisUrl.php
index d9ad3df..ab0d53e 100644
--- a/share/server/core/classes/NagVisUrl.php
+++ b/share/server/core/classes/NagVisUrl.php
@@ -59,14 +59,14 @@ class NagVisUrl {
                // Reported here: 
http://news.gmane.org/find-root.php?message_id=%3cf60c42280909021938s7f36c0edhd66d3e9156a5d081%40mail.gmail.com%3e
                $aUrl = parse_url($this->strUrl);
                if(!isset($aUrl['scheme']) || $aUrl['scheme'] == '') {
-                       echo new GlobalMessageBox('ERROR', 
$this->CORE->LANG->getText('problemReadingUrl', 'URL~'.$this->strUrl.',MSG~Not 
allowed url'), $this->CORE->MAINCFG->getValue('paths','htmlbase'), 'error');
+                       echo new GlobalMessage('ERROR', 
$this->CORE->LANG->getText('problemReadingUrl', Array('URL' => 
htmlentities($this->strUrl), 'MSG' => 'Not allowed url')), null, 'error');
                        exit(1);
                }
                                
                if(false == ($this->strContents = 
file_get_contents($this->strUrl))) {
                        $aError = error_get_last();
                        
-                       echo new GlobalMessageBox('ERROR', 
$this->CORE->LANG->getText('problemReadingUrl', 
'URL~'.$this->strUrl.',MSG~'.$aError['message']), 
$this->CORE->MAINCFG->getValue('paths','htmlbase'), 'error');
+                       echo new GlobalMessage('ERROR', 
$this->CORE->LANG->getText('problemReadingUrl', Array('URL' => 
htmlentities($this->strUrl), 'MSG' => $aError['message'])), null, 'error');
                }
                
                // set the old level of reporting back


------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Nagvis-checkins mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/nagvis-checkins

Reply via email to