[Mapbender-commits] r7015 - trunk/mapbender/http/javascripts

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon Oct 4 06:19:50 EDT 2010


Author: christoph
Date: 2010-10-04 10:19:50 +0000 (Mon, 04 Oct 2010)
New Revision: 7015

Modified:
   trunk/mapbender/http/javascripts/initWmcObj.php
Log:
check if sessionWmc module is available; if not, always load session Wmc from GET API

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2010-10-04 10:16:09 UTC (rev 7014)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2010-10-04 10:19:50 UTC (rev 7015)
@@ -29,7 +29,7 @@
 
 try {
 	$loadFromSession = new ElementVar($app, "loadwmc", "loadFromSession");
-	if ($loadFromSession->value === "1") {
+	if ($wmcDocSession && $loadFromSession->value === "1") {
 	//check if session contains a wmc,
 	//otherwise create a new wmc from application
 		$e = new mb_notice("trying to load session WMC...");
@@ -40,7 +40,7 @@
 		}
 	}
 	else {
-		$e = new mb_notice("loading from session WMC disabled in loadwmc.");
+		$e = new mb_notice("loading from session WMC disabled in loadwmc or no session WMC set.");
 		$e = new mb_notice("creating wmc from app: " . $app);
 		$wmc->createFromApplication($app);
 	}
@@ -142,14 +142,14 @@
 		else {
 			$currentWms = new wms();
 			if(is_numeric($key)) {
-			//get WMS by URL
-				if (is_string($val)) {
-					$currentWms->createObjFromXML($val);
-				}
 				//get WMS by ID
 				if (is_numeric($val)) {
 					$currentWms->createObjFromDBNoGui($val);
 				}
+				//get WMS by URL
+				else if (is_string($val)) {
+					$currentWms->createObjFromXML($val);
+				}
 				array_push($wmsArray, $currentWms);
 				$wmcGetApi->mergeWmsArray($wmsArray);
 				$wmsArray = array();
@@ -362,12 +362,20 @@
 //
 // Output
 //
+// Check if session WMC module is loaded
+$sql = "SELECT COUNT(e_id) AS i FROM gui_element WHERE fkey_gui_id = $1 AND e_id = $2";
+$v = array(Mapbender::session()->get("mb_user_gui"), "sessionWmc");
+$t = array("s", "s");
+$res = db_prep_query($sql, $v, $t);
+$row = db_fetch_assoc($res);
+$isSessionWmcModuleLoaded = intval($row["i"]);
 
 Mapbender::session()->set("wmcGetApi", $wmcGetApi);
 if (
 	count($resultObj["withoutId"]["wms"]) === 0 &&
 	count($resultObj["invalidId"]["wms"]) === 0 &&
-	count($resultObj["unavailable"]["wms"]) === 0
+	count($resultObj["unavailable"]["wms"]) === 0 ||
+	!$isSessionWmcModuleLoaded
 ) {
 	Mapbender::session()->set("wmcConstraints", $resultObj);
 	$output = $wmcGetApi->wmsToJavaScript();
@@ -396,7 +404,7 @@
 
 $GeoRSSStr = " Mapbender.events.afterInit.register(function () {";
 foreach($inputGeoRSSArray as $inputGeoRSSUrl){
-	$GeoRSSStr .= '$("#mapframe1").georss({url: "'.$inputGeoRSSUrl .'"})';
+	$GeoRSSStr .= 'try {$("#mapframe1").georss({url: "'.$inputGeoRSSUrl .'"})} catch(e) {new Mb_warning("GeoRSS module not loaded")}';
 }
 $GeoRSSStr .="}); ";
 
@@ -416,4 +424,4 @@
 Mapbender::session()->delete("addwms_zoomToExtent");
 unset($output);
 unset($wmc);
-?>
+?>
\ No newline at end of file



More information about the Mapbender_commits mailing list