Module: nagvis Branch: master Commit: 28feb7ed42581dfc8df17c5ce156c4417f3ceb18 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis/nagvis;a=commit;h=28feb7ed42581dfc8df17c5ce156c4417f3ceb18
Author: Lars Michelsen <[email protected]> Date: Tue Sep 8 21:22:07 2009 +0200 #8 More steps to make the ajax handler work with new structure --- .../frontend/nagvis-js/classes/NagVisFrontend.php | 5 +- .../classes/{GlobalMap.php => NagVisMapView.php} | 42 ++++++++++++-------- .../classes/controller/GlobalControllerMap.php | 5 +- share/server/core/ajax_handler.php | 16 ++++---- .../core}/classes/GlobalBackground.php | 0 .../core}/classes/GlobalMap.php | 0 .../core}/classes/NagVisContextMenu.php | 0 .../core}/classes/NagVisHoverMenu.php | 0 .../core}/classes/NagVisMap.php | 0 .../core}/classes/NagVisMapCfg.php | 0 10 files changed, 39 insertions(+), 29 deletions(-) diff --git a/share/frontend/nagvis-js/classes/NagVisFrontend.php b/share/frontend/nagvis-js/classes/NagVisFrontend.php index be77700..c6f8d24 100644 --- a/share/frontend/nagvis-js/classes/NagVisFrontend.php +++ b/share/frontend/nagvis-js/classes/NagVisFrontend.php @@ -138,9 +138,10 @@ class NagVisFrontend extends GlobalPage { public function getMap() { $this->addBodyLines('<div id="overDiv" style="position:absolute; visibility:hidden; z-index:1000;"></div>'); $this->addBodyLines('<div id="map" class="map"></div>'); - $this->MAP = new NagVisMap($this->CORE, $this->MAPCFG, null, false); + //FIXME: Need recoding here: $this->MAPCFG is the mapname and $this->MAP should be $this->VIEW + $this->MAP = new NagVisMapView($this->CORE, $this->MAPCFG); //FIXME: $this->MAP->MAPOBJ->checkMaintenance(1); - $this->addBodyLines($this->parseJs($this->MAP->parseMapJson())); + $this->addBodyLines($this->parseJs($this->MAP->parse())); } /** diff --git a/share/frontend/nagvis-js/classes/GlobalMap.php b/share/frontend/nagvis-js/classes/NagVisMapView.php similarity index 52% copy from share/frontend/nagvis-js/classes/GlobalMap.php copy to share/frontend/nagvis-js/classes/NagVisMapView.php index 2ae21b2..3acf087 100644 --- a/share/frontend/nagvis-js/classes/GlobalMap.php +++ b/share/frontend/nagvis-js/classes/NagVisMapView.php @@ -1,9 +1,9 @@ <?php /***************************************************************************** * - * GlobalMap.php - Class for parsing the NagVis maps + * NagVisMapView.php - Class for parsing the NagVis maps in nagvis-js frontend * - * Copyright (c) 2004-2008 NagVis Project (Contact: [email protected]) + * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected]) * * License: * @@ -25,34 +25,42 @@ /** * @author Lars Michelsen <[email protected]> */ -class GlobalMap { - protected $CORE; - protected $MAPCFG; - - private $linkedMaps = Array(); +class NagVisMapView { + private $CORE = null; + private $name = ''; /** * Class Constructor * - * @param GlobalCore $CORE - * @param GlobalMapCfg $MAPCFG + * @param GlobalCore $CORE + * @param String $NAME * @author Lars Michelsen <[email protected]> */ - public function __construct($CORE,$MAPCFG) { + public function __construct($CORE, $name) { $this->CORE = $CORE; - $this->MAPCFG = $MAPCFG; + + // FIXME: Already validated? + $this->name = $name; } /** - * Gets the background html code of the map + * Parses the map and the objects for the nagvis-js frontend * - * @param String $src html path - * @param String $style css parameters - * @return String HTML Code + * @return String String with JS Code * @author Lars Michelsen <[email protected]> */ - public function getBackgroundHtml($src, $style='', $attr='') { - return '<img id="background" src="'.$src.'" style="z-index:0;'.$style.'" alt="" '.$attr.'>'; + public function parse() { + $ret = ''; + $ret .= 'oGeneralProperties='.$this->CORE->MAINCFG->parseGeneralProperties().';'."\n"; + $ret .= 'oWorkerProperties='.$this->CORE->MAINCFG->parseWorkerProperties().';'."\n"; + + // Kick of the worker + $ret .= 'addDOMLoadEvent(function(){runWorker(0, \'map\', \''.$this->name.'\')});'; + + // This disables the context menu when someone clicked anywhere on the map + $ret .= 'document.body.onmousedown = contextMouseDown;'; + + return $ret; } } ?> diff --git a/share/frontend/nagvis-js/classes/controller/GlobalControllerMap.php b/share/frontend/nagvis-js/classes/controller/GlobalControllerMap.php index ea1c322..f71ae91 100644 --- a/share/frontend/nagvis-js/classes/controller/GlobalControllerMap.php +++ b/share/frontend/nagvis-js/classes/controller/GlobalControllerMap.php @@ -37,14 +37,15 @@ class GlobalControllerMap { // Load the core $CORE = new GlobalCore(); - + + //FIXME: Remove $MAPCFG somehow here? // Initialize map configuration $MAPCFG = new NagVisMapCfg($CORE, $this->mapName); // Read the map configuration file $MAPCFG->readMapConfig(); // Initialize the frontend - $FRONTEND = new NagVisFrontend($CORE, $MAPCFG, null); + $FRONTEND = new NagVisFrontend($CORE, $this->mapName, null); // Build the page $FRONTEND->addBodyLines($FRONTEND->parseJs('oRotationProperties = '.$FRONTEND->getRotationPropertiesJson(0).';')); diff --git a/share/server/core/ajax_handler.php b/share/server/core/ajax_handler.php index 3aa8db4..548c3db 100755 --- a/share/server/core/ajax_handler.php +++ b/share/server/core/ajax_handler.php @@ -22,16 +22,16 @@ * *****************************************************************************/ -// Include defines -require("./includes/defines/global.php"); -require("./includes/defines/matches.php"); +// Include global defines +require('../../server/core/defines/global.php'); +require('../../server/core/defines/matches.php'); // Include functions -require("./includes/functions/autoload.php"); -require("./includes/functions/debug.php"); -require("./includes/functions/oldPhpVersionFixes.php"); -require("./includes/functions/getuser.php"); -require("./includes/functions/ajaxErrorHandler.php"); +require('../../server/core/functions/autoload.php'); +require('../../server/core/functions/debug.php'); +require("../../server/core/functions/getuser.php"); +require('../../server/core/functions/oldPhpVersionFixes.php'); +require('../../server/core/functions/ajaxErrorHandler.php'); // This defines whether the GlobalFrontendMessage prints HTML or ajax error messages define('CONST_AJAX' , TRUE); diff --git a/share/frontend/nagvis-js/classes/GlobalBackground.php b/share/server/core/classes/GlobalBackground.php similarity index 100% rename from share/frontend/nagvis-js/classes/GlobalBackground.php rename to share/server/core/classes/GlobalBackground.php diff --git a/share/frontend/nagvis-js/classes/GlobalMap.php b/share/server/core/classes/GlobalMap.php similarity index 100% rename from share/frontend/nagvis-js/classes/GlobalMap.php rename to share/server/core/classes/GlobalMap.php diff --git a/share/frontend/nagvis-js/classes/NagVisContextMenu.php b/share/server/core/classes/NagVisContextMenu.php similarity index 100% rename from share/frontend/nagvis-js/classes/NagVisContextMenu.php rename to share/server/core/classes/NagVisContextMenu.php diff --git a/share/frontend/nagvis-js/classes/NagVisHoverMenu.php b/share/server/core/classes/NagVisHoverMenu.php similarity index 100% rename from share/frontend/nagvis-js/classes/NagVisHoverMenu.php rename to share/server/core/classes/NagVisHoverMenu.php diff --git a/share/frontend/nagvis-js/classes/NagVisMap.php b/share/server/core/classes/NagVisMap.php similarity index 100% rename from share/frontend/nagvis-js/classes/NagVisMap.php rename to share/server/core/classes/NagVisMap.php diff --git a/share/frontend/nagvis-js/classes/NagVisMapCfg.php b/share/server/core/classes/NagVisMapCfg.php similarity index 100% rename from share/frontend/nagvis-js/classes/NagVisMapCfg.php rename to share/server/core/classes/NagVisMapCfg.php ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
