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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Aug 24 08:28:59 EDT 2010


Author: verenadiewald
Date: 2010-08-24 12:28:59 +0000 (Tue, 24 Aug 2010)
New Revision: 6802

Modified:
   trunk/mapbender/http/javascripts/initWmcObj.php
Log:
current status for loading featuretype confs

Modified: trunk/mapbender/http/javascripts/initWmcObj.php
===================================================================
--- trunk/mapbender/http/javascripts/initWmcObj.php	2010-08-24 12:27:34 UTC (rev 6801)
+++ trunk/mapbender/http/javascripts/initWmcObj.php	2010-08-24 12:28:59 UTC (rev 6802)
@@ -215,12 +215,85 @@
 	}
 }
 
-//workaround to have a fully merged WMS for loading
+$getParams["FEATURETYPE"] = getConfiguration("FEATURETYPE");
 
+function normalizeFeaturetypeInput ($input) {
+	if (is_array($input)) {
+		$keys = array_keys($input);
+		$isSingleFeaturetype = false;
+		foreach ($keys as $key) {
+			if (!is_numeric($key)) {
+				$isSingleFeaturetype = true;
+				break;
+			}
+		}
+		// FEATURETYPE[id]=12&FEATURETYPE[active]=something
+		if ($isSingleFeaturetype) {
+			$input[0] = array();
+			foreach ($keys as $key) {
+				if (!is_numeric($key)) {
+					$input[0][$key] = $input[$key];
+					unset($input[$key]);
+				}
+			}
+		}
+		else {
+			for ($i = 0; $i < count($input); $i++) {
+				// assume FEATURETYPE[]=12&FEATURETYPE[]=13
+				if (is_numeric($input[$i])) {
+					$id = $input[$i];
+					$input[$i] = array("id" => $id);
+				}
+			}
+		}
+	}
+	else {
+		// assume FEATURETYPE=12,13,14
+		$inputArray = split(",", $input); 
+		$input = array();
+		$i = 0;
+		foreach ($inputArray as $id) {
+			if (is_numeric($id)) {
+				$input[$i++]["id"] = $id;
+			}
+		}
+	}
+	// check if each featuretype has at least an id, if not, delete
+	$i = 0;
+	while ($i < count($input)) {
+		if (!is_array($input[$i]) || !isset($input[$i]["id"]) || !is_numeric($input[$i]["id"])) {
+			array_splice($input, $i, 1);
+			continue;
+		}
+		$input[$i]["id"] = intval($input[$i]["id"]);
+		$i++;
+	}
+	return $input;
+}
+
+if ($getParams["FEATURETYPE"]) {
+	$inputFeaturetypeArray = normalizeFeaturetypeInput($getParams['FEATURETYPE']);
+
+	$wfsConfIds = array();	
+	foreach ($inputFeaturetypeArray as $input) {
+		array_push($wfsConfIds, $input["id"]);
+	}
+	
+	$wmc->generalExtensionArray['WFSCONFIDSTRING'] = implode(",", array_merge(
+		explode(",", $wmc->generalExtensionArray['WFSCONFIDSTRING']),
+		$wfsConfIds
+	));
+	//$firephp->log($wmc->generalExtensionArray['WFSCONFIDSTRING']);
+}
+
+//workaround to have a fully merged WMC for loading
+
 $xml = $wmc->toXml();
+#$firephp->log($xml);
 
 $wmc = new wmc();
 $wmc->createFromXml($xml);
+//$firephp->log($wmc);
 
 $output = $wmc->wmsToJavaScript();
 
@@ -228,10 +301,21 @@
 $extent = $wmc->mainMap->getExtent();
 Mapbender::session()->set("mb_myBBOX", $extent->min->x . "," . $extent->min->y . "," . $extent->max->x . "," . $extent->max->y);
 
+$outputString = "";
 for ($i = 0; $i < count($output); $i++) {
-	echo administration::convertOutgoingString($output[$i]);
+	$outputString .= administration::convertOutgoingString($output[$i]);
 }
 
+$wmcFeaturetypeJson = $wmc->featuretypeConfToJavaScript();
+$wmcFeaturetypeStr = "Mapbender.events.afterInit.register(function () {
+	$('#body').trigger('addFeaturetypeConfs', [{featuretypeConfObj : ".$wmcFeaturetypeJson."}]);
+});";
+
+$outputString .= $wmcFeaturetypeStr;
+
+echo $outputString;
+
+
 Mapbender::session()->delete("addwms_showWMS");
 Mapbender::session()->delete("addwms_zoomToExtent");
 unset($output);



More information about the Mapbender_commits mailing list