[Mapbender-commits] r10177 - in trunk/mapbender: http/classes http/javascripts http/plugins resources/locale/de_DE/LC_MESSAGES

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jul 3 02:35:45 PDT 2019


Author: armin11
Date: 2019-07-03 02:35:45 -0700 (Wed, 03 Jul 2019)
New Revision: 10177

Modified:
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/javascripts/initWmcObj.php
   trunk/mapbender/http/plugins/mb_sessionWmc.js
   trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po
Log:
Add message if external wms could not be loaded!

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2019-07-03 07:15:02 UTC (rev 10176)
+++ trunk/mapbender/http/classes/class_wms.php	2019-07-03 09:35:45 UTC (rev 10177)
@@ -1251,13 +1251,12 @@
 			$returnObject['success'] = false;
 			$returnObject['message'] = _mb("WMS could not be loaded!");
 			return $returnObject;	
-		}
-
-		else{
+		} else {
 			$this->wms_status = true;
 			$this->optimizeWMS();
 			$e = new mb_notice("class_wms: createObjFromXML: WMS " . $url . " has been loaded successfully.");
 			$returnObject['success'] = true;
+			$returnObject['message'] = _mb("WMS Capabilities has been parsed successfully!");
 			return $returnObject;	
 		}
 	}

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2019-07-03 07:15:02 UTC (rev 10176)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2019-07-03 09:35:45 UTC (rev 10177)
@@ -64,7 +64,11 @@
 	),
 	"wmcTou" => array(
 		"message" => ""
-	)
+	),
+	"notAccessable" => array(
+		"message" => _mb("Following WebMapService is not accessable or could not be invoked").":",
+		"wms" => array()
+	),
 );
 
 /*
@@ -218,33 +222,54 @@
 			// get WMS by URL
 			elseif (array_key_exists('url', $multipleAssocArray)) {
 				$currentWms = new wms();
-				$currentWms->createObjFromXML($multipleAssocArray['url']);
-			}
-			else {
+				//try to parse capabilities - if not successful give message to unavailable array!
+//$e = new mb_exception("javascripts/initWmcObj.php: begin result of wms parsing: ");
+				$resultOfWmsParsing = $currentWms->createObjFromXML($multipleAssocArray['url']);
+//$e = new mb_exception("javascripts/initWmcObj.php: result of wms parsing: ".json_encode($resultOfWmsParsing));
+			} else {
 				continue;
 			}
-			array_push($wmsArray, $currentWms);
-			$options['visible'] = $multipleAssocArray['visible'] === "1" ?
-				true : false;
-			$options['zoom'] = $multipleAssocArray['zoom'] === "1" ?
-				true : false;
-			$wmcGetApi->mergeWmsArray($wmsArray, $options);
-			$wmsArray = array();
-			$multipleAssocArray = array();
+//$e = new mb_exception("javascripts/initWmcObj.php: result of wms parsing: ".json_encode($resultOfWmsParsing));
+			if ($resultOfWmsParsing['success'] == true) {
+				array_push($wmsArray, $currentWms);
+				$options['visible'] = $multipleAssocArray['visible'] === "1" ?
+					true : false;
+				$options['zoom'] = $multipleAssocArray['zoom'] === "1" ?
+					true : false;
+				$wmcGetApi->mergeWmsArray($wmsArray, $options);
+				$wmsArray = array();
+				$multipleAssocArray = array();
+			} else {
+//$e = new mb_exception("javascripts/initWmcObj.php: wms with problem: ".$multipleAssocArray['url']);
+				$resultObj["notAccessable"]["wms"] = array_merge(
+					$resultObj["notAccessable"]["wms"],
+					$multipleAssocArray['url'].' - '.$resultOfWmsParsing['message']
+					);	
+			}
 		} else {
 			$currentWms = new wms();
 			if(is_numeric($key)) {
 				// get WMS by ID
 				if (is_numeric($val)) {
-					$currentWms->createObjFromDBNoGui($val);
+					$resultOfWmsParsing = $currentWms->createObjFromDBNoGui($val);
 				}
 				// get WMS by URL
 				else if (is_string($val)) {
-					$currentWms->createObjFromXML($val);
+					$resultOfWmsParsing = $currentWms->createObjFromXML($val);
 				}
-				array_push($wmsArray, $currentWms);
-				$wmcGetApi->mergeWmsArray($wmsArray);
-				$wmsArray = array();
+				if ($resultOfWmsParsing['success'] == true) {
+					array_push($wmsArray, $currentWms);
+					$options['visible'] = $multipleAssocArray['visible'] === "1" ?
+						true : false;
+					$options['zoom'] = $multipleAssocArray['zoom'] === "1" ?
+						true : false;
+					$wmcGetApi->mergeWmsArray($wmsArray, $options);
+					$wmsArray = array();
+					$multipleAssocArray = array();
+				} else {
+//$e = new mb_exception("javascripts/initWmcObj.php: wms with problem: message: ".(string)$val." - ".$resultOfWmsParsing['message']);
+					$resultObj["notAccessable"]["wms"][] = htmlentities($val)." - ("._mb('Notice')."</b>: ".$resultOfWmsParsing['message'].")";
+				}
 			}
 			else {
 				$singleAssocArray[$key] = $val;

Modified: trunk/mapbender/http/plugins/mb_sessionWmc.js
===================================================================
--- trunk/mapbender/http/plugins/mb_sessionWmc.js	2019-07-03 07:15:02 UTC (rev 10176)
+++ trunk/mapbender/http/plugins/mb_sessionWmc.js	2019-07-03 09:35:45 UTC (rev 10177)
@@ -137,6 +137,11 @@
 				dialogHasContent = true;
 				continue;
 			}
+			/*if (constraintType === "notAccessable" && caseObj.message != "") {
+				html += "<fieldset>"+caseObj.message+"</fieldset>";
+				dialogHasContent = true;
+				continue;
+			}*/
 			if (caseObj.wms && caseObj.wms.length === 0) {
 				continue;
 			}
@@ -144,19 +149,29 @@
 			var permissionHtml = "";
 			for (var index in caseObj.wms) {
 				var wms = caseObj.wms[index];
-				permissionHtml += "<label for='" + constraintType + "_" + wms.index + "'>" +
-				(constraintType === "noPermission" ? "<li>" : "<input id='" + options.id + "_" + constraintType + "_" + wms.index + "' " + "type='checkbox' checked='checked' />") +
-				wms.title  + "</label><br>";
-				wmsCount++;
+				if (constraintType !== "notAccessable") {
+					permissionHtml += "<label for='" + constraintType + "_" + wms.index + "'>" +
+					(constraintType === "noPermission" ? "<li>" : "<input id='" + options.id + "_" + constraintType + "_" + wms.index + "' " + "type='checkbox' checked='checked' />") +
+					wms.title  + "</label><br>";
+					wmsCount++;
+				} else {
+					permissionHtml += wms;
+					wmsCount++;
+				}
 			}
 			if (wmsCount > 0) {
-				html += "<fieldset>" + caseObj.message +
-					(constraintType === "noPermission" ?
-						"<br><ul>" + permissionHtml + "</ul>" :
-						" "+translatedI18nObject.confirmationQuestion+"<br><br>" +
-						permissionHtml
-					) + "</fieldset><br>";
-				dialogHasContent = true;
+				//if (constraintType !== "notAccessable") {
+					html += "<fieldset>" + caseObj.message +
+						(constraintType === "noPermission" ?
+							"<br><ul>" + permissionHtml + "</ul>" :
+							(constraintType === "notAccessable" ?
+							"<br><br>" :
+							" "+translatedI18nObject.confirmationQuestion+"<br><br>"
+							) +
+							permissionHtml
+						) +
+  						"</fieldset><br>";
+					dialogHasContent = true;
 			}
 			constraintTypeArray.push(constraintType);
 		}

Modified: trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po
===================================================================
--- trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po	2019-07-03 07:15:02 UTC (rev 10176)
+++ trunk/mapbender/resources/locale/de_DE/LC_MESSAGES/Mapbender.po	2019-07-03 09:35:45 UTC (rev 10177)
@@ -4314,4 +4314,10 @@
 msgid "based on links from metadata"
 msgstr "basierend auf Verlinkungen in Metadaten"
 
+msgid "Following WebMapService is not accessable or could not be invoked"
+msgstr "Der folgenden WebMapService ist nicht erreichbar oder konnte nicht richtig aufgerufen werden"
 
+msgid "Notice"
+msgstr "Hinweis"
+
+



More information about the Mapbender_commits mailing list