[Mapbender-commits] r10240 - in trunk/mapbender/http: classes php

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu Sep 12 01:52:40 PDT 2019


Author: armin11
Date: 2019-09-12 01:52:40 -0700 (Thu, 12 Sep 2019)
New Revision: 10240

Modified:
   trunk/mapbender/http/classes/class_wfs.php
   trunk/mapbender/http/php/mod_linkedDataProxy.php
Log:
Possibility to have rest api for linkedDataProxy - rewrite rule for apache needed - see mapbender.conf

Modified: trunk/mapbender/http/classes/class_wfs.php
===================================================================
--- trunk/mapbender/http/classes/class_wfs.php	2019-09-12 08:51:10 UTC (rev 10239)
+++ trunk/mapbender/http/classes/class_wfs.php	2019-09-12 08:52:40 UTC (rev 10240)
@@ -414,7 +414,7 @@
 				$srsName = "EPSG:".$srsId;
 				break;
 		}
-$e = new mb_exception($filter);
+		//$e = new mb_exception($filter);
 		if($storedQueryId && $storedQueryId != "") {
 		    $postData = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" .
 				"<wfs:GetFeature service=\"WFS\" version=\"" . $version . "\" " .

Modified: trunk/mapbender/http/php/mod_linkedDataProxy.php
===================================================================
--- trunk/mapbender/http/php/mod_linkedDataProxy.php	2019-09-12 08:51:10 UTC (rev 10239)
+++ trunk/mapbender/http/php/mod_linkedDataProxy.php	2019-09-12 08:52:40 UTC (rev 10240)
@@ -5,6 +5,9 @@
 require_once(dirname(__FILE__)."/../classes/class_gml_3_factory.php");
 require_once(dirname(__FILE__)."/../classes/class_owsConstraints.php");
 require_once(dirname(__FILE__)."/../classes/class_connector.php");//for resolving external @context content
+global $rewritePath;
+global $behindRewrite;
+global $linkedDataProxyUrl;
 
 if (file_exists(dirname(__FILE__)."/../../conf/linkedDataProxy.json")) {
      $configObject = json_decode(file_get_contents("../../conf/linkedDataProxy.json"));
@@ -46,6 +49,17 @@
     $maxxFC = 51;
     $maxyFC = 9;
 }
+if (isset($configObject) && isset($configObject->behind_rewrite) && $configObject->behind_rewrite == true) {
+    $behindRewrite = true;
+} else {
+    $behindRewrite = false;
+}
+if (isset($configObject) && isset($configObject->rewrite_path) && $configObject->rewrite_path != "") {
+    $rewritePath = $configObject->rewrite_path;
+} else {
+    $rewritePath = "linkedDataProxy";
+}
+
 //textual data:
 $textualDataArray = array("title", "description", "datasource_url", "legal_notice_link", "privacy_notice_link", "map_position");
 
@@ -56,6 +70,20 @@
 $privacy_notice_link = "https://www.geoportal.rlp.de/article/Datenschutz";
 $map_position = "side";
 
+if (!empty($_SERVER['HTTPS'])) {
+    $schema = "https";
+} else {
+    $schema = "http";
+}
+
+$linkedDataProxyUrl = $schema."://".$_SERVER['HTTP_HOST']."/".$rewritePath;
+//$e = new mb_exception($linkedDataProxy);
+
+if ($behindRewrite == true) {
+    $cssFile = MAPBENDER_PATH."/php/".$cssFile;  
+    $imagePathReplace = MAPBENDER_PATH."/img/";  //for license symbols exhange ../img/ with this string!
+}
+
 foreach ($textualDataArray as $textualData) {
     if (isset($configObject) && isset($configObject->{$textualData}) && $configObject->{$textualData} != "") {
         ${$textualData} = $configObject->{$textualData};
@@ -143,9 +171,147 @@
     } else {
         return $returnObject;
     } 
-    
 }
-//handle http request parameters
+
+//TODO - built function to map get parameters back to combined rest/get uri
+// wfsid=...&collection=....&item=...&f=html -> /linkedDataProxy/{wfsid}/collections/{collectionId}/items/{itemId}?f=html
+//uri of proxy have to be given absolute? - 
+
+//http://localhost/linkedDataProxy/19/collections/TEHG_RLP%3Atehg_anlagen_2013_gesamt/items
+//http://localhost/linkedDataProxy/19/
+//preg_grep()
+
+function get2Rest($requestString) { 
+    global $linkedDataProxyUrl;
+    global $behindRewrite;
+    //return $requestString;
+    if ($behindRewrite == true) {
+	    $e = new mb_notice("php/mod_linkedDataProxy.php function get2Rest string to exchange: ".$requestString);
+	    //get query part:
+	    if (strpos($requestString, "?") !== false) {
+		$queryPartArray = explode("?", $requestString);
+		$queryString = $queryPartArray[1];
+	    } else {
+		$queryString = $requestString;
+	    }
+	    $e = new mb_notice("php/mod_linkedDataProxy.php function get2Rest found query: ".$queryString);
+	    //map queryString to rest url
+	    parse_str($queryString, $requestArray);    
+	    $e = new mb_notice("php/mod_linkedDataProxy.php function get2Rest array of get parameters: ".json_encode($requestArray));
+	    //initialize new api path
+	    $apiPath = ''; //would be relative
+	    //parts of api to extract from query
+	    $apiParams = array("wfsid", "collections", "collection", "items", "item");
+	    //build path from params
+	    if (isset($requestArray['wfsid']) && $requestArray['wfsid'] != "") {
+		$apiPath .= "/".$requestArray['wfsid']."";
+	    }
+	    if (isset($requestArray['collection']) && $requestArray['collection'] != "") {
+		if ($requestArray['collection'] == "all") {
+		    $apiPath .= "/collections";
+		} else {
+		    $apiPath .= "/collections/".$requestArray['collection']."";
+		}
+	    }
+	    if (isset($requestArray['items']) && $requestArray['items'] != "") {
+		if ($requestArray['items'] == "all") {
+		    $apiPath .= "/items";
+		}
+	    }
+	    if (isset($requestArray['item']) && $requestArray['item'] != "") {
+		    $apiPath .= "/items/".$requestArray['item'];
+	    }
+	    //remove all $apiParams from initial requestArray
+	    foreach ($apiParams as $apiParamName) {
+		unset($requestArray[$apiParamName]);
+	    }
+	    //unset empty request elements - relicts?
+	    foreach ($requestArray as $key => $value){
+		if ($value == "") {
+		    unset($requestArray[$key]);
+		}
+	    }
+	    $e = new mb_notice("php/mod_linkedDataProxy.php function get2Rest extracted api path: ".$apiPath);
+	    $e = new mb_notice("php/mod_linkedDataProxy.php function get2Rest further get parameters to add to api path: ".json_encode($requestArray));
+	    //build new url from proxyPath, apiPath and the further get parameters
+            if ($apiPath == "" && http_build_query($requestArray) == "") {
+		$newUrl = $linkedDataProxyUrl."/";
+            } else {
+	        $newUrl = $linkedDataProxyUrl.$apiPath."?".ltrim(http_build_query($requestArray), "&");
+	    }
+	    $e = new mb_notice("php/mod_linkedDataProxy.php function get2Rest new absolute url for href: ".$newUrl);
+	    return str_replace("?&", "?", rtrim($newUrl, "?"));
+    } else {
+        return $requestString;
+    }
+}
+
+//first get request parameter for api - if invoked behind apache2 mod_rewrite to built REST
+if (isset($_REQUEST["api"]) && $_REQUEST["api"] != "") {
+    $e = new mb_notice("php/mod_linkedDataProxy.php try to read GET parameters from api: ".$_REQUEST["api"]);
+    //first get whole request "api" divide it by ? to distinguish query parameters from rest uris
+    if (strpos($_REQUEST["api"], "?") !== false){
+	$pathArray = explode('?', $_REQUEST["api"]);
+	$restPath = $pathArray[0];
+	$queryString = $pathArray[1];
+        //TODO foreach $queryString object generate one $_REQUEST[] variable - if allowed!!!!! - make a lookup table
+    } else {
+        $restPath = $_REQUEST["api"];
+    }
+    //parse api - split by / - template: {wfsid}/collection/{collectionId}/items/{itemId}
+    $requestParams = explode("/", $restPath);
+    //array to store the request params from rest api - merge them afterward to get right request_uri!
+    $apiParamsArray = array();
+    switch (count($requestParams)) {
+        case "1":
+            $_REQUEST["wfsid"] = $requestParams[0];
+            //$apiParamsArray["wfsid"] = $requestParams[0];
+            break;
+        case "2":
+            if ($requestParams[1] == "collections") {
+                $_REQUEST["wfsid"] = $requestParams[0]; 
+                $_REQUEST["collections"] = "all";
+            } else {		
+		echo 'URI not valid! {wfsid}/collection<br/>'; 
+		die(); 
+	    }
+            break;
+        case "3":
+            if ($requestParams[1] == "collections") {
+                $_REQUEST["wfsid"] = $requestParams[0];
+                $_REQUEST["collection"] = $requestParams[2];
+		$_REQUEST["items"] = "all";
+            } else {		
+		echo 'URI not valid! {wfsid}/collections/{collectionId} <br/>'; 
+		die(); 
+	    }
+            break;
+        case "4":
+            if ($requestParams[1] == "collections" && $requestParams[3] == "items") {
+                $_REQUEST["wfsid"] = $requestParams[0];
+                $_REQUEST["collection"] = $requestParams[2];
+		$_REQUEST["items"] = "all";
+            } else {		
+		echo 'URI not valid! {wfsid}/collections/{collectionId}/items <br/>'; 
+		die(); 
+	    }
+            break;
+        case "5":
+            if ($requestParams[1] == "collections" && $requestParams[3] == "items") {
+                $_REQUEST["wfsid"] = $requestParams[0];
+                $_REQUEST["collection"] = $requestParams[2];
+		$_REQUEST["item"] = $requestParams[4];
+            } else {		
+		echo 'URI not valid! {wfsid}/collections/{collectionId}/items/{itemId} <br/>'; 
+		die(); 
+	    }
+            break;
+    }
+}
+
+//TODO - built function to map get parameters back to combined rest/get uri
+// wfsid=...&collection=....&item=...&f=html -> /linkedDataProxy/{wfsid}/collections/{collectionId}/items/{itemId}?f=html
+
 //parse request parameters
 if (isset($_REQUEST["wfsid"]) & $_REQUEST["wfsid"] != "") {
 	//validate to csv integer list
@@ -240,7 +406,7 @@
 	$testMatch = NULL;
 }
 if (isset($_REQUEST["item"]) & $_REQUEST["item"] != "") {
-	//validate to csv integer list
+	//reg expr
 	$testMatch = $_REQUEST["item"];
 	$pattern = '/^[0-9a-zA-Z\.\-_:]*$/';	
  	if (!preg_match($pattern,$testMatch)){ 
@@ -303,6 +469,40 @@
 	}
 	$testMatch = NULL;
 }
+
+//merge together all request parameters to new global available query_string which is needed for further href's 
+//this string holds parts from rest url and the further parameters in case of rewrite (rest) and simple invocation via php script
+$wholeQueryArray = $_REQUEST;
+//unset api part from rewrite, cause this was already read before and intgrated into request array
+unset($wholeQueryArray['api']);
+//remove api from 
+global $wholeQuery;
+$wholeQuery = http_build_query($wholeQueryArray);
+//************************************************************************************************************************************
+//overwrite request_uri if invoked from rest api to add further parameters which came from api path
+$e = new mb_notice("php/linkedDataProxy.php: Original request URI: ".$_SERVER['REQUEST_URI']);
+$e = new mb_notice("php/linkedDataProxy.php: Mapping to GET Parameters: ".$wholeQuery);
+//************************************************************************************************************************************
+//remove api from $_SERVER['REQUEST_URI']
+$_SERVER['REQUEST_URI'] = delTotalFromQuery("api", $_SERVER['REQUEST_URI']);
+//add all other parameters
+if (isset($_REQUEST['api']) && $_REQUEST['api'] != "") {
+	if (strpos($_SERVER['REQUEST_URI'], "?") !== false){
+	    $requestUriArray = explode("?", $_SERVER['REQUEST_URI']);
+	    $_SERVER['REQUEST_URI'] = $requestUriArray[0]."?".$wholeQuery;
+	} else {
+	    $_SERVER['REQUEST_URI'] = $wholeQuery;
+	}
+}
+//************************************************************************************************************************************
+$e = new mb_notice("php/linkedDataProxy.php: \$_SERVER['REQUEST_URI'] after \"api\" paramter deleted: ".$_SERVER['REQUEST_URI']);
+//example when invoked from rest api:
+//before: /mapbender/php/mod_linkedDataProxy.php?api=18/collections
+//after: wfsid=18&collections=all
+//therefor we need a resubstitution of the /mapbender/php/mod_linkedDataProxy.php with {proxyPath} and
+//the build the further path fom the relevant GET parameters 
+// function get2Rest() -> does the work
+//************************************************************************************************************************************
 $proxyStartTime = microtime_float();
 //instantiate needed classes 
 $cache = new Cache();
@@ -373,7 +573,10 @@
 	    $constraints->id = $wfsid;
 	    $constraints->type = "wfs";
 	    $constraints->returnDirect = false;
-	    $tou = $constraints->getDisclaimer();//TODO encoding problems occur!
+	    $tou = $constraints->getDisclaimer();//TODO encoding problems may occur!
+	    if (isset($imagePathReplace)) {
+		$tou = str_replace("../img/", $imagePathReplace, $tou);
+	    }
 	    if ($f == "html") {
 		$returnObject->license = $tou; //- generate license info in json for json format!!!!!
 	    }
@@ -385,11 +588,11 @@
 	    $returnObject->links[0]->rel = "self";
 	    $returnObject->links[0]->type = "application/json";
 	    $returnObject->links[0]->title = "this document";
-	    $returnObject->links[0]->href = $_SERVER['REQUEST_URI']."&f=json";
+	    $returnObject->links[0]->href = get2Rest($_SERVER['REQUEST_URI']."&f=json");
 	    $returnObject->links[1]->rel = "alternate";
 	    $returnObject->links[1]->type = "text/html";
 	    $returnObject->links[1]->title = "this document as HTML";
-	    $returnObject->links[1]->href = $_SERVER['REQUEST_URI']."&f=html";
+	    $returnObject->links[1]->href = get2Rest($_SERVER['REQUEST_URI']."&f=html");
 	    //TODO service api
 	    //TODO conformance
 	    //TODO data
@@ -396,7 +599,7 @@
 	    $returnObject->links[2]->rel = "data";
 	    $returnObject->links[2]->type = "application/json";
 	    $returnObject->links[2]->title = "Metadata about the feature collections";
-	    $returnObject->links[2]->href = $_SERVER['REQUEST_URI']."&collections=all";
+	    $returnObject->links[2]->href = get2Rest($_SERVER['REQUEST_URI']."&collections=all");
 	    //available crs? - howto get from capabilities
 	    
             //************************************************************************************************************************************
@@ -412,13 +615,13 @@
 		$returnObject->collections[$collectionCount]->links[0]->rel = "item";
 		$returnObject->collections[$collectionCount]->links[0]->type = "application/json";
                 $returnObject->collections[$collectionCount]->links[0]->title = $featureType->title." as GeoJSON";
-		$returnObject->collections[$collectionCount]->links[0]->href = $_SERVER['REQUEST_URI']."&collection=".$featureType->name."&items=all";
+		$returnObject->collections[$collectionCount]->links[0]->href = get2Rest($_SERVER['REQUEST_URI']."&collection=".$featureType->name."&items=all");
 		//one item entry for each format!
 		//self
 		$returnObject->collections[$collectionCount]->links[1]->rel = "self";
 		$returnObject->collections[$collectionCount]->links[1]->type = "application/json";
                 $returnObject->collections[$collectionCount]->links[1]->title = "Information about the ".$featureType->title." data";
-		$returnObject->collections[$collectionCount]->links[1]->href = $_SERVER['REQUEST_URI']."&collection=".$featureType->name;
+		$returnObject->collections[$collectionCount]->links[1]->href = get2Rest($_SERVER['REQUEST_URI']."&collection=".$featureType->name);
 		//alternate
 		//TODO
 		$returnObject->collections[$collectionCount]->extent->crs = array();
@@ -493,7 +696,7 @@
 		    $returnObject->links[0]->rel = "item";
 		    $returnObject->links[0]->type = "application/geo+json";
  		    $returnObject->links[0]->title = $myFeatureType->title." as GeoJSON";
-                    $returnObject->links[0]->href = $_SERVER['REQUEST_URI']."&collection=".$featureType->name."&items=all&f=json";
+                    $returnObject->links[0]->href = get2Rest($_SERVER['REQUEST_URI']."&collection=".$featureType->name."&items=all&f=json");
 		    //TODO: items in other formats, self, alternate
 		    if ($items == "all") { //show items in list!
 			//reinitialize object!
@@ -509,7 +712,7 @@
 			$returnObject->links[0]->rel = "self";
 			$returnObject->links[0]->type = "application/geo+json";			
 			$returnObject->links[0]->title = "this document";
-			$returnObject->links[0]->href = $_SERVER['REQUEST_URI'];
+			$returnObject->links[0]->href = get2Rest($_SERVER['REQUEST_URI']);
 			//TODO  alternate
 		        //check for given spatialFilter (bbox)
 		        if (isset($bbox) && $bbox != '') {
@@ -646,13 +849,13 @@
 			$returnObject->links[1]->type = "application/geo+json";			
 			$returnObject->links[1]->title = "next page";
 			//$returnObject->links[1]->href = $_SERVER['REQUEST_URI']."&p=".($page + 1);
-			$returnObject->links[1]->href = $_SERVER['REQUEST_URI']."&offset=".($offset + 1 * $limit)."&limit=".$limit;
+			$returnObject->links[1]->href = get2Rest($_SERVER['REQUEST_URI']."&offset=".($offset + 1 * $limit)."&limit=".$limit);
 			//for rlp
 			$returnObject->links[2]->rel = "last";
 			$returnObject->links[2]->type = "application/geo+json";			
 			$returnObject->links[2]->title = "last page";
 			//$returnObject->links[1]->href = $_SERVER['REQUEST_URI']."&p=".($page + 1);
-			$returnObject->links[2]->href = $_SERVER['REQUEST_URI']."&offset=".$lastOffset."&limit=".$limit;
+			$returnObject->links[2]->href = get2Rest($_SERVER['REQUEST_URI']."&offset=".$lastOffset."&limit=".$limit);
 			//check if outputformat geojson is available - if - gml don't need to be parsed!!!!! TODO - where to become hits ????? - has to count in a special request!!!!!
 			if (in_array('application/json; subtype=geojson', explode(',', $ftOutputFormats)) && $nativeJson == true) {
 			//if (false) {
@@ -1060,17 +1263,17 @@
 			$returnObject->collectionName = $ftName;
 			$returnObject->collectionTitle = $myFeatureType->title;
 			//end rlp specific
-		    	$returnObject->links[0]->href =  $_SERVER['REQUEST_URI'];
+		    	$returnObject->links[0]->href =  get2Rest($_SERVER['REQUEST_URI']);
 		   	$returnObject->links[0]->rel =  "self";
 		   	$returnObject->links[0]->type = "application/geo+json";
 		   	$returnObject->links[0]->title = "this document";
 
-		        $returnObject->links[1]->href =  $_SERVER['REQUEST_URI'];
+		        $returnObject->links[1]->href =  get2Rest($_SERVER['REQUEST_URI']);
 		        $returnObject->links[1]->rel =  "alternate";
 		        $returnObject->links[1]->type = "text/html";
 		        $returnObject->links[1]->title = "this document as HTML";
 
-		        $returnObject->links[2]->href =  $_SERVER['REQUEST_URI'];
+		        $returnObject->links[2]->href =  get2Rest($_SERVER['REQUEST_URI']);
 		        $returnObject->links[2]->rel =  "alternate";
 		        $returnObject->links[2]->type = "application/gml+xml;profile=\"http://www.opengis.net/def/profile/ogc/2.0/gml-sf2\";version=3.2";
 		        $returnObject->links[2]->title = "this document as GML";
@@ -1182,7 +1385,11 @@
 	$html .= '<script src="https://unpkg.com/leaflet@1.5.1/dist/leaflet.js" integrity="sha512-GffPMF3RvMeYyc1LWMHtK8EbPv0iNZ8/oTtHPx9/cc2ILxQ+u905qIwdpULaqDkyBKgOaB57QTMg7ztg8Jm2Og==" crossorigin=""></script>'.$newline;
 	//bootstrap
 	if ($useInternalBootstrap == true) {
-            $html .= '<link rel="stylesheet" href="../extensions/bootstrap-4.0.0-dist/css/bootstrap.min.css">'.$newline;
+	    if ($behindRewrite == true) {
+                $html .= '<link rel="stylesheet" href="'.MAPBENDER_PATH.'/extensions/bootstrap-4.0.0-dist/css/bootstrap.min.css">'.$newline;
+            } else {
+                $html .= '<link rel="stylesheet" href="../extensions/bootstrap-4.0.0-dist/css/bootstrap.min.css">'.$newline;
+	    }
 	} else {
 	    $html .= '<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">'.$newline;
 	}
@@ -1208,19 +1415,19 @@
             $html .= '</ol>';
 	} else {
 	    if (!isset($collection) || $collections == 'all') {
-	        $html .= '<li class="breadcrumb-item"><a href="'.rtrim(delTotalFromQuery(array("f","wfsid","nativeJson"), $_SERVER['REQUEST_URI']),'?').'">Datasets</a></li>'.$newline; //TODO - use base uri
+	        $html .= '<li class="breadcrumb-item"><a href="'.get2Rest(rtrim(delTotalFromQuery(array("f","wfsid","nativeJson"), $_SERVER['REQUEST_URI']),'?')).'">Datasets</a></li>'.$newline; //TODO - use base uri
                 $html .= '<li class="breadcrumb-item active">'.$returnObject->title.'</li>'.$newline;
                 $html .= '</ol>';
 	    } else {
 		if (!isset($item) || $items == 'all') {
-		    $html .= '<li class="breadcrumb-item"><a href="'.rtrim(delTotalFromQuery(array_merge(array("f","wfsid","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?').'">Datasets</a></li>'.$newline; //TODO - use base uri
-                    $html .= '<li class="breadcrumb-item"><a href="'.rtrim(delTotalFromQuery(array_merge(array("f","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?').'">'.$returnObject->serviceTitle.'</a></li>'.$newline;
+		    $html .= '<li class="breadcrumb-item"><a href="'.get2Rest(rtrim(delTotalFromQuery(array_merge(array("f","wfsid","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?')).'">Datasets</a></li>'.$newline; //TODO - use base uri
+                    $html .= '<li class="breadcrumb-item"><a href="'.get2Rest(rtrim(delTotalFromQuery(array_merge(array("f","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?')).'">'.$returnObject->serviceTitle.'</a></li>'.$newline;
                     $html .= '<li class="breadcrumb-item active">'.$returnObject->collectionTitle.'</li>'.$newline;
                     $html .= '</ol>';
 		} else {
-		    $html .= '<li class="breadcrumb-item"><a href="'.rtrim(delTotalFromQuery(array_merge(array("f","wfsid","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?').'">Datasets</a></li>'.$newline; //TODO - use base uri
-                    $html .= '<li class="breadcrumb-item"><a href="'.rtrim(delTotalFromQuery(array_merge(array("f","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?').'">'.$returnObject->serviceTitle.'</a></li>'.$newline;
-		    $html .= '<li class="breadcrumb-item"><a href="'.rtrim(delTotalFromQuery(array_merge(array("f","item","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?').'&items=all'.'">'.$returnObject->collectionTitle.'</a></li>'.$newline;
+		    $html .= '<li class="breadcrumb-item"><a href="'.get2Rest(rtrim(delTotalFromQuery(array_merge(array("f","wfsid","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?')).'">Datasets</a></li>'.$newline; //TODO - use base uri
+                    $html .= '<li class="breadcrumb-item"><a href="'.get2Rest(rtrim(delTotalFromQuery(array_merge(array("f","collection","collections","item","items","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?')).'">'.$returnObject->serviceTitle.'</a></li>'.$newline;
+		    $html .= '<li class="breadcrumb-item"><a href="'.get2Rest(rtrim(delTotalFromQuery(array_merge(array("f","item","limit","offset","bbox","nativeJson"), $stringFilterActive), $_SERVER['REQUEST_URI']),'?').'&items=all').'">'.$returnObject->collectionTitle.'</a></li>'.$newline;
                     $html .= '<li class="breadcrumb-item active">'.$returnObject->id.'</li>'.$newline;
                     $html .= '</ol>';
 		}
@@ -1228,11 +1435,11 @@
 	    // other formats ! for collection, item, ...
 	    //if (!isset($item)) {
                 $html .= '<ul class="list-separated m-0 p-0 text-muted">'.$newline;
-                $html .= '    <li><a href="'.rtrim(delTotalFromQuery("f", $_SERVER['REQUEST_URI']),'?').'&f=json" target="_blank">GeoJSON</a></li>'.$newline;
+                $html .= '    <li><a href="'.get2Rest(rtrim(delTotalFromQuery("f", $_SERVER['REQUEST_URI']),'?').'&f=json').'" target="_blank">GeoJSON</a></li>'.$newline;
 		if (isset($collection) || $collections == 'all') {
-                    $html .= '    <li><a href="'.rtrim(delTotalFromQuery("f", $_SERVER['REQUEST_URI']),'?').'&f=xml" target="_blank">GML</a></li>'.$newline;
+                    $html .= '    <li><a href="'.get2Rest(rtrim(delTotalFromQuery("f", $_SERVER['REQUEST_URI']),'?').'&f=xml').'" target="_blank">GML</a></li>'.$newline;
 		} else {
-			$html .= '    <li><a href="'.rtrim(delTotalFromQuery("f", $_SERVER['REQUEST_URI']),'?').'&f=xml" target="_blank">XML</a></li>'.$newline;
+			$html .= '    <li><a href="'.get2Rest(rtrim(delTotalFromQuery("f", $_SERVER['REQUEST_URI']),'?').'&f=xml').'" target="_blank">XML</a></li>'.$newline;
 		}
                 $html .= '</ul> '.$newline;
 	    //}
@@ -1265,7 +1472,7 @@
 	    foreach ($returnObject->service as $service) {
 	        $html .= '            <li itemprop="dataset" itemscope itemtype="http://schema.org/Dataset">'.$newline;
                 $html .= '                <h2>'.$newline;
-                $html .= '                    <a itemprop="url" href="'.rtrim($_SERVER['REQUEST_URI'],'?').'?wfsid='.$service->id.'">'.$newline;
+                $html .= '                    <a itemprop="url" href="'.get2Rest(rtrim($_SERVER['REQUEST_URI'],'?').'?wfsid='.$service->id).'">'.$newline;
                 $html .= '                        <span itemprop="name">'.$service->title.' (WFS '.$service->version.')</span>'.$newline;
                 $html .= '                    </a>'.$newline;
                 $html .= '                </h2>'.$newline;
@@ -1284,9 +1491,9 @@
                 $html .= '    <div itemscope itemtype="http://schema.org/Dataset">'.$newline;
         	$html .= '        <h1 itemprop="name">'.$returnObject->title.'</h1>'.$newline;
        	 	$html .= '        <span itemprop="description">'.$returnObject->description.'</span>'.$newline;
-        	$html .= '        <p itemprop="url" class="d-none">'.$_SERVER['REQUEST_URI'].'</p>'.$newline;//TODO canonical url
+        	$html .= '        <p itemprop="url" class="d-none">'.get2Rest($_SERVER['REQUEST_URI']).'</p>'.$newline;//TODO canonical url
             	$html .= '        <div itemprop="includedInDataCatalog" itemscope itemtype="http://schema.org/Datacatalog" class="d-none">'.$newline;
-                $html .= '            <div itemprop="url">https://www.ldproxy.nrw.de/'.$_SERVER['REQUEST_URI'].'</div>'.$newline;//TODO canonical url
+                $html .= '            <div itemprop="url">https://www.ldproxy.nrw.de/'.get2Rest($_SERVER['REQUEST_URI']).'</div>'.$newline;//TODO canonical url
             	$html .= '        </div>'.$newline;
 //ul 0 for keywords ...
 //ul 1..n for distribution - each a download url to a wfs featuretype in different formats!
@@ -1568,7 +1775,7 @@
 			    foreach($returnObject->features as $feature) {
 				$html .= '                <li>'.$newline;
 				$html .= '                    <div  itemscope itemtype="http://schema.org/Place">'.$newline;
-				$html .= '                        <h4 class="mt-3 mb-1"><a href="'.delTotalFromQuery(array('items','offset','limit','bbox'),$_SERVER['REQUEST_URI']).'&item='.$feature->id.'" target="_blank"><span itemprop="name">'.$feature->id.'</span></a></h4><a href=""  onclick="zoomToExtent('.$geojsonBbox[$objIndex]->minx.",".$geojsonBbox[$objIndex]->miny.",".$geojsonBbox[$objIndex]->maxx.",".$geojsonBbox[$objIndex]->maxy.');return false;">'._mb('zoom to').'</a>'.$newline;
+				$html .= '                        <h4 class="mt-3 mb-1"><a href="'.get2Rest(delTotalFromQuery(array('items','offset','limit','bbox'),$_SERVER['REQUEST_URI']).'&item='.$feature->id).'" target="_blank"><span itemprop="name">'.$feature->id.'</span></a></h4><a href=""  onclick="zoomToExtent('.$geojsonBbox[$objIndex]->minx.",".$geojsonBbox[$objIndex]->miny.",".$geojsonBbox[$objIndex]->maxx.",".$geojsonBbox[$objIndex]->maxy.');return false;">'._mb('zoom to').'</a>'.$newline;
 				$html .= '                        <span class="d-none" itemprop="sameAs">https://www.ldproxy.nrw.de/topographie/collections/ax_bergbaubetrieb/items/DENWAT01D000CcF0</span>'.$newline;
 				//foreach attribute
 				foreach($feature->properties as $key=>$value) {



More information about the Mapbender_commits mailing list