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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jun 19 02:16:41 PDT 2019


Author: armin11
Date: 2019-06-19 02:16:41 -0700 (Wed, 19 Jun 2019)
New Revision: 10154

Modified:
   trunk/mapbender/conf/isoMetadata.conf
   trunk/mapbender/http/classes/class_cswClient.php
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/classes/class_qualityReport.php
   trunk/mapbender/http/php/mod_exportIso19139.php
   trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php
   trunk/mapbender/http/php/mod_layerISOMetadata.php
Log:
Possibility to allow resolving of data/service couplings when requesting metadata via csw calls

Modified: trunk/mapbender/conf/isoMetadata.conf
===================================================================
--- trunk/mapbender/conf/isoMetadata.conf	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/conf/isoMetadata.conf	2019-06-19 09:16:41 UTC (rev 10154)
@@ -13,7 +13,7 @@
 	category => "identification",
 	description => _mb("A value uniquely identifying the metadata (description) of the resource."),
 	//rdf-a
-	schemaorg_typeof => null, //use pathes for hierachy - example
+	schemaorg_typeof => null, //use pathes for hierarchy - example
 	schemaorg_property => 'identifier', //TODO - use other identifier for this!!!  - dataset identifier (unique resource identifier) - but not available for services!!!!!
 	rdfa_content => null //fir fix content/value,
 ),
@@ -29,7 +29,7 @@
 	category => "identification",
 	description => _mb("This a characteristic, and often unique, name by which the resource is known. The value domain of this metadata element is free text."),
 	//rdf-a
-	schemaorg_typeof => null, //use pathes for hierachy - example
+	schemaorg_typeof => null, //use pathes for hierarchy - example
 	schemaorg_property => 'name',
 	rdfa_content => null //fir fix content/value
 ),
@@ -45,7 +45,7 @@
 	category => "identification",
 	description => _mb("This is a brief narrative summary of the content of the resource."),
 	#rdf-a
-	schemaorg_typeof => null, //use pathes for hierachy - example
+	schemaorg_typeof => null, //use pathes for hierarchy - example
 	schemaorg_property => 'description',
 	rdfa_content => null //fir fix content/value
 ),
@@ -73,7 +73,7 @@
 	category => "identification",
 	description => _mb("The resource locator defines the link(s) to the resource and/or the link to additional information about the resource. The value domain of this metadata element is a character string, commonly expressed as uniform resource locator (URL)."),
 	//rdf-a
-	schemaorg_typeof => null, //use pathes for hierachy - example
+	schemaorg_typeof => null, //use pathes for hierarchy - example
 	schemaorg_property => 'url',
 	rdfa_content => null //fir fix content/value
 ),
@@ -165,7 +165,7 @@
 	category => "keyword",
 	description => _mb("If the resource is a spatial data service, at least one keyword from Part D.4 shall be provided. If a resource is a spatial data set or spatial data set series, at least one keyword shall be provided from the general environmental multilingual thesaurus (GEMET) describing the relevant spatial data theme as defined in Annex I, II or III to Directive 2007/2/EC."),
 	//rdf-a
-	schemaorg_typeof => null, //use pathes for hierachy - example
+	schemaorg_typeof => null, //use pathes for hierarchy - example
 	schemaorg_property => 'keywords', //TODO - use other identifier for this!!!  - dataset identifier (unique resource identifier)!!!!
 	rdfa_content => null //fir fix content/value
 ),

Modified: trunk/mapbender/http/classes/class_cswClient.php
===================================================================
--- trunk/mapbender/http/classes/class_cswClient.php	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/http/classes/class_cswClient.php	2019-06-19 09:16:41 UTC (rev 10154)
@@ -42,10 +42,15 @@
 		$this->operationSuccessful = false;
 	}
 	
-	public function doRequest($cswId, $operationName, $recordId=false, $record=false, $recordtype=false, $maxrecords=false, $startposition=false, $additionalFilter=false) {
-		$this->cswId = $cswId;
-		$csw = new csw();
-		$csw->createCatObjFromDB($this->cswId);
+	public function doRequest($cswId, $operationName, $recordId=false, $record=false, $recordtype=false, $maxrecords=false, $startposition=false, $additionalFilter=false, $datasetId=false, $cswObject=false) {
+		if ($cswId != false) {
+			$this->cswId = $cswId;
+			$csw = new csw();
+			$csw->createCatObjFromDB($this->cswId);
+		} else {
+			$csw = $cswObject;
+		}
+//$e = new mb_exception("csw_client: cat_op_values: ".$csw->cat_op_values['getrecords']['post']['dflt']);
 		$operationNameCsw = $operationName;
 		//$e = new mb_exception($csw->cat_op_values[$operationName]['post']);
 		//check for operation support
@@ -91,6 +96,14 @@
 					return false;
 				}
 				break;
+			case "getrecordsresolvecoupling":
+				if (isset($csw->cat_op_values['getrecords']['post'])) {
+					//all ok
+				} else {
+					$e = new mb_exception("classes/class_cswClient.php: Needed operation not supported by catalogue!");
+					return false;
+				}
+				break;
 			case "getrecordspaging":				
 				if (isset($csw->cat_op_values['getrecords']['post'])) {
 					//all ok
@@ -118,6 +131,52 @@
 			case "getrecords":
 				
 				break;
+			case "getrecordsresolvecoupling":
+				$postRequest = '<?xml version="1.0" encoding="UTF-8"?>';
+				//TODO check the following: - resultType="hits" seems to be default behaviour
+				$postRequest .= '<csw:GetRecords service="CSW" version="2.0.2" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0" ';	
+				$postRequest .= 'outputSchema="http://www.isotc211.org/2005/gmd" ';				
+				$postRequest .= 'resultType="results">';
+    				$postRequest .= '<csw:Query typeNames="csw:Record">';
+				$postRequest .= '<csw:ElementSetName>full</csw:ElementSetName>'; //full to get all queryables?
+				if ($recordtype !== false) {
+            				$postRequest .= '<csw:Constraint version="1.0.0">';
+                			$postRequest .= '<ogc:Filter>';
+					if ($additionalFilter !== false) {
+						$postRequest .= '<ogc:And>';
+					}
+					$postRequest .= '<ogc:Or>';
+                    			$postRequest .= '<ogc:PropertyIsEqualTo>';
+                       			$postRequest .= '<ogc:PropertyName>OperatesOn</ogc:PropertyName>';
+                        		$postRequest .= '<ogc:Literal>'.$datasetId.'</ogc:Literal>';
+                    			$postRequest .= '</ogc:PropertyIsEqualTo>';
+                    			$postRequest .= '<ogc:PropertyIsEqualTo>';
+                       			$postRequest .= '<ogc:PropertyName>OperatesOn</ogc:PropertyName>';
+                        		$postRequest .= '<ogc:Literal>'.$recordId.'</ogc:Literal>';
+                    			$postRequest .= '</ogc:PropertyIsEqualTo>';
+					$postRequest .= '</ogc:Or>';
+					if ($additionalFilter !== false) {
+						$postRequest .= $additionalFilter;
+					}
+					if ($additionalFilter !== false) {
+						$postRequest .= '</ogc:And>';
+					}
+                			$postRequest .= '</ogc:Filter>';
+            				$postRequest .= '</csw:Constraint>';
+				} else {
+					if ($additionalFilter !== false) {
+						$postRequest .= '<csw:Constraint version="1.0.0">';
+                				$postRequest .= '<ogc:Filter>';
+						$postRequest .= $additionalFilter;
+						$postRequest .= '</ogc:Filter>';
+            					$postRequest .= '</csw:Constraint>';
+					}
+				}
+        			$postRequest .= '</csw:Query>';
+    				$postRequest .= '</csw:GetRecords>';
+				//alter operationName
+				$operationNameCsw = 'getrecords';
+				break;
 			case "transactionupdate":
 				$postRequest = '<?xml version="1.0" encoding="UTF-8"?>';
 				$postRequest .= '<csw:Transaction service="CSW" version="2.0.2" xmlns:csw="http://www.opengis.net/cat/csw/2.0.2" xmlns:ogc="http://www.opengis.net/ogc" xmlns:apiso="http://www.opengis.net/cat/csw/apiso/1.0">';
@@ -269,9 +328,17 @@
 		//$e = new mb_exception($csw->cat_op_values[$operationName]['post']);
 		if (strpos($operationNameCsw, "transaction") === false) {
 			//$e = new mb_exception("test: ".$csw->cat_op_values[$operationNameCsw]['post']);
-			$this->operationResult = $this->getResult($csw->cat_op_values[$operationNameCsw]['post'], $postRequest);
+			if ($cswId != false) {
+				$this->operationResult = $this->getResult($csw->cat_op_values[$operationNameCsw]['post'], $postRequest);
+			} else {
+				$this->operationResult = $this->getResult($csw->cat_op_values[$operationNameCsw]['post']['dflt'], $postRequest);
+			}
 			//Also give back url of operation
-			$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['post'];
+			if ($cswId != false) {
+				$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['post'];
+			} else {
+				$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['post']['dflt'];
+			}
 		} else {
 			$this->operationResult = $this->getResult($csw->cat_op_values["transaction"]['post'], $postRequest);
 			//$this->operationUrl = $csw->cat_op_values[$operationNameCsw]['post'];
@@ -301,6 +368,7 @@
 			return false;
 		}
 		if ($cswResponseObject !== false) {
+//$e = new mb_exception("classes/class_cswClient.php: parsing results was successfull!");
 			$cswResponseObject->registerXPathNamespace("ows", "http://www.opengis.net/ows");
 			$cswResponseObject->registerXPathNamespace("gml", "http://www.opengis.net/gml");
 			$cswResponseObject->registerXPathNamespace("gmd", "http://www.isotc211.org/2005/gmd");
@@ -338,7 +406,7 @@
 						break;
 					case "getrecords":
 						$metadataRecord = $cswResponseObject->xpath('/csw:GetRecordsResponse/csw:SearchResults at numberOfRecordsMatched');
-						$e = new mb_exception(json_encode($metadataRecord));
+						//$e = new mb_exception(json_encode($metadataRecord));
 						if (is_array($metadataRecord) && count($metadataRecord) <> 1 || !is_array($metadataRecord)) {
 							$this->operationResult = "No result for counting metadata records via csw query!";
 							return false;
@@ -350,7 +418,6 @@
 						break;
 					case "counthits":
 						//$e = new mb_exception('count hits');
-						
 						$metadataRecord = $cswResponseObject->xpath('/csw:GetRecordsResponse/csw:SearchResults/@numberOfRecordsMatched');
 						//$e = new mb_exception(json_encode($metadataRecord));
 						if (is_array($metadataRecord) && count($metadataRecord) <> 1 || !is_array($metadataRecord)) {
@@ -361,6 +428,23 @@
 							$this->operationResult = $metadataRecord[0];
 							return true;
 						}
+					case "getrecordsresolvecoupling":
+//$e = new mb_exception("classes/class_cswClient.php: operation was getrecordsresolvecoupling");
+						$metadataRecord = $cswResponseObject->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata');
+						//$e = new mb_exception(json_encode($metadataRecord));
+//$e = new mb_exception("classes/class_cswClient.php: type of metadataRecord: ".gettype($metadataRecord));
+						if (is_array($metadataRecord) && count($metadataRecord) < 1 || !is_array($metadataRecord)) {
+//$e = new mb_exception("classes/class_cswClient.php: no array found!");
+							$this->operationResult = "No result for getrecordsresolvecoupling for metadata records via csw query!";
+							$this->operationSuccessful = false;
+							return false;
+						} else {
+//$e = new mb_exception("classes/class_cswClient.php: metadata array found!");
+							$this->operationSuccessful = true;
+							$this->operationResult = $cswResponseObject;
+							return true;
+						}
+						break;
 					case "getrecordspaging":
 						$metadataRecord = $cswResponseObject->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata');
 						if (is_array($metadataRecord) && count($metadataRecord) < 1 || !is_array($metadataRecord)) {
@@ -402,7 +486,6 @@
 			$postData = stripslashes($postData);
 			$dataXMLObject = new SimpleXMLElement($postData);
 			$postData = $dataXMLObject->asXML();
-
 			//$e = new mb_exception($postData);
 			$cswInterfaceObject->set('curlSendCustomHeaders',true);
 			$cswInterfaceObject->set('httpPostData', $postData);
@@ -409,6 +492,7 @@
 			$cswInterfaceObject->set('httpContentType','text/xml');
 			$cswInterfaceObject->load($url);
 			//$file = $cswInterfaceObject->file;
+//$e = new mb_exception($cswInterfaceObject->file);
 			return $cswInterfaceObject->file;
 	}
 	//insert or update - depends if record with same fileidentifier already exists in catalog and if timestamp is not newer than the timestamp of the new record

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/http/classes/class_iso19139.php	2019-06-19 09:16:41 UTC (rev 10154)
@@ -43,7 +43,7 @@
 	var $customCategories = array();
 	var $downloadLinks = array();  //store in db as json object!!!!
 	var $transferSize;
-	var $hierachyLevel;
+	var $hierarchyLevel;
 	var $tmpExtentBegin;
 	var $tmpExtentEnd;
 	var $refSystem;
@@ -107,7 +107,7 @@
 		$this->customCategories = array();
 		$this->downloadLinks = array();
 		//
-		$this->hierachyLevel = "dataset";
+		$this->hierarchyLevel = "dataset";
 		$this->tmpExtentBegin = "1900-01-01";
 		$this->tmpExtentEnd = "1900-01-01";
 		$this->randomId = new Uuid();
@@ -181,7 +181,7 @@
     }
 
 	public function getRelevantInspireRegulations($withAmendmentAndCorrigendum = true) {
-		//use $this->hierachyLevel and give back all relevant regulations (only the newest of each type) with their dates in the requested language
+		//use $this->hierarchyLevel and give back all relevant regulations (only the newest of each type) with their dates in the requested language
 		$language = $this->inspireLegislation->default_language;
 		$countInspireRegulations = 0;
 		$regulations = array();
@@ -195,7 +195,7 @@
 		foreach ($this->inspireLegislation as $inspire_rules) {
 			foreach ($inspire_rules as $regulation) { 
 				if (in_array($regulation->type, $legislationTypeArray) && in_array($regulation->group, array("data_specifications","metadata","network_services"))) {
-					if (in_array($this->hierachyLevel, $regulation->subject)) {
+					if (in_array($this->hierarchyLevel, $regulation->subject)) {
 						//check if already a regulation with this name exists in the array - if it is already there, check if the date is newer or older!
 						$keyInArray = array_search($regulation->label->{$language}, $this->array_column($regulations, 'name'));//TODO []
 						if ($keyInArray !== false) {
@@ -294,9 +294,9 @@
 			$this->createDate = $this->createDate[0];
 			$this->changeDate = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:dateStamp/gco:Date');
 			$this->changeDate = $this->changeDate[0];
-			$this->hierachyLevel = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode');
-			$this->hierachyLevel = $this->hierachyLevel[0];
-			if ($this->hierachyLevel == 'service') {				
+			$this->hierarchyLevel = $iso19139Xml->xpath('//gmd:MD_Metadata/gmd:hierarchyLevel/gmd:MD_ScopeCode/@codeListValue');
+			$this->hierarchyLevel = $this->hierarchyLevel[0];
+			if ($this->hierarchyLevel == 'service') {				
 				$identifikationXPath = "srv:SV_ServiceIdentification";	
 			} else {
 				$identifikationXPath = "gmd:MD_DataIdentification";
@@ -741,7 +741,11 @@
    		return $proc->transformToXML($xmlDoc);	
 	}
 
-	public function transformToHtml($layout,$languageCode){
+	public function transformToHtml3($layout,$languageCode){
+		
+	}
+
+	public function transformToHtml($layout, $languageCode, $serviceInformation=false){
 		libxml_use_internal_errors(true);
 		//TODO don't parse it again, but change the internal parser function!
 		try {
@@ -1180,6 +1184,16 @@
 			//push xml instead of html? But there is no real url
 			$html .= $tableEnd;
 			$html .= '</fieldset>';
+			if (count($serviceInformation->service) > 0) {
+				//new for coupled services if they exists:
+				$html .= '<fieldset><legend>'._mb("Available Services").'</legend>';
+				$html .= $tableBegin;
+				foreach ($serviceInformation->service as $service) {
+					$html .= $t_a."<b>".$service->serviceType."</b>: ".$t_b."<a href='".$_SERVER['PHP_SELF']."?url=".urlencode($service->metadataUrl)."' target='_blank'>".$service->serviceTitle."</a>".$t_c;
+				}
+				$html .= $tableEnd;
+				$html .= '</fieldset>';
+			}
 			//$html .= '</p>';
 			$html .= '</div>';//foreach upper category element
 			//***************************************************************************
@@ -1391,7 +1405,7 @@
 			$this->customCategories = array();
 			//*/
 
-			$this->hierachyLevel = $row['type'];
+			$this->hierarchyLevel = $row['type'];
 			$this->tmpExtentBegin = $row['tmp_reference_1'];//"1900-01-01";
 			$this->tmpExtentEnd = $row['tmp_reference_2'];//"1900-01-01";
 			$this->randomId =  $row['randomid'];
@@ -2230,7 +2244,7 @@
 			$this->changeDate,
 			$this->abstract,
 			$this->keywords[0],
-			$this->hierachyLevel,
+			$this->hierarchyLevel,
 			$this->tmpExtentBegin,
 			$this->tmpExtentEnd,
 			$this->export2Csw,
@@ -2345,7 +2359,7 @@
 			$this->changeDate,
 			$this->abstract,
 			$this->keywords[0],
-			$this->hierachyLevel,
+			$this->hierarchyLevel,
 			$this->tmpExtentBegin,
 			$this->tmpExtentEnd,
 			$this->export2Csw,
@@ -2405,7 +2419,7 @@
 			$this->changeDate,
 			$this->abstract,
 			$this->keywords[0],
-			$this->hierachyLevel,
+			$this->hierarchyLevel,
 			$this->tmpExtentBegin,
 			$this->tmpExtentEnd,
 			$this->export2Csw,

Modified: trunk/mapbender/http/classes/class_qualityReport.php
===================================================================
--- trunk/mapbender/http/classes/class_qualityReport.php	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/http/classes/class_qualityReport.php	2019-06-19 09:16:41 UTC (rev 10154)
@@ -13,7 +13,7 @@
 
 	public function getIso19139Representation($metadataType, $inspireInteroperability, $legislation_group = false) {
 		$iso19139 = new iso19139();
-		$iso19139->hierachyLevel = $metadataType;
+		$iso19139->hierarchyLevel = $metadataType;
 		$regulations = $iso19139->inspireRegulations;
 		//load xml snippet from filesystem as template
 		$reportDomObject = new DOMDocument();

Modified: trunk/mapbender/http/php/mod_exportIso19139.php
===================================================================
--- trunk/mapbender/http/php/mod_exportIso19139.php	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/http/php/mod_exportIso19139.php	2019-06-19 09:16:41 UTC (rev 10154)
@@ -7,13 +7,56 @@
 # http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
 require_once dirname(__FILE__) . "/../../core/globalSettings.php";
 require_once dirname(__FILE__) . "/../classes/class_iso19139.php";
+require_once(dirname(__FILE__) . "/../classes/class_cswClient.php");
+require_once(dirname(__FILE__) . "/../classes/class_csw.php");
 //show html from a given url
+//default languageCode to de
+$languageCode = "de";
 $url = urldecode($_REQUEST['url']);
 $outputFormat = 'html';
+$resolveCoupledResources = false;
+//get language parameter out of mapbender session if it is set else set default language to de_DE
+$sessionLang = Mapbender::session()->get("mb_lang");
+if (isset($sessionLang) && ($sessionLang!='')) {
+	$e = new mb_notice("mod_showMetadata.php: language found in session: ".$sessionLang);
+	$language = $sessionLang;
+	$langCode = explode("_", $language);
+	$langCode = $langCode[0]; # Hopefully de or s.th. else
+	$languageCode = $langCode; #overwrite the GET Parameter with the SESSION information
+}
+if (isset($_REQUEST["languageCode"]) & $_REQUEST["languageCode"] != "") {
+	//validate to csv integer list
+	$testMatch = $_REQUEST["languageCode"];
+	if (!($testMatch == 'de' or $testMatch == 'fr' or $testMatch == 'en')){ 
+		//echo 'languageCode: <b>'.$testMatch.'</b> is not valid.<br/>'; 
+		echo 'Parameter <b>languageCode</b> is not valid (de,fr,en).<br/>'; 
+		die(); 		
+ 	}
+	$languageCode = $testMatch;
+	$testMatch = NULL;
+}
+if (isset($_REQUEST["resolveCoupledResources"]) & $_REQUEST["resolveCoupledResources"] != "") {
+	$testMatch = $_REQUEST["resolveCoupledResources"];	
+ 	if (!($testMatch == 'true' or $testMatch == 'false')){ 
+		echo 'Parameter <b>resolveCoupledResources</b> is not valid (true,false (default to false)).<br/>'; 
+		die(); 		
+ 	}
+	switch ($testMatch) {
+		case "true":
+			$resolveCoupledResources = true;
+		break;
+		case "false":
+			$resolveCoupledResources = false;
+		break;	
+	}
+	$testMatch = NULL;
+}
+//write languageCode into session!
+$localeObj->setCurrentLocale($languageCode);
 if (isset($_REQUEST["outputFormat"]) & $_REQUEST["outputFormat"] != "") {
 	//validate to de, en, fr
 	$testMatch = $_REQUEST["outputFormat"];	
- 	if (!($testMatch == 'html' or $testMatch == 'rdf' or $testMatch == 'iso19139')){ 
+ 	if (!($testMatch == 'html' or $testMatch == 'rdf' or $testMatch == 'iso19139'  or $testMatch == 'html2'  or $testMatch == 'html3')){ 
 		//echo 'languageCode: <b>'.$testMatch.'</b> is not valid.<br/>'; 
 		echo 'Parameter <b>outputFormat</b> is not valid (html,rdf,iso19139).<br/>'; 
 		die(); 		
@@ -21,13 +64,121 @@
 	$outputFormat = $testMatch;
 	$testMatch = NULL;
 }
+//initialize if resource is based on a request to csw interface
+$cswBasedResource = false;
+//instantiate
 $mbMetadata = new Iso19139();
-$mbMetadata->readFromUrl($url);
+//test if getrecordbyid request was used - then the service data may also be in the same catalogue
+if (strpos(strtoupper($url), "GETRECORDBYID",strtoupper($url)) !== false && strpos(strtoupper($url), "SERVICE=CSW") !== false && strpos(strtoupper($url), "VERSION=2.0.2") !== false) {
+	$cswBasedResource = true;
+}
+//build search request for services
+//TODO: test if this ok - maybe not everything is parsed by class? instead we could use $mbMetadata->readFromUrl($url);
+$mbMetadata->createFromUrl($url);
+//$e = new mb_exception("datasetId: ".$mbMetadata->datasetId);
+//$e = new mb_exception("datasetIdCodeSpace: ".$mbMetadata->datasetIdCodeSpace);
+//$e = new mb_exception("hierarchyLevel: ".$mbMetadata->hierarchyLevel);
+$serviceMetadata = new stdClass();
+$serviceMetadataIndex = 0;
+if ($mbMetadata->hierarchyLevel == 'dataset' || $mbMetadata->hierarchyLevel == 'series') {
+	//get datasetidentifier to resolve coupled resources
+	//$e = new mb_exception("datasetId: ".$mbMetadata->datasetId);
+	//$e = new mb_exception("datasetIdCodeSpace: ".$mbMetadata->datasetIdCodeSpace);
+	if ($resolveCoupledResources == true && $cswBasedResource == true) {
+		//$e = new mb_exception("try to resolve coupled resources");
+		//createCatObjFromXML($url);
+		$csw = new csw();
+		//$e = new mb_exception("parse csw capabilities!");
+		//parse url
+		$urlArray = parse_url($url);
+		$urlWithoutRequest = $urlArray['scheme']."://".$urlArray['host'].":".$urlArray['port']."/".$urlArray['path'];
+		$csw->createCatObjFromXML($urlWithoutRequest."?SERVICE=CSW&VERSION=2.0.2&REQUEST=GetCapabilities");
+		$cswClient = new cswClient();
+		$operation = "getrecordsresolvecoupling";
+		$getrecordId = $mbMetadata->fileIdentifier;
+		$datasetId = $mbMetadata->datasetId;
+		$recordType = 'service';
+		$cswResponseObject = $cswClient->doRequest(false, $operation, $getrecordId, false, $recordType, false, false, false, $datasetId, $csw);
+		//$e = new mb_exception("test1");	
+		//$e = new mb_exception($cswClient->operationSuccessful);
+		//$e = new mb_exception("test2");	
+		$serviceMetadataUrls = array();
+		if ($cswClient->operationSuccessful == true) {
+			//$e = new mb_exception("operation successfull");	
+			//$e = new mb_exception(gettype($cswClient->operationResult));
+			$metadataRecord = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata');
+			//$e = new mb_exception("number of records: ".count($metadataRecord));
+			//what is possible: keywords, categories?, spatial, ...
+			for ($k = 1; $k <= count($metadataRecord) ; $k++) {
+				$fileIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:fileIdentifier/gco:CharacterString');
+				$fileIdentifier = (string)$fileIdentifier[0];
+				//service date
+				$mdDateStamp = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:date/gmd:CI_Date/gmd:date/gco:Date');
+				$mdDateStamp = (string)$mdDateStamp[0];
+				//service title
+				$mdTitle = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/srv:SV_ServiceIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+				$mdTitle = (string)$mdTitle[0];
+				//service type
+				$mdServiceType = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/srv:SV_ServiceIdentification/srv:serviceType/gco:LocalName');
+				$mdServiceType = (string)$mdServiceType[0];
+				//accessUrl
+				$mdAccessUrl = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL');
+				$mdAccessUrl = (string)$mdAccessUrl[0];
+
+				//get service type - view / download
+
+				//get service title
+
+				/*$datasetIdentifier = $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:identificationInfo/gmd:MD_DataIdentification/@uuid');
+				$datasetidentifier = (string)$datasetidentifier[0];
+				$url =  $cswClient->operationResult->xpath('/csw:GetRecordsResponse/csw:SearchResults/gmd:MD_Metadata['.$k.']/gmd:distributionInfo/gmd:MD_Distribution/gmd:transferOptions/gmd:MD_DigitalTransferOptions/gmd:onLine/gmd:CI_OnlineResource/gmd:linkage/gmd:URL');
+				$url = (string)$url[0];
+				if (isset($url) && $url !=="") {
+					//$metadataArray[$numberOfMetadataRecords]['uuid'] = $datasetIdentifier;
+					$metadataArray[$numberOfMetadataRecords]['uuid'] = $fileIdentifier;
+					$metadataArray[$numberOfMetadataRecords]['changedate'] = $mdDateStamp;
+					$numberOfMetadataRecords++;
+				}*/
+				//$e = new mb_exception("found service with fileIdentifier: ".$fileIdentifier." - date - ".$mdDateStamp);
+				$serviceMetadata->service[$k]->serviceType = $mdServiceType;
+				$serviceMetadata->service[$k]->serviceTitle = $mdTitle;
+				$serviceMetadata->service[$k]->serviceDate = $mdDateStamp;
+				$serviceMetadata->service[$k]->metadataUrl = $urlWithoutRequest."?SERVICE=CSW&VERSION=2.0.2&REQUEST=GetRecordById&outputSchema=".urlencode('http://www.isotc211.org/2005/gmd')."&id=".$fileIdentifier;
+				$serviceMetadata->service[$k]->accessUrl = $mdAccessUrl;
+
+				
+			}
+		}
+		/*if ($cswClient->operationSuccessful == true) {
+			if ($cswResponseObject !== false) {
+				$e = new mb_exception("php/mod_exportIso19139.php: returned service records: ".$cswClient->operationResult->asXML());
+				
+			}
+		}*/
+	}
+}
+//resolve operates on
+//new - test createFromUrl instead and build the presentations from object! There for a new json configuration is needed!
+//html2 / html3 - conf from json!
 switch ($outputFormat) {
+	case "html3":
+		$html = $mbMetadata->transformToHtml3('tabs',$languageCode);
+		header("Content-type: text/html; charset=UTF-8");
+		echo $html;
+	break;
+	case "html2":
+		$html = $mbMetadata->transformToHtml2('tabs',$languageCode);
+		header("Content-type: text/html; charset=UTF-8");
+		echo $html;
+	break;
 	case "html":
-		$html = $mbMetadata->transformToHtml('tabs','de');
+		$html = $mbMetadata->transformToHtml('tabs', $languageCode, $serviceMetadata);
 		header("Content-type: text/html; charset=UTF-8");
 		echo $html;
+		/*foreach ($serviceMetadata as $serviceMetadatas) {
+			echo "<br>".json_encode($serviceMetadata)."<br>";
+			
+		}*/
 	break;
 	case "rdf":
 		$rdf =  $mbMetadata->transformToRdf();

Modified: trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/http/php/mod_inspireAtomFeedISOMetadata.php	2019-06-19 09:16:41 UTC (rev 10154)
@@ -616,7 +616,7 @@
 	$hierarchyLevel->appendChild($scopecode);
 	$hierarchyLevel=$MD_Metadata->appendChild($hierarchyLevel);
 
-	//iso19139 demands a hierachyLevelName object
+	//iso19139 demands a hierarchyLevelName object
 	$hierarchyLevelName = $iso19139->createElement("gmd:hierarchyLevelName");
 	$hierarchyLevelNameString = $iso19139->createElement("gco:CharacterString");
 	$hierarchyLevelNameText = $iso19139->createTextNode('Downloaddienst');

Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php	2019-06-18 09:07:04 UTC (rev 10153)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php	2019-06-19 09:16:41 UTC (rev 10154)
@@ -217,7 +217,7 @@
 	$hierarchyLevel->appendChild($scopecode);
 	$hierarchyLevel=$MD_Metadata->appendChild($hierarchyLevel);
 
-	//iso19139 demands a hierachyLevelName object
+	//iso19139 demands a hierarchyLevelName object
 	$hierarchyLevelName = $iso19139->createElement("gmd:hierarchyLevelName");
 	$hierarchyLevelNameString = $iso19139->createElement("gco:CharacterString");
 	$hierarchyLevelNameText = $iso19139->createTextNode('Darstellungsdienst');



More information about the Mapbender_commits mailing list