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

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Wed Jan 17 06:45:06 PST 2018


Author: armin11
Date: 2018-01-17 06:45:06 -0800 (Wed, 17 Jan 2018)
New Revision: 9847

Modified:
   trunk/mapbender/http/classes/class_iso19139.php
   trunk/mapbender/http/php/mod_dataISOMetadata.php
   trunk/mapbender/http/php/mod_showMetadata.php
Log:
Bugfix for dataset metadata editor

Modified: trunk/mapbender/http/classes/class_iso19139.php
===================================================================
--- trunk/mapbender/http/classes/class_iso19139.php	2018-01-16 19:55:45 UTC (rev 9846)
+++ trunk/mapbender/http/classes/class_iso19139.php	2018-01-17 14:45:06 UTC (rev 9847)
@@ -1781,7 +1781,7 @@
 		//map category name to id before insert them into db!
 		//read maptable from db
 		//iso - code in xml
-		if ($resourceType == "wms" || $resourceType == "wfs" || $resourceType == "inspire_dls_atom" || $resourceType == "inspire_dls_atom_dataset" || $resourceType == "metadata") {
+		if ($resourceType == "wms" || $resourceType == "wfs" || $resourceType == "inspire_dls_atom" || $resourceType == "inspire_dls_atom_dataset") {
 			return false;
 		}
 		switch ($resourceType) {
@@ -1860,7 +1860,9 @@
 				$e = new mb_exception("class_Iso19139:"._mb("Cannot insert custom categories for this metadata!"));
 			}
 		}
-		$this->bequeathCategoriesToCoupledResource($metadataId,$resourceType,$resourceId);	
+		if ($resourceType == 'layer' || $resourceType == 'featuretype') {
+			$this->bequeathCategoriesToCoupledResource($metadataId,$resourceType,$resourceId);	
+		}
 		$sqlInsert = "";
 		//insert keywords into keyword table
 		//foreach keyword look for an id or create it newly - made for postgres > 8.2 with returning option for insert statement

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2018-01-16 19:55:45 UTC (rev 9846)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2018-01-17 14:45:06 UTC (rev 9847)
@@ -99,7 +99,7 @@
 	//get record from mb_metadata and prohibit duplicates:
 	$sql = <<<SQL
 
-SELECT * FROM mb_metadata WHERE uuid = $1 ORDER BY lastchanged DESC LIMIT 1
+SELECT *, st_xmin(the_geom) || ',' || st_ymin(the_geom) || ',' || st_xmax(the_geom) || ',' || st_ymax(the_geom)  as bbox2d FROM mb_metadata WHERE uuid = $1 ORDER BY lastchanged DESC LIMIT 1
 
 SQL;
 	$v = array($uuid);
@@ -342,109 +342,18 @@
 			header("Content-type: text/xml; charset=UTF-8");
 			echo $iso19139str;
 		break;
-	}
-	
+	}	
 }
 
 //some needfull functions to pull metadata out of the database!
 function fillISO19139($iso19139, $recordId) {
 	global $admin;
 	global $mb_metadata;
-	$noLayer = false;
-	$noFeaturetype = false;
-	//read out relevant information from mapbender database:
-
-	//layer and wms information:
-	$sql = <<<SQL
-SELECT layer_id, fkey_wms_id FROM layer INNER JOIN ows_relation_metadata ON 
-(ows_relation_metadata.fkey_layer_id=layer.layer_id)  WHERE ows_relation_metadata.fkey_metadata_id = $1 LIMIT 1
-SQL;
-	//TODO: Problem - the metadata may be used for more than one service - not often but sometimes - does one get the right contact data?
-	//TODO: Problem - this is also the fact if the data is provided by a wfs featuretype! There maybe other contact infos - maybe the info should be integrated more than once and identical info should be identified
-	$e = new mb_notice("used metadata id: ".$mb_metadata['metadata_id']);
-	$v = array($mb_metadata['metadata_id']);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	if (!$res) {
-		$noLayer = true;
-	} else {
-		$mb_metadata_coupling = db_fetch_array($res);
-	}
-	$layerId = $mb_metadata_coupling['layer_id'];
-	$wmsId = $mb_metadata_coupling['fkey_wms_id'];
-	$e = new mb_notice("mod_dataISOMetadata.php: Found coupled layer with id: ".$layerId);
-
-	//featuretype and wfs information:
-	$sql = <<<SQL
-SELECT featuretype_id, fkey_wfs_id FROM wfs_featuretype INNER JOIN ows_relation_metadata ON 
-(ows_relation_metadata.fkey_featuretype_id=wfs_featuretype.featuretype_id) WHERE ows_relation_metadata.fkey_metadata_id = $1 LIMIT 1
-SQL;
-	//TODO: Problem - the metadata may be used for more than one service - not often but sometimes - does one get the right contact data?
-	//TODO: Problem - this is also the fact if the data is provided by a wfs featuretype! There maybe other contact infos - maybe the info should be integrated more than once and identical info should be identified
-	//$e = new mb_exception("used metadata id: ".$mb_metadata['metadata_id']);
-	$v = array($mb_metadata['metadata_id']);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	if (!$res) {
-		$noFeaturetype = true;
-	} else {
-		$mb_metadata_coupling = db_fetch_array($res);
-	}
-	$featuretypeId = $mb_metadata_coupling['featuretype_id'];
-	$wfsId = $mb_metadata_coupling['fkey_wfs_id'];
-	$e = new mb_notice("mod_dataISOMetadata.php: Found coupled featuretype with id: ".$featuretypeId);
-	//if no coupled resource was found - the metadata cannot be created
-	/*if ($noFeaturetype == true && $noFeaturetype == true) {
-		$exception = "<exception>No coupled service ressource found - metadata cannot be created</exception>";
-		return $exception;
-	}*/
-	
-	/*if (!isset($featuretypeId)) {
-		echo "<exception>no featuretype coupled</exception>";
-		die();
-	}*/
-
-		if ($wmsView != '') {
-			$sql = "SELECT * ";
-			$sql .= "FROM ".$wmsView." WHERE layer_id = $1";
-		}
-		else {
-		//next function is for normal mapbender installations and read the info directly from the wms and layer tables
-			$sql = "SELECT ";
-			$sql .= "layer.layer_id,layer.layer_name, layer.layer_title, layer.layer_abstract, layer.layer_pos, layer.layer_parent, layer.layer_minscale, layer.layer_maxscale, layer.uuid,";
-			$sql .= "wms.wms_title, wms.wms_abstract, wms.wms_id, wms.fees, wms.accessconstraints, wms.contactperson, ";
-			$sql .= "wms.contactposition, wms.contactorganization, wms.address, wms.city, wms_timestamp, wms_owner, ";
-			$sql .= "wms.stateorprovince, wms.postcode, wms.contactvoicetelephone, wms.contactfacsimiletelephone, wms.wms_owsproxy,";
-			$sql .= "wms.contactelectronicmailaddress, wms.country, wms.fkey_mb_group_id, wms.wms_license_source_note,";
-			$sql .= "layer_epsg.minx || ',' || layer_epsg.miny || ',' || layer_epsg.maxx || ',' || layer_epsg.maxy  as bbox ";
-			$sql .= "FROM wms, layer, layer_epsg WHERE layer_id = $1 and layer.fkey_wms_id = wms.wms_id";
-			$sql .= " and layer_epsg.fkey_layer_id=layer.layer_id and layer_epsg.epsg='EPSG:4326'";
-			$v = array((integer)$layerId);
-		}
-/*
-// noFeaturetype = false
-		$sql = "SELECT ";
-			$sql .= "wfs_featuretype.featuretype_id,wfs_featuretype.featuretype_name, wfs_featuretype.featuretype_title, wfs_featuretype.featuretype_abstract,  wfs_featuretype.uuid,";
-			$sql .= "wfs.wfs_title, wfs.wfs_abstract, wfs.wfs_id, wfs.fees, wfs.accessconstraints, wfs.individualname, ";
-			$sql .= "wfs.positionname, wfs.providername, wfs.deliverypoint, wfs.city, wfs_timestamp, wfs_owner, ";
-			$sql .= "wfs.administrativearea, wfs.postalcode, wfs.voice, wfs.facsimile, wfs.wfs_owsproxy,";
-			$sql .= "wfs.electronicmailaddress, wfs.country, wfs.fkey_mb_group_id, ";
-			$sql .= "layer_epsg.minx || ',' || layer_epsg.miny || ',' || layer_epsg.maxx || ',' || layer_epsg.maxy  as bbox ";
-			$sql .= "FROM wms, layer, layer_epsg WHERE layer_id = $1 and layer.fkey_wms_id = wms.wms_id";
-			$sql .= " and layer_epsg.fkey_layer_id=layer.layer_id and layer_epsg.epsg='EPSG:4326'";
-			$v = array((integer)$featuretypeId);
-	}
-*/
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$mapbenderMetadata = db_fetch_array($res);
-
+	//new for 2018 - get all information from mb_metadata instead of crawling it from services
 	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table
-	$departmentMetadata = $admin->getOrgaInfoFromRegistry("wms", $mapbenderMetadata['wms_id'], $mapbenderMetadata['wms_owner']);
+	$departmentMetadata = $admin->getOrgaInfoFromRegistry("metadata", $mb_metadata['metadata_id'], $mb_metadata['fkey_mb_user_id']);
+	//$e = new mb_exception($departmentMetadata['mb_user_email']);
 	$userMetadata['mb_user_email'] = $departmentMetadata['mb_user_email'];
-
-	//check if resource is freely available to anonymous user - which are all users who search thru metadata catalogues:
-	$hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],PUBLIC_USER);
 	//schemas for metadata:
 	/*
 	<gmd:MD_Metadata xsi:schemaLocation="http://www.isotc211.org/2005/gmd http://schemas.opengis.net/iso/19139/20060504/gmd/gmd.xsd" xmlns:gmd="http://www.isotc211.org/2005/gmd" xmlns:gco="http://www.isotc211.org/2005/gco" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:gml="http://www.opengis.net/gml" xmlns:xlink="http://www.w3.org/1999/xlink">
@@ -476,9 +385,9 @@
 	$language = $iso19139->createElement("gmd:language");
 	$languagecode = $iso19139->createElement("gmd:LanguageCode");
 	$languagecode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#LanguageCode");
-	if (isset($mapbenderMetadata['metadata_language'])) {
-		$languageText = $iso19139->createTextNode($mapbenderMetadata['metadata_language']);
-		$languagecode->setAttribute("codeListValue", $mapbenderMetadata['metadata_language']);
+	if (isset($mb_metadata['metadata_language'])) {
+		$languageText = $iso19139->createTextNode($mb_metadata['metadata_language']);
+		$languagecode->setAttribute("codeListValue", $mb_metadata['metadata_language']);
 	}
 	else {
 		$languageText = $iso19139->createTextNode("ger");
@@ -689,10 +598,7 @@
 	$gmd_organisationName_cs->appendChild($gmd_organisationName_Text);
 	$gmd_organisationName->appendChild($gmd_organisationName_cs);
 	$gmd_CI_ResponsibleParty->appendChild($gmd_organisationName);
-	
 
-
-
 	$gmd_contactInfo=$iso19139->createElement("gmd:contactInfo");
 	$gmd_CI_Contact=$iso19139->createElement("gmd:CI_Contact");
 	$gmd_onlineResource=$iso19139->createElement("gmd:onlineResource");
@@ -743,14 +649,12 @@
 
 	$MD_Metadata->appendChild($gmd_referenceSystemInfo);
 
-
 	#do the things for identification
 	$identificationInfo=$iso19139->createElement("gmd:identificationInfo");
 	$MD_DataIdentification=$iso19139->createElement("gmd:MD_DataIdentification");
 
 	$MD_DataIdentification->setAttribute("id", "spatial_dataset_".md5($mb_metadata['uuid']));
 
-
 	$citation=$iso19139->createElement("gmd:citation");
 	$CI_Citation=$iso19139->createElement("gmd:CI_Citation");
 
@@ -842,7 +746,6 @@
 			default:
 			break;
 		}
-	
 
 		$date1=$iso19139->createElement("gmd:date");
 		$CI_Date=$iso19139->createElement("gmd:CI_Date");
@@ -955,7 +858,7 @@
 		}
 	}
 
-$e = new mb_exception($uniqueResourceIdentifierCodespace);
+	//$e = new mb_exception($uniqueResourceIdentifierCodespace);
 
 	$codeText=$iso19139->createTextNode($uniqueResourceIdentifierCodespace.$mb_metadata['uuid']);
 
@@ -966,10 +869,6 @@
 	$identifier->appendChild($md_identifier);
 	$CI_Citation->appendChild($identifier);
 
-
-
-
-
 	$citation->appendChild($CI_Citation);
 	$MD_DataIdentification->appendChild($citation);
 
@@ -1005,22 +904,12 @@
 	if (isset($mb_metadata['responsible_party_name']) && $mb_metadata['responsible_party_name'] !=='') {
 		$resOrgaText = $iso19139->createTextNode($mb_metadata['responsible_party_name']);
 	} else {
-		if (isset($mapbenderMetadata['contactorganization'])) {
-			$resOrgaText = $iso19139->createTextNode($mapbenderMetadata['contactorganization']);
-		}
-		else {
-			$resOrgaText= $iso19139->createTextNode("not yet defined");
-		}
+		$resOrgaText= $iso19139->createTextNode("not yet defined");
 	}
 	if (isset($mb_metadata['responsible_party_email']) && $mb_metadata['responsible_party_email'] !=='') {
 		$resMailText = $iso19139->createTextNode($mb_metadata['responsible_party_email']);
 	} else {
-		if (isset($mapbenderMetadata['contactelectronicmailaddress']) && $mapbenderMetadata['contactelectronicmailaddress'] != '') {
-			$resMailText = $iso19139->createTextNode($mapbenderMetadata['contactelectronicmailaddress']);
-		}
-		else {
-			$resMailText = $iso19139->createTextNode("kontakt at geoportal.rlp.de");
-		}
+		$resMailText = $iso19139->createTextNode("kontakt at geoportal.rlp.de");
 	}
 	$resRoleText = $iso19139->createTextNode("pointOfContact");
 	$orgaName_cs->appendChild($resOrgaText);
@@ -1077,8 +966,8 @@
 	}
 	//generate keyword part - for services the inspire themes are not applicable!!!**********
 	//read keywords for resource out of the database/not only layer keywords also featuretype keywords if given!
-	$sql = "SELECT DISTINCT keyword.keyword FROM keyword, layer_keyword WHERE layer_keyword.fkey_layer_id=$1 AND layer_keyword.fkey_keyword_id=keyword.keyword_id";
-	$v = array((integer)$layerId);
+	$sql = "SELECT DISTINCT keyword.keyword FROM keyword, mb_metadata_keyword WHERE mb_metadata_keyword.fkey_metadata_id=$1 AND mb_metadata_keyword.fkey_keyword_id=keyword.keyword_id";
+	$v = array((integer)$mb_metadata['metadata_id']);
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	$descriptiveKeywords=$iso19139->createElement("gmd:descriptiveKeywords");
@@ -1095,10 +984,10 @@
 		}
 	}
 	//pull special keywords from custom categories:
-	$e = new mb_notice("layer: ".$layerId);	
+	//$e = new mb_notice("layer: ".$layerId);	
 
-	$sql = "SELECT DISTINCT custom_category.custom_category_key FROM custom_category, layer_custom_category WHERE layer_custom_category.fkey_layer_id = $1 AND layer_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0";
-	$v = array((integer)$layerId);
+	$sql = "SELECT DISTINCT custom_category.custom_category_key FROM custom_category, mb_metadata_custom_category WHERE mb_metadata_custom_category.fkey_metadata_id = $1 AND mb_metadata_custom_category.fkey_custom_category_id =  custom_category.custom_category_id AND custom_category_hidden = 0";
+	$v = array((integer)$mb_metadata['metadata_id']);
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	$e = new mb_notice("look for custom categories: ");
@@ -1123,8 +1012,8 @@
 /* example
 <gmd:keyword><gco:CharacterString>Geographical names</gco:CharacterString></gmd:keyword><gmd:thesaurusName><gmd:CI_Citation><gmd:title><gco:CharacterString>GEMET - INSPIRE themes, version 1.0</gco:CharacterString></gmd:title><gmd:date><gmd:CI_Date><gmd:date><gco:Date>2008-06-01</gco:Date></gmd:date><gmd:dateType><gmd:CI_DateTypeCode codeList="http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/ML_gmxCodelists.xml#CI_DateTypeCode" codeListValue="publication">publication</gmd:CI_DateTypeCode></gmd:dateType></gmd:CI_Date></gmd:date></gmd:CI_Citation></gmd:thesaurusName></gmd:MD_Keywords></gmd:descriptiveKeywords><gmd:descriptiveKeywords><gmd:MD_Keywords><gmd:keyword><gco:CharacterString>BasisDLM</gco:CharacterString></gmd:keyword>	
 */
-	$sql = "SELECT DISTINCT inspire_category.inspire_category_code_en FROM inspire_category, layer_inspire_category WHERE layer_inspire_category.fkey_layer_id=$1 AND layer_inspire_category.fkey_inspire_category_id=inspire_category.inspire_category_id";
-	$v = array((integer)$layerId);
+	$sql = "SELECT DISTINCT inspire_category.inspire_category_code_en FROM inspire_category, mb_metadata_inspire_category WHERE mb_metadata_inspire_category.fkey_metadata_id=$1 AND mb_metadata_inspire_category.fkey_inspire_category_id=inspire_category.inspire_category_id";
+	$v = array((integer)$mb_metadata['metadata_id']);
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	while ($row = db_fetch_array($res)) {
@@ -1196,14 +1085,6 @@
 	$predefinedLicenseFound = false;
 	$licenseOrigin = "metadata";
 	$res = db_prep_query($sql,$v,$t);
-	if (db_num_rows($res) == 0) {
-		$licenseOrigin = "service";
-		//check service for predefined license
-		$sql = "SELECT * FROM termsofuse WHERE termsofuse_id IN (SELECT fkey_termsofuse_id FROM wms_termsofuse WHERE fkey_wms_id = $1)";
-		$v = array((integer)$wmsId);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-	}
 	if (db_num_rows($res) > 0) {
 		$predefinedLicenseFound = true;
 		while ($row = db_fetch_array($res)) {
@@ -1220,13 +1101,6 @@
 							$license_source = "Source note required by license, but not given!";
 						}
 					break;
-					case "service":
-						if (isset($mapbenderMetadata['wms_license_source_note']) && $mapbenderMetadata['wms_license_source_note'] !==  "") {
-							$license_source = $mapbenderMetadata['wms_license_source_note'];
-						} else {
-							$license_source = "Source note required by license, but not given!";
-						}
-					break;
 				}
 			} else {
 				$license_source = false;
@@ -1255,11 +1129,7 @@
 	if (isset($mb_metadata['fees']) && $mb_metadata['fees'] !== '') {
 			$useLimitationTextString = $mb_metadata['fees']." ".$predefinedLicenseText;
 	} else {
-		if(isset($mapbenderMetadata['fees'])){
-			$useLimitationTextString = $mapbenderMetadata['fees']." ".$predefinedLicenseText;
-		} else {
-			$useLimitationTextString = "no conditions apply";
-		}
+		$useLimitationTextString = "no conditions apply";
 	}
 	$useLimitationText = $iso19139->createTextNode($useLimitationTextString);
  	//TODO: Mapping of constraints between OWS/registry and INSPIRE 
@@ -1320,7 +1190,6 @@
 		
 	}
 
-
 	$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
 	$MD_LegalConstraints=$iso19139->createElement("gmd:MD_LegalConstraints");
 	$accessConstraints=$iso19139->createElement("gmd:accessConstraints");
@@ -1331,13 +1200,9 @@
 	$otherConstraints=$iso19139->createElement("gmd:otherConstraints");
 	$otherConstraints_cs=$iso19139->createElement("gco:CharacterString");
 	if (isset($mb_metadata['constraints']) && $mb_metadata['constraints'] !== '') {
-			$otherConstraintsText=$iso19139->createTextNode($mb_metadata['constraints']);
-		} else {
-		if (isset($mapbenderMetadata['accessconstraints']) & strtoupper($mapbenderMetadata['accessconstraints']) != 'NONE'){
-			$otherConstraintsText=$iso19139->createTextNode($mapbenderMetadata['accessconstraints']);
-		} else {
-			$otherConstraintsText=$iso19139->createTextNode("no constraints");
-		}
+		$otherConstraintsText=$iso19139->createTextNode($mb_metadata['constraints']);
+	} else {
+		$otherConstraintsText=$iso19139->createTextNode("no constraints");
 	}
 	$otherConstraints_cs->appendChild($otherConstraintsText);
 	$otherConstraints->appendChild($otherConstraints_cs);
@@ -1414,17 +1279,16 @@
 	$characterSet->appendChild($MD_CharacterSetCode);
 	$MD_DataIdentification->appendChild($characterSet);
 
-
 /*
 <gmd:topicCategory>
 <gmd:MD_TopicCategoryCode>imageryBaseMapsEarthCover</gmd:MD_TopicCategoryCode>
 </gmd:topicCategory>
 */
-	#Topic Category B 2.1 - not needed for services
+	//Topic Category B 2.1 - not needed for services
 
-	//read keywords for resource out of the database:
-	$sql = "SELECT DISTINCT md_topic_category.md_topic_category_code_en FROM md_topic_category, layer_md_topic_category WHERE layer_md_topic_category.fkey_layer_id = $1 AND layer_md_topic_category.fkey_md_topic_category_id=md_topic_category.md_topic_category_id";
-	$v = array((integer)$layerId);
+	//read topic categories for resource out of the database:
+	$sql = "SELECT DISTINCT md_topic_category.md_topic_category_code_en FROM md_topic_category INNER JOIN mb_metadata_md_topic_category ON md_topic_category.md_topic_category_id = mb_metadata_md_topic_category.fkey_md_topic_category_id WHERE mb_metadata_md_topic_category.fkey_metadata_id = $1";
+	$v = array((integer)$mb_metadata['metadata_id']);
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	$e = new mb_notice("look for topic: ");
@@ -1449,7 +1313,6 @@
 		$topicCategory->appendChild($MD_TopicCategoryCode);
 		$MD_DataIdentification->appendChild($topicCategory);
 	}
-
 	#Geographical Extent
 	$bbox = array();
 	//initialize if no extent is defined in the database
@@ -1457,9 +1320,11 @@
 	$bbox[1] = -90;
 	$bbox[2] = 180;
 	$bbox[3] = 90;
-	if (isset($mapbenderMetadata['bbox']) & ($mapbenderMetadata['bbox'] != '')) {
-		$bbox = explode(',',$mapbenderMetadata['bbox']);
+
+	if (isset($mb_metadata['bbox2d']) & ($mb_metadata['bbox2d'] != '')) {
+		$bbox = explode(',',$mb_metadata['bbox2d']);
 	}
+
 	$extent=$iso19139->createElement("gmd:extent");
 	$EX_Extent=$iso19139->createElement("gmd:EX_Extent");
 	$geographicElement=$iso19139->createElement("gmd:geographicElement");
@@ -1547,14 +1412,9 @@
 	$extent->appendChild($EX_Extent);
 	$MD_DataIdentification->appendChild($extent);
 
-
-	
-
-
 	$identificationInfo->appendChild($MD_DataIdentification);
 
-
-//distributionInfo
+	//distributionInfo
 	$gmd_distributionInfo=$iso19139->createElement("gmd:distributionInfo");
 	$MD_Distribution=$iso19139->createElement("gmd:MD_Distribution");
 	$gmd_distributionFormat=$iso19139->createElement("gmd:distributionFormat");
@@ -1583,12 +1443,15 @@
 
 	$gmd_linkage=$iso19139->createElement("gmd:linkage");
 	$gmd_URL=$iso19139->createElement("gmd:URL");
-	//Check if anonymous user has rights to access this layer - if not ? which resource should be advertised? TODO
-	if ($hasPermission) {
-		$gmd_URLText=$iso19139->createTextNode("http://".$_SERVER['HTTP_HOST']."/mapbender/php/wms.php?inspire=1&layer_id=".$mapbenderMetadata['layer_id']."");
+	//use downloadurl if given
+	$downloadUrls = json_decode($mb_metadata['datalinks']);
+	$downloadUrl = $downloadUrls->downloadLinks[0]->{0};
+	//
+	if ($downloadUrl == "" || !isset($downloadUrl)) {
+		$gmd_URLText=$iso19139->createTextNode("http://dummydownloadurl.domain");
 	}
 	else {
-		$gmd_URLText=$iso19139->createTextNode("https://".$_SERVER['HTTP_HOST']."/http_auth/".$mapbenderMetadata['layer_id']."?");
+		$gmd_URLText=$iso19139->createTextNode($downloadUrl);
 	}
 	$gmd_URL->appendChild($gmd_URLText);
 	$gmd_linkage->appendChild($gmd_URL);
@@ -1687,54 +1550,5 @@
 	$MD_Metadata->appendChild($gmd_dataQualityInfo);
 	return $iso19139->saveXML();
 }
-
-
-
-function getEpsgByLayerId ($layer_id) { // from merge_layer.php
-	$epsg_list = "";
-	$sql = "SELECT DISTINCT epsg FROM layer_epsg WHERE fkey_layer_id = $1";
-	$v = array($layer_id);
-	$t = array('i');
-	$res = db_prep_query($sql, $v, $t);
-	while($row = db_fetch_array($res)){
-		$epsg_list .= $row['epsg'] . " ";
-	}
-	return trim($epsg_list);
-}
-
-function getEpsgArrayByLayerId ($layer_id) { // from merge_layer.php
-	//$epsg_list = "";
-	$epsg_array=array();
-	$sql = "SELECT DISTINCT epsg FROM layer_epsg WHERE fkey_layer_id = $1";
-	$v = array($layer_id);
-	$t = array('i');
-	$res = db_prep_query($sql, $v, $t);
-	$cnt=0;
-	while($row = db_fetch_array($res)){
-		$epsg_array[$cnt] = $row['epsg'];
-		$cnt++;
-	}
-	return $epsg_array;
-}
-
-function guid(){
-    if (function_exists('com_create_guid')){
-        return com_create_guid();
-    }else{
-        mt_srand((double)microtime()*10000);//optional for php 4.2.0 and up.
-        $charid = strtoupper(md5(uniqid(rand(), true)));
-        $hyphen = chr(45);// "-"
-        $uuid = chr(123)// "{"
-                .substr($charid, 0, 8).$hyphen
-                .substr($charid, 8, 4).$hyphen
-                .substr($charid,12, 4).$hyphen
-                .substr($charid,16, 4).$hyphen
-                .substr($charid,20,12)
-                .chr(125);// "}"
-        return $uuid;
-    }
-}
-
-
 ?>
 

Modified: trunk/mapbender/http/php/mod_showMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_showMetadata.php	2018-01-16 19:55:45 UTC (rev 9846)
+++ trunk/mapbender/http/php/mod_showMetadata.php	2018-01-17 14:45:06 UTC (rev 9847)
@@ -641,7 +641,7 @@
 	$resourceMetadata['featuretype_geomType'] = $featuretypeElements['element_type'];
 }
 
-$e = new mb_exception("mod_showMetadata: mb_group_name: ".$metadataContactGroup['mb_group_name']);
+//$e = new mb_exception("mod_showMetadata: mb_group_name: ".$metadataContactGroup['mb_group_name']);
 //db select for layer previews
 if ($resource == 'wms' or $resource == 'layer') {
 	$resourceMetadata['preview'] = "<img class='responsivimg' src = '../geoportal/mod_showPreview.php?resource=layer&id=".$layerId."'>";



More information about the Mapbender_commits mailing list