[Mapbender-commits] r7799 - in trunk/mapbender: http/classes http/php http/plugins resources/db/pgsql/UTF-8/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Mon May 9 09:04:48 EDT 2011


Author: armin11
Date: 2011-05-09 06:04:48 -0700 (Mon, 09 May 2011)
New Revision: 7799

Modified:
   trunk/mapbender/http/classes/class_wms.php
   trunk/mapbender/http/php/mod_dataISOMetadata.php
   trunk/mapbender/http/php/mod_layerISOMetadata.php
   trunk/mapbender/http/php/wms.php
   trunk/mapbender/http/plugins/mb_metadata_layer.js
   trunk/mapbender/http/plugins/mb_metadata_server.php
   trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
   trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql
Log:
Bugfixes and first functional service/data metadata coupling for inspire ! ;-)

Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/classes/class_wms.php	2011-05-09 13:04:48 UTC (rev 7799)
@@ -2200,6 +2200,21 @@
 					//TODO: check if this is set, maybe DateTime must be searched instead?
 					//title
 					$title = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:title/gco:CharacterString');
+					//dataset identifier - howto model into md_metadata?
+					//check where datasetid is defined - maybe as RS_Identifier or as MD_Identifier see http://inspire.jrc.ec.europa.eu/documents/Metadata/INSPIRE_MD_IR_and_ISO_v1_2_20100616.pdf page 18
+					$code = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:code/gco:CharacterString');
+					$codeSpace = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:citation/gmd:CI_Citation/gmd:identifier/gmd:RS_Identifier/gmd:codeSpace/gco:CharacterString');
+					$e = new mb_exception("class_wms.php: code: ".$code[0]);
+					$e = new mb_exception("class_wms.php: codeSpace: ".$codeSpace[0]);
+					if (isset($codeSpace[0]) && isset($code[0]) && $codeSpace[0] != '' && $code[0] != '') {
+						
+						$datasetid = $codeSpace[0]."#".$code[0];
+						$e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+					} else {
+						
+						$datasetid = 'undefined';# in sense of INSPIRE TODO control MD_Identifier too!
+						$e = new mb_exception("class_wms.php: datasetid: ".$datasetid);
+					}
 					//abstract
 					$abstract = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:abstract/gco:CharacterString');
 					//searchtext -- use keywords!
@@ -2209,7 +2224,7 @@
 					//tmp_reference_1
 					$tmp_reference_1 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:beginPosition');
 					//tmp_reference_2
-					$tmp_reference_2 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');					//spatial_res_type
+					$tmp_reference_2 = $iso19139Xml->xpath('/gmd:MD_Metadata/gmd:identificationInfo/gmd:MD_DataIdentification/gmd:extent/gmd:EX_Extent/gmd:temporalElement/gmd:EX_TemporalExtent/gmd:extent/gml:TimePeriod/gml:endPosition');			//spatial_res_type
 					//spatial_res_value
 					//ref_system
 					//format
@@ -2219,8 +2234,8 @@
 					//fees
 					//"constraints"	
 					//fill database with elements:
-					$sql = "INSERT INTO mb_metadata (link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw) ";
-					$sql .= "VALUES($1, 'capabilities', $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14)";
+					$sql = "INSERT INTO mb_metadata (link, origin, md_format, data, linktype, uuid, title, createdate, changedate, abstract, searchtext, type, tmp_reference_1, tmp_reference_2, export2csw, datasetid) ";
+					$sql .= "VALUES($1, 'capabilities', $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)";
 					$v = array($this->objLayer[$i]->layer_metadataurl[$j]->href,
 						$this->objLayer[$i]->layer_metadataurl[$j]->format,
 						$metaData,
@@ -2234,9 +2249,10 @@
 						$type[0],
 						$tmp_reference_1[0],
 						$tmp_reference_2[0],
-						't'
+						't',
+						$datasetid
 					);
-					$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b');
+					$t = array('s','s','s','s','s','s','s','s','s','s','s','s','s','b','s');
 					$res = db_prep_query($sql,$v,$t);
 					if(!$res){
 						db_rollback();	

Modified: trunk/mapbender/http/php/mod_dataISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_dataISOMetadata.php	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/php/mod_dataISOMetadata.php	2011-05-09 13:04:48 UTC (rev 7799)
@@ -1,5 +1,6 @@
 <?php
 #http://www.geoportal.rlp.de/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&Id=uuid
+#http://localhost/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&ID=cb567df4-57da-449a-be74-821903a59d45
 # $Id: mod_dataISOMetadata.php 235
 # http://www.mapbender.org/index.php/Inspire_Metadata_Editor
 # Copyright (C) 2002 CCGIS 
@@ -17,8 +18,6 @@
 # You should have received a copy of the GNU General Public License
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
-
-
 //function to pull out information from mapbenders md_metadata table
 //the information is pulled out by uuid cause the uuid is not changed
 //there are 3 ways to access the information:
@@ -26,7 +25,6 @@
 //2. read the metadata addon information and fill the rest from the wms/mb_user/mb_group/layer table
 //3. give back the harvested content of the column data - if conform?
 
-
 require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
 require_once(dirname(__FILE__) . "/../classes/class_connector.php");
 require_once(dirname(__FILE__) . "/../classes/class_administration.php");
@@ -36,13 +34,12 @@
 db_select_db(DB,$con);
 
 $admin = new administration();
-
+$wmsView = '';
 //parse request parameter
 //make all parameters available as upper case
 foreach($_REQUEST as $key => $val) {
 	$_REQUEST[strtoupper($key)] = $val;
 }
-
 //example mapbender uuid: 2494d033-ccdd-cdd7-71c6-3e3c195e1d85
 //cb567df4-57da-449a-be74-821903a59d45
 
@@ -75,9 +72,6 @@
 	echo 'validate: <b>'.$_REQUEST['VALIDATE'].'</b> is not valid.<br/>'; 
 	die();
 }
-
-
-	
 	//get record from mb_metadata and prohibit duplicates:
 	$sql = <<<SQL
 
@@ -137,8 +131,7 @@
 					die();
 				}
 				
-			}
-			
+			}	
 		//if xml has been harvested - push this xml from database, if not just harvest it and push the result
 		break;
 		case 'capabilities':
@@ -162,7 +155,6 @@
 		default:
 		break;	
 	}
-
 //function to give away the xml data
 function pushISO19139($iso19139Doc, $recordId) {
 	//echo $recordId;
@@ -171,28 +163,30 @@
 	echo $xml;
 	die();
 }
-
 //some needfull functions to pull metadata out of the database!
 function fillISO19139($iso19139, $recordId) {
 	global $admin;
 	global $mb_metadata;
 	//read out relevant information from mapbender database:
 	//layer and service 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) INNER JOIN mb_metadata ON 
-(mb_metadata.metadata_id = ows_relation_metadata.fkey_metadata_id) WHERE 
-mb_metadata. = $1 ORDER BY layer_id DESC LIMIT 1
-SQL;*/
 	$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
 SQL;
 	//TODO: Problem - the metadata may be used for more than one service - not often but sometimes - does one get the right contact data?
+	$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) {
+		$exception = "<exception>No coupled resource found in database!</exception>";
+		return $exception;
+	} else {
+		$mb_metadata_coupling = db_fetch_array($res);
+	}
+	$layerId = $mb_metadata_coupling['layer_id'];
+	$wmsId = $mb_metadata_coupling['wms_id'];
+	$e = new mb_notice("mod_dataISOMetadata.php: Found coupled layer with id: ".$layerId);
 	if ($wmsView != '') {
 		$sql = "SELECT * ";
 		$sql .= "FROM ".$wmsView." WHERE layer_id = $1";
@@ -209,24 +203,13 @@
 		$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)$recordId);
+	$v = array((integer)$layerId);
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	$mapbenderMetadata = db_fetch_array($res);
-	
-	//Get other needed information out of mapbender database (if not already defined in the view):
-	//service data
-	if ($wmsView != '') {
-		$sql = "SELECT contactorganization, contactelectronicmailaddress ";
-		$sql .= "FROM wms WHERE wms_id = $1";
-		$v = array((integer)$mapbenderMetadata['wms_id']);
-		$t = array('i');
-		$res = db_prep_query($sql,$v,$t);
-		$serviceMetadata = db_fetch_array($res);
-	}
 	//infos about the registrating department, check first if a special metadata point of contact is defined in the service table - function from mod_showMetadata - TODO: should be defined in admin class
 	if (!isset($mapbenderMetadata['fkey_mb_group_id']) or is_null($mapbenderMetadata['fkey_mb_group_id']) or $mapbenderMetadata['fkey_mb_group_id'] == 0){
-		$e = new mb_exception("mod_layerISOMetadata.php: fkey_mb_group_id not found!");
+		$e = new mb_exception("mod_dataISOMetadata.php: fkey_mb_group_id not found!");
 		//Get information about owning user of the relation mb_user_mb_group - alternatively the defined fkey_mb_group_id from the service must be used!
 		$sqlDep = "SELECT mb_group_name, mb_group_title, mb_group_id, mb_group_logo_path, mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone FROM mb_group AS a, mb_user AS b, mb_user_mb_group AS c WHERE b.mb_user_id = $1  AND b.mb_user_id = c.fkey_mb_user_id AND c.fkey_mb_group_id = a.mb_group_id AND c.mb_user_mb_group_type=2 LIMIT 1";
 		$vDep = array($mapbenderMetadata['wms_owner']);
@@ -234,7 +217,7 @@
 		$resDep = db_prep_query($sqlDep, $vDep, $tDep);
 		$departmentMetadata = db_fetch_array($resDep);
 	} else {
-		$e = new mb_exception("mod_layerISOMetadata.php: fkey_mb_group_id found!");
+		$e = new mb_exception("mod_dataISOMetadata.php: fkey_mb_group_id found!");
 		$sqlDep = "SELECT mb_group_name , mb_group_title, mb_group_id, mb_group_logo_path , mb_group_address, mb_group_email, mb_group_postcode, mb_group_city, mb_group_voicetelephone, mb_group_facsimiletelephone FROM mb_group WHERE mb_group_id = $1 LIMIT 1";
 		$vDep = array($mapbenderMetadata['fkey_mb_group_id']);
 		$tDep = array('i');
@@ -249,11 +232,9 @@
 	$res = db_prep_query($sql,$v,$t);
 	$userMetadata = db_fetch_array($res);
 	//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'],ANONYMOUS_USER);
+	$hasPermission=$admin->getLayerPermission($mapbenderMetadata['wms_id'],$mapbenderMetadata['layer_name'],PUBLIC_USER);
 	//Creating the "MD_Metadata" node
 	$MD_Metadata = $iso19139->createElementNS('http://www.isotc211.org/2005/gmd', 'gmd:MD_Metadata');
-	//$MD_Metadata=$iso19139->registerNamespace('srv','http://www.iso211.org/2005/srv');
-	//$wmt_ms_capabilities->setAttribute("updateSequence", $wms_row["wms_timestamp"]);
 	$MD_Metadata = $iso19139->appendChild($MD_Metadata);
 	$MD_Metadata->setAttribute("xmlns:srv", "http://www.isotc211.org/2005/srv");
 	$MD_Metadata->setAttribute("xmlns:gml", "http://www.opengis.net/gml");
@@ -261,11 +242,12 @@
 	$MD_Metadata->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink");
 	$MD_Metadata->setAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
 	$MD_Metadata->setAttribute("xsi:schemaLocation", "http://www.isotc211.org/2005/gmd ./xsd/gmd/gmd.xsd://www.isotc211.org/2005/srv ./xsd/srv/srv.xsd");
-	//generate identifier part 
+
+	//generate fileidentifier part (metadata record identification) 
 	$identifier = $iso19139->createElement("gmd:fileIdentifier");
 	$identifierString = $iso19139->createElement("gco:CharacterString");
-	if (isset($mapbenderMetadata['uuid'])) {
-		$identifierText = $iso19139->createTextNode($mapbenderMetadata['uuid']);//TODO: generate an uuid?
+	if (isset($mb_metadata['uuid'])) {
+		$identifierText = $iso19139->createTextNode($mb_metadata['uuid']);
 	}
 	else {
 		$identifierText = $iso19139->createTextNode("no id found");
@@ -288,31 +270,31 @@
 	$languagecode->appendChild($languageText);
 	$language ->appendChild($languagecode);
 	$language = $MD_Metadata->appendChild($language);
-	//generate Characterset - first it should be utf8 ;-)
+
+	//generate Characterset 
 	$characterSet = $iso19139->createElement("gmd:characterSet");
 	$characterSetCode = $iso19139->createElement("gmd:MD_CharacterSetCode");
 	$characterSetCode->setAttribute("codeList", "./resources/codeList.xml#MD_CharacterSetCode");
-	$characterSetCode->setAttribute("codeListValue", "utf8");
+	$characterSetCode->setAttribute("codeListValue", $mb_metadata['inspire_charset']);
 	$characterSet->appendChild($characterSetCode);
 	$characterSet = $MD_Metadata->appendChild($characterSet);
 
-
-
 	#generate MD_Scope part B 1.3 (if available)
 	$hierarchyLevel = $iso19139->createElement("gmd:hierarchyLevel");
 	$scopecode = $iso19139->createElement("gmd:MD_ScopeCode");
 	$scopecode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#MD_ScopeCode");
-	if (isset($mapbenderMetadata['hierarchy_level'])) {
-		$scopecode->setAttribute("codeListValue", $mapbenderMetadata['hierarchy_level']);//if such a metadata exists in the mapbender metadata view
-		$scopeText = $iso19139->createTextNode($mapbenderMetadata['hierarchy_level']);
+	if (isset($mb_metadata['type'])) {
+		$scopecode->setAttribute("codeListValue", $mb_metadata['type']);
+		$scopeText = $iso19139->createTextNode($mb_metadata['type']);
 	}
 	else {
-		$scopecode->setAttribute("codeListValue", "service");
-		$scopeText = $iso19139->createTextNode("service");
+		$scopecode->setAttribute("codeListValue", "dataset");
+		$scopeText = $iso19139->createTextNode("dataset");
 	}
 	$scopecode->appendChild($scopeText);
 	$hierarchyLevel->appendChild($scopecode);
 	$hierarchyLevel=$MD_Metadata->appendChild($hierarchyLevel);
+
 	#Part B 10.1 responsible party for the resource
 	$contact=$iso19139->createElement("gmd:contact");
 	$CI_ResponsibleParty=$iso19139->createElement("gmd:CI_ResponsibleParty");
@@ -331,20 +313,19 @@
 	$CI_Address=$iso19139->createElement("gmd:CI_Address");
 	$electronicMailAddress=$iso19139->createElement("gmd:electronicMailAddress");
 	$electronicMailAddress_cs=$iso19139->createElement("gco:CharacterString");
-	if (isset($userMetadata['mb_user_email'])) {
+	if (isset($userMetadata['mb_user_email']) && $userMetadata['mb_user_email'] != '') {
 		//get email address from ows service metadata out of mapbender database	
 		$electronicMailAddressText=$iso19139->createTextNode($userMetadata['mb_user_email']); 
 	}
 	else
 	{
-		$electronicMailAddressText=$iso19139->createTextNode('email not yet given');
+		$electronicMailAddressText=$iso19139->createTextNode('kontakt at geoportal.rlp.de');
 	}
 	$role=$iso19139->createElement("gmd:role");
 	$CI_RoleCode=$iso19139->createElement("gmd:CI_RoleCode");
 	$CI_RoleCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_RoleCode");
 	$CI_RoleCode->setAttribute("codeListValue", "pointOfContact");
 	$CI_RoleCodeText=$iso19139->createTextNode("pointOfContact");
-	#create xml tree
 	$organisationName_cs->appendChild($organisationNameText);
 	$organisationName->appendChild($organisationName_cs);
 	$CI_ResponsibleParty->appendChild($organisationName);
@@ -360,11 +341,12 @@
 	$CI_ResponsibleParty->appendChild($role);
 	$contact->appendChild($CI_ResponsibleParty);
 	$MD_Metadata->appendChild($contact);
+
 	#generate dateStamp part B 10.2 (if available)
 	$dateStamp = $iso19139->createElement("gmd:dateStamp");
 	$mddate = $iso19139->createElement("gco:Date");
-	if (isset($mapbenderMetadata['wms_timestamp'])) {
-		$mddateText = $iso19139->createTextNode(date("Y-m-d",$mapbenderMetadata['wms_timestamp']));
+	if (isset($mb_metadata['lastchanged'])) {
+		$mddateText = $iso19139->createTextNode($mb_metadata['lastchanged']);
 	}
 	else {
 		$mddateText = $iso19139->createTextNode("2000-01-01");
@@ -372,33 +354,33 @@
 	$mddate->appendChild($mddateText);
 	$dateStamp->appendChild($mddate);
 	$dateStamp=$MD_Metadata->appendChild($dateStamp);
+
 	//standard definition - everytime the same
 	$metadataStandardName = $iso19139->createElement("gmd:metadataStandardName");
 	$metadataStandardVersion = $iso19139->createElement("gmd:metadataStandardVersion");
 	$metadataStandardNameText = $iso19139->createElement("gco:CharacterString");
 	$metadataStandardVersionText = $iso19139->createElement("gco:CharacterString");
-	$metadataStandardNameTextString = $iso19139->createTextNode("ISO19119");
-	$metadataStandardVersionTextString = $iso19139->createTextNode("2005/PDAM 1");
+	$metadataStandardNameTextString = $iso19139->createTextNode("ISO19115");
+	$metadataStandardVersionTextString = $iso19139->createTextNode("2003/Cor.1:2006");
 	$metadataStandardNameText->appendChild($metadataStandardNameTextString);
 	$metadataStandardVersionText->appendChild($metadataStandardVersionTextString);
 	$metadataStandardName->appendChild($metadataStandardNameText);
 	$metadataStandardVersion->appendChild($metadataStandardVersionText);
 	$MD_Metadata->appendChild($metadataStandardName);
 	$MD_Metadata->appendChild($metadataStandardVersion);
+
 	#do the things for identification
-	#create nodes
 	$identificationInfo=$iso19139->createElement("gmd:identificationInfo");
-	$SV_ServiceIdentification=$iso19139->createElement("srv:SV_ServiceIdentification");
-	#add attribut
-	//$SV_ServiceIdentification->setAttribute("id", "dataId");
+	$MD_DataIdentification=$iso19139->createElement("gmd:MD_DataIdentification");
 	$citation=$iso19139->createElement("gmd:citation");
 	$CI_Citation=$iso19139->createElement("gmd:CI_Citation");
-	#create nodes for things which are defined - howto do the multiplicities? Ask Martin!
+
+	#create nodes for things which are defined
 	#Create Resource title element B 1.1
 	$title=$iso19139->createElement("gmd:title");
 	$title_cs=$iso19139->createElement("gco:CharacterString");
-	if (isset($mapbenderMetadata['wms_title'])) {
-		$titleText = $iso19139->createTextNode($mapbenderMetadata['wms_title']);
+	if (isset($mb_metadata['title'])) {
+		$titleText = $iso19139->createTextNode($mb_metadata['title']);
 	}
 	else {
 		$titleText = $iso19139->createTextNode("title not given");
@@ -406,6 +388,7 @@
 	$title_cs->appendChild($titleText);
 	$title->appendChild($title_cs);
 	$CI_Citation->appendChild($title);
+
 	#Create date elements B5.2-5.4
 	#Do things for B 5.2 date of publication
 	if (isset($mapbenderMetadata['wms_timestamp_create'])) {
@@ -418,7 +401,7 @@
 		$dateTypeCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
 		$dateTypeCode->setAttribute("codeListValue", "publication");
 		$dateTypeCodeText=$iso19139->createTextNode('publication');
-		$dateText= $iso19139->createTextNode(date('Y-m-d',$mapbenderMetadata['wms_timestamp_create']));
+		$dateText= $iso19139->createTextNode($mapbenderMetadata['wms_timestamp_create']);
 		$dateTypeCode->appendChild($dateTypeCodeText);
 		$dateType->appendChild($dateTypeCode);
 		$gcoDate->appendChild($dateText);
@@ -429,7 +412,7 @@
 		$CI_Citation->appendChild($date1);
 	}
 	#Do things for B 5.3 date of revision
-	if (isset($mapbenderMetadata['wms_timestamp'])) {
+	if (isset($mb_metadata['createdate'])) {
 		$date1=$iso19139->createElement("gmd:date");
 		$CI_Date=$iso19139->createElement("gmd:CI_Date");
 		$date2=$iso19139->createElement("gmd:date");
@@ -439,7 +422,7 @@
 		$dateTypeCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
 		$dateTypeCode->setAttribute("codeListValue", "revision");
 		$dateTypeCodeText=$iso19139->createTextNode('revision');
-		$dateText= $iso19139->createTextNode(date('Y-m-d',$mapbenderMetadata['wms_timestamp']));
+		$dateText= $iso19139->createTextNode($mb_metadata['createdate']);
 		$dateTypeCode->appendChild($dateTypeCodeText);
 		$dateType->appendChild($dateTypeCode);
 		$gcoDate->appendChild($dateText);
@@ -450,7 +433,7 @@
 		$CI_Citation->appendChild($date1);
 	}
 	#Do things for B 5.4 date of creation
-	if (isset($mapbenderMetadata['wms_timestamp_creation'])) {
+	if (isset($mb_metadata['changedate']) || isset($mb_metadata['lastchanged'])) {
 		$date1=$iso19139->createElement("gmd:date");
 		$CI_Date=$iso19139->createElement("gmd:CI_Date");
 		$date2=$iso19139->createElement("gmd:date");
@@ -460,7 +443,11 @@
 		$dateTypeCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
 		$dateTypeCode->setAttribute("codeListValue", "creation");
 		$dateTypeCodeText=$iso19139->createTextNode('creation');
-		$dateText= $iso19139->createTextNode(date('Y-m-d',$mapbenderMetadata['wms_timestamp_creation']));
+		if (!isset($mb_metadata['changedate'])) {
+			$dateText= $iso19139->createTextNode($mb_metadata['lastchanged']);
+		} else {
+			$dateText= $iso19139->createTextNode($mb_metadata['changedate']);
+		}
 		$dateTypeCode->appendChild($dateTypeCodeText);
 		$dateType->appendChild($dateTypeCode);
 		$gcoDate->appendChild($dateText);
@@ -471,32 +458,52 @@
 		$CI_Citation->appendChild($date1);
 	}
 	#Do things for B 1.5 Resource unique identifier NOTE: not applicable for services
-	//$identifier=$iso19139->createElement("gmd:identifier");
-	//$rs_identifier=$iso19139->createElement("gmd:RS_Identifier");
-	//$code=$iso19139->createElement("gmd:code");
-	//$code_cs=$iso19139->createElement("gco:CharacterString");
-	//$codeText=$iso19139->createTextNode($detail_array['t01_object.obj_id']);
-	//$code_cs->appendChild($codeText);
-	//$code->appendChild($code_cs);
-	//$rs_identifier->appendChild($code);
-	//$identifier->appendChild($rs_identifier);
-	//$CI_Citation->appendChild($identifier);
-	#create tree
+//example from INSPIRE Guidance Metadata 
+//The main problem will be, that this entry is the identifier for the service data coupling 
+//to make it easy, we will use the same identifier as for fileidentifier! In case of external datasets, the right data identifier must be harvested! 
+//
+/*<gmd:identifier><gmd:RS_Identifier><gmd:code><gco:CharacterString>gdi-rp</gco:CharacterString></gmd:code><gmd:codeSpace><gco:CharacterString>gdi-rp</gco:CharacterString></gmd:codeSpace></gmd:RS_Identifier></gmd:identifier>*/
+	$identifier=$iso19139->createElement("gmd:identifier");
+	$rs_identifier=$iso19139->createElement("gmd:RS_Identifier");
+
+	$code=$iso19139->createElement("gmd:code");
+	$code_cs=$iso19139->createElement("gco:CharacterString");
+	$codeText=$iso19139->createTextNode($mb_metadata['uuid']); //in case of the mapbender addon!
+
+	$codeSpace=$iso19139->createElement("gmd:codeSpace");
+	$codeSpace_cs=$iso19139->createElement("gco:CharacterString");
+	$codeSpaceText=$iso19139->createTextNode("http://www.geoportal.rlp.de"); //in case of the mapbender addon!
+
+	$code_cs->appendChild($codeText);
+	$code->appendChild($code_cs);
+	$rs_identifier->appendChild($code);
+
+	$codeSpace_cs->appendChild($codeSpaceText);
+	$codeSpace->appendChild($codeSpace_cs);
+	$rs_identifier->appendChild($codeSpace);
+
+
+
+	$identifier->appendChild($rs_identifier);
+	$CI_Citation->appendChild($identifier);
+
 	$citation->appendChild($CI_Citation);
-	$SV_ServiceIdentification->appendChild($citation);
+	$MD_DataIdentification->appendChild($citation);
+
 	#Create part for abstract B 1.2
 	$abstract=$iso19139->createElement("gmd:abstract");
 	$abstract_cs=$iso19139->createElement("gco:CharacterString");
-	if (isset($mapbenderMetadata['wms_abstract'])) {
-		$abstractText = $iso19139->createTextNode($mapbenderMetadata['wms_abstract']);
+	if (isset($mb_metadata['abstract'])) {
+		$abstractText = $iso19139->createTextNode($mb_metadata['abstract']);
 	}
 	else {
 		$abstractText = $iso19139->createTextNode("not yet defined");
 	}
 	$abstract_cs->appendChild($abstractText);
 	$abstract->appendChild($abstract_cs);
-	$SV_ServiceIdentification->appendChild($abstract);
-	#Create part for point of contact for service identification
+	$MD_DataIdentification->appendChild($abstract);
+
+	#Create part for point of contact for data identification - use contact from service provider! 
 	#Define relevant objects
 	$pointOfContact=$iso19139->createElement("gmd:pointOfContact");
 	$CI_ResponsibleParty=$iso19139->createElement("gmd:CI_ResponsibleParty");
@@ -518,7 +525,7 @@
 	else {
 		$resOrgaText= $iso19139->createTextNode("not yet defined");
 	}
-	if (isset($mapbenderMetadata['contactelectronicmailaddress'])) {
+	if (isset($mapbenderMetadata['contactelectronicmailaddress']) && $mapbenderMetadata['contactelectronicmailaddress'] != '') {
 		$resMailText = $iso19139->createTextNode($mapbenderMetadata['contactelectronicmailaddress']);
 	}
 	else {
@@ -539,85 +546,17 @@
 	$role->appendChild($CI_RoleCode);
 	$CI_ResponsibleParty->appendChild($role);
 	$pointOfContact->appendChild($CI_ResponsibleParty);
-	$SV_ServiceIdentification->appendChild($pointOfContact);
-	//generate graphical overview part
-	$sql = "SELECT layer_preview.layer_map_preview_filename FROM layer_preview WHERE layer_preview.fkey_layer_id=$1";
-	$v = array((integer)$mapbenderMetadata["layer_id"]);
-	$t = array('i');
-	$res = db_prep_query($sql,$v,$t);
-	$row = db_fetch_array($res);
-	#old version 
-/*	if (isset($row['layer_map_preview_filename']) & $row['layer_map_preview_filename'] != '') {
-		$graphicOverview=$iso19139->createElement("gmd:graphicOverview");
-		$MD_BrowseGraphic=$iso19139->createElement("gmd:MD_BrowseGraphic");
-		$fileName=$iso19139->createElement("gmd:fileName");
-		$fileName_cs=$iso19139->createElement("gco:characterString");
-		$previewFilenameText = $iso19139->createTextNode("http://www.gdi-rp-dienste3.rlp.de/mapbender/x_geoportal/layer_preview/".$row['layer_map_preview_filename']);
-		$fileName_cs->appendChild($previewFilenameText);
-		$fileName->appendChild($fileName_cs);
-		$MD_BrowseGraphic->appendChild($fileName);
-		$graphicOverview->appendChild($MD_BrowseGraphic);
-		$SV_ServiceIdentification->appendChild($graphicOverview);
-	}
-*/	
-	#version of bavaria
-	if (file_exists(PREVIEW_DIR."/".$mapbenderMetadata['layer_id']."_layer_map_preview.jpg")) {	//TODO
-		$graphicOverview=$iso19139->createElement("gmd:graphicOverview");
-		$MD_BrowseGraphic=$iso19139->createElement("gmd:MD_BrowseGraphic");
-		$fileName=$iso19139->createElement("gmd:fileName");
-		$fileName_cs=$iso19139->createElement("gco:CharacterString");
-		$previewFilenameText = $iso19139->createTextNode("http://www.geoportal.rlp.de/mapbender/geoportal/preview/".$mapbenderMetadata['layer_id']."_layer_map_preview.jpg");
-		$fileName_cs->appendChild($previewFilenameText);
-		$fileName->appendChild($fileName_cs);
+	$MD_DataIdentification->appendChild($pointOfContact);
 
-		$fileDescription=$iso19139->createElement("gmd:fileDescription");
-		$fileDescription_cs=$iso19139->createElement("gco:CharacterString");
-		$fileDescription_text=$iso19139->createTextNode("Thumbnail");
-
-		$fileDescription_cs->appendChild($fileDescription_text);
-		$fileDescription->appendChild($fileDescription_cs);
-		
-
-		$fileType=$iso19139->createElement("gmd:fileType");
-		$fileType_cs=$iso19139->createElement("gco:CharacterString");
-		$fileType_text=$iso19139->createTextNode("JPEG");
-
-		$fileType_cs->appendChild($fileType_text);
-		$fileType->appendChild($fileType_cs);
-
-
-
-		$MD_BrowseGraphic->appendChild($fileName);
-
-		$MD_BrowseGraphic->appendChild($fileDescription);
-		$MD_BrowseGraphic->appendChild($fileType);
-
-		$graphicOverview->appendChild($MD_BrowseGraphic);
-		$SV_ServiceIdentification->appendChild($graphicOverview);
-	}
-	
-
-
-
-
-
-	/*<gmd:graphicOverview>
-  		<gmd:MD_BrowseGraphic>
-   			 <gmd:fileName>
-      				<gco:CharacterString>http://goesr.noaa.gov/browse/datasetIdentifier</gco:CharacterString>
-    			</gmd:fileName>
-  		</gmd:MD_BrowseGraphic>
-	</gmd:graphicOverview>*/
-	
-
-	//generate keyword part - for services the inspire themes are not applicable!!!
+	//generate keyword part - for services the inspire themes are not applicable!!!**********
 	//read keywords for resource out of the database:
 	$sql = "SELECT 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)$recordId);
+	$v = array((integer)$layerId);
 	$t = array('i');
 	$res = db_prep_query($sql,$v,$t);
 	$descriptiveKeywords=$iso19139->createElement("gmd:descriptiveKeywords");
 	$MD_Keywords=$iso19139->createElement("gmd:MD_Keywords");
+	//push in keywords without thesaurus
 	while ($row = db_fetch_array($res)) {
 		$keyword=$iso19139->createElement("gmd:keyword");
 		$keyword_cs=$iso19139->createElement("gco:CharacterString");
@@ -626,15 +565,64 @@
 		$keyword->appendChild($keyword_cs);
 		$MD_Keywords->appendChild($keyword);
 	}
-	//a special keyword for service type wms ;-)
-	$keyword=$iso19139->createElement("gmd:keyword");
-	$keyword_cs=$iso19139->createElement("gco:CharacterString");
-	$keywordText = $iso19139->createTextNode("humanGeographicViewer");
-	$keyword_cs->appendChild($keywordText);
-	$keyword->appendChild($keyword_cs);
-	$MD_Keywords->appendChild($keyword);
+	//read out the inspire categories and push them in as controlled keywords
+/* 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 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);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	while ($row = db_fetch_array($res)) {
+
+		//part for the name of the inspire category
+		$keyword=$iso19139->createElement("gmd:keyword");
+		$keyword_cs=$iso19139->createElement("gco:CharacterString");
+		$keywordText = $iso19139->createTextNode($row['inspire_category_code_en']);
+		$keyword_cs->appendChild($keywordText);
+		$keyword->appendChild($keyword_cs);
+
+		//part for the vocabulary
+		$thesaurusName = $iso19139->createElement("gmd:thesaurusName");
+		$CI_Citation = $iso19139->createElement("CI_Citation");
+		$title = $iso19139->createElement("gmd:title");
+		$title_cs = $iso19139->createElement("gco:CharacterString");
+		$titleText = $iso19139->createTextNode("GEMET - INSPIRE themes, version 1.0");
+
+		$title_cs->appendChild($titleText);
+		$title->appendChild($title_cs);
+		$CI_Citation->appendChild($title);
+
+		$date1=$iso19139->createElement("gmd:date");
+		$CI_Date=$iso19139->createElement("gmd:CI_Date");
+		$date2=$iso19139->createElement("gmd:date");
+		$gcoDate=$iso19139->createElement("gco:Date");
+		$dateType=$iso19139->createElement("gmd:dateType");
+		$dateTypeCode=$iso19139->createElement("gmd:CI_DateTypeCode");
+		$dateTypeCode->setAttribute("codeList", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode");
+		$dateTypeCode->setAttribute("codeListValue", "publication");
+		$dateTypeCodeText=$iso19139->createTextNode('publication');
+		$dateText= $iso19139->createTextNode('2008-06-01');
+		$dateTypeCode->appendChild($dateTypeCodeText);
+		$dateType->appendChild($dateTypeCode);
+		$gcoDate->appendChild($dateText);
+		$date2->appendChild($gcoDate);
+		$CI_Date->appendChild($date2);
+		$CI_Date->appendChild($dateType);
+		$date1->appendChild($CI_Date);
+
+		$CI_Citation->appendChild($date1);
+		$thesaurusName->appendChild($CI_Citation);
+
+		$MD_Keywords->appendChild($keyword);
+		$MD_Keywords->appendChild($thesaurusName);
+	}
+
+	//add the keyword part to the right leaf
 	$descriptiveKeywords->appendChild($MD_Keywords);
-	$SV_ServiceIdentification->appendChild($descriptiveKeywords);
+	$MD_DataIdentification->appendChild($descriptiveKeywords);
+	//End of keyword part **********
+
 	//generate constraints part
 	//generate service type part
 	//generate extent part
@@ -645,25 +633,24 @@
 	#Part B 3 INSPIRE Category
 	#do this only if an INSPIRE keyword (Annex I-III) is set
 	#Resource Constraints B 8
-	//if(isset($mapbenderMetadata['accessconstraints'])){
-		$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
-		$MD_LegalConstraints=$iso19139->createElement("gmd:MD_Constraints");
-		$useLimitation=$iso19139->createElement("gmd:useLimitation");
-		$useLimitation_cs=$iso19139->createElement("gco:CharacterString");
-		if(isset($mapbenderMetadata['accessconstraints'])){
-			$useLimitationText=$iso19139->createTextNode($mapbenderMetadata['accessconstraints']);
-		}
-		else
-		{
-			$useLimitationText=$iso19139->createTextNode("no conditions apply");
-		}
+	$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
+	$MD_LegalConstraints=$iso19139->createElement("gmd:MD_Constraints");
+	$useLimitation=$iso19139->createElement("gmd:useLimitation");
+	$useLimitation_cs=$iso19139->createElement("gco:CharacterString");
+	if(isset($mapbenderMetadata['accessconstraints'])){
+		$useLimitationText=$iso19139->createTextNode($mapbenderMetadata['accessconstraints']);
+	}
+	else
+	{
+		$useLimitationText=$iso19139->createTextNode("no conditions apply");
+	}
  	//TODO: Mapping of constraints between OWS/registry and INSPIRE 
-		$useLimitation_cs->appendChild($useLimitationText);
-		$useLimitation->appendChild($useLimitation_cs);
-		$MD_LegalConstraints->appendChild($useLimitation);
-		$resourceConstraints->appendChild($MD_LegalConstraints);
-		$SV_ServiceIdentification->appendChild($resourceConstraints);
-	//}
+	$useLimitation_cs->appendChild($useLimitationText);
+	$useLimitation->appendChild($useLimitation_cs);
+	$MD_LegalConstraints->appendChild($useLimitation);
+	$resourceConstraints->appendChild($MD_LegalConstraints);
+	$MD_DataIdentification->appendChild($resourceConstraints);
+
 	$resourceConstraints=$iso19139->createElement("gmd:resourceConstraints");
 	$MD_LegalConstraints=$iso19139->createElement("gmd:MD_LegalConstraints");
 	$accessConstraints=$iso19139->createElement("gmd:accessConstraints");
@@ -689,47 +676,87 @@
 	$MD_LegalConstraints->appendChild($otherConstraints);
 	$resourceConstraints->appendChild($MD_LegalConstraints);
 		
-	$SV_ServiceIdentification->appendChild($resourceConstraints);
-	//service type
-	//<srv:serviceType>
-    	//	<gco:LocalName>view</gco:LocalName>
-	//</srv:serviceType>
-	$serviceType=$iso19139->createElement("srv:serviceType");
-	$localName=$iso19139->createElement("gco:LocalName");
-	$serviceTypeText=$iso19139->createTextNode("view");
-	$localName->appendChild($serviceTypeText);
-	$serviceType->appendChild($localName);
-	$SV_ServiceIdentification->appendChild($serviceType);
+	$MD_DataIdentification->appendChild($resourceConstraints);
+	//Spatial Resolution
+/* Example
+<gmd:spatialResolution><gmd:MD_Resolution><gmd:distance><gco:Distance uom="m">3.0</gco:Distance></gmd:distance></gmd:MD_Resolution></gmd:spatialResolution>
+*/
+	$spatialResolution=$iso19139->createElement("spatialResolution");
+	$MD_Resolution=$iso19139->createElement("gmd:MD_Resolution");
+	
+	if ($mb_metadata['spatial_res_type'] == 'groundDistance') {
+		$distance = $iso19139->createElement("gmd:distance");
+		$Distance = $iso19139->createElement("gmd:Distance");
+		$Distance->setAttribute("uom", "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/uom/ML_gmxUom.xml#m");
+		$DistanceText=$iso19139->createTextNode($mb_metadata['spatial_res_value']);
+		$Distance->appendChild($DistanceText);
+		$distance->appendChild($Distance);
+		$MD_Resolution->appendChild($distance);
+	} else { //will be scaleDenominator
+		/*<gmd:equivalentScale>
+	<gmd:MD_RepresentativeFraction>
+	<gmd:denominator>
+	<gco:Integer>50000</gco:Integer>
+	</gmd:denominator>
+	</gmd:MD_RepresentativeFraction>
+	</gmd:equivalentScale>*/
+		$equivalentScale = $iso19139->createElement("gmd:equivalentScale");
+		$MD_RepresentativeFraction = $iso19139->createElement("gmd:MD_RepresentativeFraction");
+		$denominator = $iso19139->createElement("gmd:denominator");
+		$Integer = $iso19139->createElement("gco:Integer");
+		$IntegerText=$iso19139->createTextNode($mb_metadata['spatial_res_value']);
+		$Integer->appendChild($IntegerText);
+		$denominator->appendChild($Integer);
+		$MD_RepresentativeFraction->appendChild($denominator);
+		$equivalentScale->appendChild($MD_RepresentativeFraction);
+		$MD_Resolution->appendChild($equivalentScale);
+	}
+	$spatialResolution->appendChild($MD_Resolution);
+	$MD_DataIdentification->appendChild($spatialResolution);
 
+	#Part B 1.7 Dataset Language
+	$language=$iso19139->createElement("gmd:language");
+	$LanguageCode=$iso19139->createElement("gmd:LanguageCode");
+	$LanguageCodeText=$iso19139->createTextNode('ger');
+	$LanguageCode->appendChild($LanguageCodeText);
+	$language->appendChild($LanguageCode);
+	$MD_DataIdentification->appendChild($language);
 
+/*
+<gmd:topicCategory>
+<gmd:MD_TopicCategoryCode>imageryBaseMapsEarthCover</gmd:MD_TopicCategoryCode>
+</gmd:topicCategory>
+*/
+	#Topic Category B 2.1 - not needed for services
 
-	$serviceTypeVersion=$iso19139->createElement("srv:serviceTypeVersion");
-	$serviceTypeVersion_cs=$iso19139->createElement("gco:CharacterString");
-	$serviceTypeVersionText=$iso19139->createTextNode("1.1.1");
+	//read keywords for resource out of the database:
+	$sql = "SELECT 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);
+	$t = array('i');
+	$res = db_prep_query($sql,$v,$t);
+	$e = new mb_notice("look for topic: ");
+	$countTopic = 0;
+	while ($row = db_fetch_array($res)) {
+		$e = new mb_exception("topic cat found!");
+		$topicCategory=$iso19139->createElement("gmd:topicCategory");
+		$MD_TopicCategoryCode=$iso19139->createElement("gmd:MD_TopicCategoryCode");
+		$MD_TopicCategoryText=$iso19139->createTextNode($row['md_topic_category_code_en']);
+		$MD_TopicCategoryCode->appendChild($MD_TopicCategoryText);
+		$topicCategory->appendChild($MD_TopicCategoryCode);
+		$MD_DataIdentification->appendChild($topicCategory);
+		$countTopic++;
+	}
+	$e = new mb_exception("count topic: ".$countTopic);
+	if ($countTopic == 0) {
+		$e = new mb_exception("no topic cat found!");
+		$topicCategory=$iso19139->createElement("gmd:topicCategory");
+		$MD_TopicCategoryCode=$iso19139->createElement("gmd:MD_TopicCategoryCode");
+		$MD_TopicCategoryText=$iso19139->createTextNode("no category defined till now!");
+		$MD_TopicCategoryCode->appendChild($MD_TopicCategoryText);
+		$topicCategory->appendChild($MD_TopicCategoryCode);
+		$MD_DataIdentification->appendChild($topicCategory);
+	}
 
-	$serviceTypeVersion_cs->appendChild($serviceTypeVersionText);
-	$serviceTypeVersion->appendChild($serviceTypeVersion_cs);
-	$SV_ServiceIdentification->appendChild($serviceTypeVersion);
-
-
-	# Part B 1.7 Dataset Language
-	#if(isset($detail_array['t01_object.data_language'])){
-		#$language=$iso19139->createElement("gmd:language");
-		#$LanguageCode=$iso19139->createElement("gmd:LanguageCode");
-		#$LanguageCodeText=$iso19139->createTextNode($detail_array['t01_object.data_language']);
-		#$LanguageCode->appendChild($LanguageCodeText);
-		#$language->appendChild($LanguageCode);
-		#$SV_ServiceIdentification->appendChild($language);
-	#}
-	#Topic Category B 2.1 - not needed for services
-	#if(isset($detail_array['t011_obj_geo_topic_cat.topic_category'])){
-		#$topicCategory=$iso19139->createElement("gmd:topicCategory");
-		#$MD_TopicCategoryCode=$iso19139->createElement("gmd:MD_TopicCategoryCode");
-		#$MD_TopicCategoryText=$iso19139->createTextNode($detail_array['t011_obj_geo_topic_cat.topic_category']);
-		#$MD_TopicCategoryCode->appendChild($MD_TopicCategoryText);
-		#$topicCategory->appendChild($MD_TopicCategoryCode);
-		#$SV_ServiceIdentification->appendChild($topicCategory);
-	#}
 	#Geographical Extent
 	$bbox = array();
 	//initialize if no extent is defined in the database
@@ -740,7 +767,7 @@
 	if (isset($mapbenderMetadata['bbox']) & ($mapbenderMetadata['bbox'] != '')) {
 		$bbox = explode(',',$mapbenderMetadata['bbox']);
 	}
-	$extent=$iso19139->createElement("srv:extent");
+	$extent=$iso19139->createElement("gmd:extent");
 	$EX_Extent=$iso19139->createElement("gmd:EX_Extent");
 	$geographicElement=$iso19139->createElement("gmd:geographicElement");
 	$EX_GeographicBoundingBox=$iso19139->createElement("gmd:EX_GeographicBoundingBox");
@@ -781,74 +808,31 @@
 	$EX_Extent->appendChild($geographicElement);
 	$extent->appendChild($EX_Extent);
 
-	$SV_ServiceIdentification->appendChild($extent);
+	$MD_DataIdentification->appendChild($extent);
 
+	$identificationInfo->appendChild($MD_DataIdentification);
 
-#to the things which have to be done for integrating the service into a client like portalu ... they have defined another location to put the GetCap URL than INSPIRE does it
-
-	$containsOperation=$iso19139->createElement("srv:containsOperations");
-	$SV_OperationMetadata=$iso19139->createElement("srv:SV_OperationMetadata");
-
-
-	$operationName=$iso19139->createElement("srv:operationName");
-	$operationName_cs=$iso19139->createElement("gco:CharacterString");
-
-	$operationNameText=$iso19139->createTextNode("GetCapabilities");
-	
-	$operationName_cs->appendChild($operationNameText);
-	$operationName->appendChild($operationName_cs);
-
-//srv DCP **************************************
-	$DCP=$iso19139->createElement("srv:DCP");
-	$DCPList=$iso19139->createElement("srv:DCPList");
-	$DCPList->setAttribute("codeList", "DCPList");
-	$DCPList->setAttribute("codeListValue", "WebService");
-
-
-	$DCP->appendChild($DCPList);
-	
-//connectPoint **********************************
-	$connectPoint=$iso19139->createElement("srv:connectPoint");
-	
-	$CI_OnlineResource=$iso19139->createElement("gmd:CI_OnlineResource");
-
-	$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']."");
-	}
-	else {
-		$gmd_URLText=$iso19139->createTextNode("https://".$_SERVER['HTTP_HOST']."/http_auth/".$mapbenderMetadata['layer_id']."?");
-	}
-	$gmd_URL->appendChild($gmd_URLText);
-	$gmd_linkage->appendChild($gmd_URL);
-	$CI_OnlineResource->appendChild($gmd_linkage);
-	$connectPoint->appendChild($CI_OnlineResource);
-
-	$SV_OperationMetadata->appendChild($operationName);
-	$SV_OperationMetadata->appendChild($DCP);
-	$SV_OperationMetadata->appendChild($connectPoint);
-
-	$containsOperation->appendChild($SV_OperationMetadata);
-
-	$SV_ServiceIdentification->appendChild($containsOperation);
-	
-/*
-	$serviceTypeVersion_cs->appendChild($serviceTypeVersionText);
-	$serviceTypeVersion->appendChild($serviceTypeVersion_cs);
-	$SV_ServiceIdentification->appendChild($serviceTypeVersion);
-*/
-	$identificationInfo->appendChild($SV_ServiceIdentification);
 //distributionInfo
 	$gmd_distributionInfo=$iso19139->createElement("gmd:distributionInfo");
 	$MD_Distribution=$iso19139->createElement("gmd:MD_Distribution");
 	$gmd_distributionFormat=$iso19139->createElement("gmd:distributionFormat");
 	$MD_Format=$iso19139->createElement("gmd:MD_Format");
 	$gmd_name=$iso19139->createElement("gmd:name");
+	$MD_FormatName_cs=$iso19139->createElement("gco:CharacterString");	
+	$MD_FormatNameText=$iso19139->createTextNode($mb_metadata['format']);
+
 	$gmd_version=$iso19139->createElement("gmd:version");
-	$gmd_name->setAttribute("gco:nilReason", "inapplicable");
-	$gmd_version->setAttribute("gco:nilReason", "inapplicable");
+	$MD_FormatVersion_cs=$iso19139->createElement("gco:CharacterString");
+	$MD_FormatVersionText=$iso19139->createTextNode("unkown");
+
+	$MD_FormatName_cs->appendChild($MD_FormatNameText);
+	$MD_FormatVersion_cs->appendChild($MD_FormatVersionText);
+
+	$gmd_name->appendChild($MD_FormatName_cs);
+	$gmd_version->appendChild($MD_FormatVersion_cs);
+	//$gmd_name->setAttribute("gco:nilReason", "inapplicable");
+	//$gmd_version->setAttribute("gco:nilReason", "inapplicable");
+
 	$gmd_transferOptions=$iso19139->createElement("gmd:transferOptions");
 	$MD_DigitalTransferOptions=$iso19139->createElement("gmd:MD_DigitalTransferOptions");
 	$gmd_onLine=$iso19139->createElement("gmd:onLine");
@@ -866,49 +850,28 @@
 	}
 	$gmd_URL->appendChild($gmd_URLText);
 	$gmd_linkage->appendChild($gmd_URL);
-	$CI_OnlineResource->appendChild($gmd_linkage);
-
-	//append things which geonetwork needs to invoke service/layer or what else? - Here the name of the layer and the protocol seems to be needed?
-	//a problem will occur, if the link to get map is not the same as the link to get caps? So how can we handle this? It seems to very silly! 
-	$gmdProtocol = $iso19139->createElement("gmd:protocol");
-	$gmdProtocol_cs = $iso19139->createElement("gco:CharacterString");
-	$gmdProtocolText = $iso19139->createTextNode("OGC:WMS-1.1.1-http-get-map");//for ever 'OGC:WMS-1.1.1-http-get-map'
-
-	$gmdName=$iso19139->createElement("gmd:name");
-	$gmdName_cs=$iso19139->createElement("gco:CharacterString");
-	$gmdNameText=$iso19139->createTextNode($mapbenderMetadata['layer_name']); //Layername?
-
-	$gmdDescription = $iso19139->createElement("gmd:description");
-	$gmdDescription_cs = $iso19139->createElement("gco:CharacterString");
-	$gmdDescriptionText = $iso19139->createTextNode($mapbenderMetadata['layer_abstract']);//Layer Abstract
-
-	$gmdProtocol_cs->appendChild($gmdProtocolText);
-	$gmdProtocol->appendChild($gmdProtocol_cs);
-	$CI_OnlineResource->appendChild($gmdProtocol);
-
-
-
-	$gmdName_cs->appendChild($gmdNameText);
-	$gmdName->appendChild($gmdName_cs);
-	$CI_OnlineResource->appendChild($gmdName);
-
-	$gmdDescription_cs->appendChild($gmdDescriptionText);
-	$gmdDescription->appendChild($gmdDescription_cs);
-	$CI_OnlineResource->appendChild($gmdDescription);
-	
+	$CI_OnlineResource->appendChild($gmd_linkage);	
 //***********************************************************************************
 	$gmd_onLine->appendChild($CI_OnlineResource);
 	$MD_DigitalTransferOptions->appendChild($gmd_onLine);
 	$gmd_transferOptions->appendChild($MD_DigitalTransferOptions);
+
 	$MD_Format->appendChild($gmd_name);
 	$MD_Format->appendChild($gmd_version);
+
+
+
+
 	$gmd_distributionFormat->appendChild($MD_Format);
+
 	$MD_Distribution->appendChild($gmd_distributionFormat);
+
 	$MD_Distribution->appendChild($gmd_transferOptions);
 	$gmd_distributionInfo->appendChild($MD_Distribution);
 	//dataQualityInfo
 	$gmd_dataQualityInfo=$iso19139->createElement("gmd:dataQualityInfo");
 	$DQ_DataQuality=$iso19139->createElement("gmd:DQ_DataQuality");
+
 	$gmd_scope=$iso19139->createElement("gmd:scope");
 	$DQ_Scope=$iso19139->createElement("gmd:DQ_Scope");
 	$gmd_level=$iso19139->createElement("gmd:level");
@@ -921,6 +884,26 @@
 	$DQ_Scope->appendChild($gmd_level);
 	$gmd_scope->appendChild($DQ_Scope);
 	$DQ_DataQuality->appendChild($gmd_scope);
+/*
+<gmd:lineage>
+<gmd:LI_Lineage>
+<gmd:statement>
+<gco:CharacterString>test</gco:CharacterString>
+</gmd:statement>
+</gmd:LI_Lineage>
+</gmd:lineage>
+*/
+	$lineage=$iso19139->createElement("gmd:lineage");
+	$LI_Lineage=$iso19139->createElement("gmd:LI_Lineage");
+	$statement=$iso19139->createElement("gmd:statement");
+	$statement_cs=$iso19139->createElement("gco:CharacterString");
+	$statementText=$iso19139->createTextNode($mb_metadata['lineage']);
+	$lineage->appendChild($LI_Lineage);
+	$LI_Lineage->appendChild($statement);
+	$statement->appendChild($statement_cs);
+	$statement_cs->appendChild($statementText);
+	$DQ_DataQuality->appendChild($lineage);
+
 	//gmd:report in dataQualityInfo
 	$gmd_report=$iso19139->createElement("gmd:report");
 	$DQ_DomainConsistency=$iso19139->createElement("gmd:DQ_DomainConsistency");
@@ -930,12 +913,12 @@
 	$CI_Citation=$iso19139->createElement("gmd:CI_Citation");
 	$gmd_title=$iso19139->createElement("gmd:title");
 	$gmd_title_cs=$iso19139->createElement("gco:CharacterString");
-	$gmd_titleText=$iso19139->createTextNode("Service Abstract Suite"); //TODO put in the inspire test suites from mb database!
+	$gmd_titleText=$iso19139->createTextNode("INSPIRE Metadata Regulation"); //TODO put in the inspire test suites from mb database!
 	$gmd_date=$iso19139->createElement("gmd:date");
 	$CI_Date=$iso19139->createElement("gmd:CI_Date");
 	$gmd_date_2=$iso19139->createElement("gmd:date");
 	$gco_Date=$iso19139->createElement("gco:Date");
-	$gco_DateText=$iso19139->createTextNode("2010-03-10"); //TODO put in the info from database
+	$gco_DateText=$iso19139->createTextNode("2008-12-03"); //TODO put in the info from database
 	
 	$gmd_dateType=$iso19139->createElement("gmd:dateType");
 	$CI_DateTypeCode=$iso19139->createElement("gmd:CI_DateTypeCode");
@@ -975,6 +958,7 @@
 	$DQ_DomainConsistency->appendChild($gmd_result);
 	$gmd_report->appendChild($DQ_DomainConsistency);
 	$DQ_DataQuality->appendChild($gmd_report);
+
 	$gmd_dataQualityInfo->appendChild($DQ_DataQuality);
 	//$MD_ScopeCode->setAttribute("codeListValue", "service");
 	$MD_Metadata->appendChild($identificationInfo);

Modified: trunk/mapbender/http/php/mod_layerISOMetadata.php
===================================================================
--- trunk/mapbender/http/php/mod_layerISOMetadata.php	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/php/mod_layerISOMetadata.php	2011-05-09 13:04:48 UTC (rev 7799)
@@ -658,9 +658,45 @@
 
 	$SV_ServiceIdentification->appendChild($extent);
 
+	//read all metadata entries:
+	$i=0;
+	$sql = <<<SQL
 
-#to the things which have to be done for integrating the service into a client like portalu ... they have defined another location to put the GetCap URL than INSPIRE does it
+SELECT metadata_id, uuid, link, linktype, md_format, origin, datasetid FROM mb_metadata 
+INNER JOIN (SELECT * from ows_relation_metadata 
+WHERE fkey_layer_id = $recordId ) as relation ON 
+mb_metadata.metadata_id = relation.fkey_metadata_id WHERE mb_metadata.origin IN ('capabilities','external','metador')
 
+SQL;
+	$res_metadataurl = db_query($sql);
+	if ($res_metadataurl != false) {
+		$couplingType=$iso19139->createElement("srv:couplingType");
+		$SV_CouplingType=$iso19139->createElement("srv:SV_CouplingType");
+		$SV_CouplingType->setAttribute("codeList", "SV_CouplingType");
+		$SV_CouplingType->setAttribute("codeListValue", "tight");
+		$couplingType->appendChild($SV_CouplingType);
+		$SV_ServiceIdentification->appendChild($couplingType);
+	}
+	
+	//declare coupling type:
+	/*example from guidance paper:
+<srv:couplingType>
+	<srv:SV_CouplingType codeList="SV_CouplingType" codeListValue="tight"/>
+</srv:couplingType>
+
+	$couplingType=$iso19139->createElement("srv:couplingType");
+	$SV_CouplingType=$iso19139->createElement("srv:SV_CouplingType");
+	$SV_CouplingType->setAttribute("codeList", "SV_CouplingType");
+	$SV_CouplingType->setAttribute("codeListValue", "tight");
+	
+
+<srv:couplingType gco:nilReason="missing"/>
+<srv:containsOperations gco:nilReason="missing"/>
+<srv:operatesOn xlink:href="http://image2000.jrc.it#image2000_1_nl2_multi"/>*/
+	
+	
+	#to the things which have to be done for integrating the service into a client like portalu ... they have defined another location to put the GetCap URL than INSPIRE does it
+
 	$containsOperation=$iso19139->createElement("srv:containsOperations");
 	$SV_OperationMetadata=$iso19139->createElement("srv:SV_OperationMetadata");
 
@@ -708,7 +744,34 @@
 	$containsOperation->appendChild($SV_OperationMetadata);
 
 	$SV_ServiceIdentification->appendChild($containsOperation);
+	//fill in operatesOn fields with datasetid if given
+	/*<srv:operatesOn xlink:href="http://image2000.jrc.it#image2000_1_nl2_multi"/>*/
+	while ($row_metadata = db_fetch_array($res_metadataurl)) {
+		
+			switch ($row_metadata['origin']) {
+				case 'capabilities':
+					$operatesOn=$iso19139->createElement("srv:operatesOn");
+					$operatesOn->setAttribute("xlink:href", $row_metadata['datasetid']);
+					$SV_ServiceIdentification->appendChild($operatesOn);
+				break;
+				case 'metador':
+					$operatesOn=$iso19139->createElement("srv:operatesOn");
+					$operatesOn->setAttribute("xlink:href", "http://www.geoportal.rlp.de#".$row_metadata['uuid']);
+					$SV_ServiceIdentification->appendChild($operatesOn);
+				break;
+				case 'external':
+					$operatesOn=$iso19139->createElement("srv:operatesOn");
+					$operatesOn->setAttribute("xlink:href", $row_metadata['uuid']);
+					$SV_ServiceIdentification->appendChild($operatesOn);
+				break;
+				default:
+				break;
+			}
+		}
 	
+
+
+	
 /*
 	$serviceTypeVersion_cs->appendChild($serviceTypeVersionText);
 	$serviceTypeVersion->appendChild($serviceTypeVersion_cs);

Modified: trunk/mapbender/http/php/wms.php
===================================================================
--- trunk/mapbender/http/php/wms.php	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/php/wms.php	2011-05-09 13:04:48 UTC (rev 7799)
@@ -20,7 +20,6 @@
 require_once(dirname(__FILE__)."/../../core/globalSettings.php");
 require_once(dirname(__FILE__)."/../classes/class_layer_monitor.php");
 
-
 //
 // make all parameters available as upper case
 //
@@ -41,6 +40,8 @@
 
 $mapbenderMetadaUrl = $_SERVER['HTTP_HOST']."/mapbender/php/mod_showMetadata.php?resource=layer&id=";
 $inspireServiceMetadataUrl =  $_SERVER['HTTP_HOST']."/mapbender/php/mod_layerISOMetadata.php?SERVICE=WMS&outputFormat=iso19139&Id=";
+$mapbenderMetadataUrlUrl = $_SERVER['HTTP_HOST']."/mapbender/php/mod_dataISOMetadata.php?outputFormat=iso19139&id=";
+
 //http://www.geoportal.rlp.de/mapbender/php/mod_layerISOMetadata.php?SERVICE=WMS&outputFormat=iso19139&Id=24615
 if (isset($_SERVER["HTTPS"])){
 	$urlPrefix = "https://";
@@ -49,6 +50,7 @@
 }
 $mapbenderMetadataUrl = $urlPrefix.$mapbenderMetadataUrl;
 $inspireServiceMetadataUrl = $urlPrefix.$inspireServiceMetadataUrl;
+$mapbenderMetadataUrlUrl = $urlPrefix.$mapbenderMetadataUrlUrl;
 
 $con = db_connect(DBSERVER,OWNER,PW);
 db_select_db(DB,$con);
@@ -172,8 +174,6 @@
 $doc->encoding = 'UTF-8';
 $doc->standalone = false;
 
-
-
 #Check for existing content in database
 #to be adopted TODO armin 
 function validate ($contactInformation_column) {
@@ -185,7 +185,6 @@
 	}
 	return $contactinformationcheck;
 }
- 
 	
 #Creating the "WMT_MS_Capabilities" node
 $wmt_ms_capabilities = $doc->createElement("WMT_MS_Capabilities");
@@ -1019,57 +1018,99 @@
 	}
 	
 	# Creating Metadata Node
-	
-	$metadataUrl = $doc->createElement("MetadataURL");
-	$metadataUrl = $sub_layer->appendChild($metadataUrl);
-	$metadataUrl->setAttribute('type', "TC211");
-	
-	$format = $doc->createElement("Format");
-    $format = $metadataUrl->appendChild($format);
-    $formatText = $doc->createTextNode('text/html');
-    $formatText = $format->appendChild($formatText); 
+	//read out all metadata entries for specific layer
 
-	if ($wms_row['wms_owsproxy'] <> "" AND $wms_row['wms_owsproxy'] <> NULL) {
-		$onlineResource = $doc->createElement("OnlineResource");
-	   	$onlineResource = $metadataUrl->appendChild($onlineResource);
-	   	$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
-		$onlineResource->setAttribute("xlink:href", OWSPROXY."/".session_id()."/".$wms_row["wms_owsproxy"]."?");
-		$onlineResource->setAttribute("xlink:type", "simple");
-	}
-	else {
-		if ($sub_layer_row['layer_metadataurl'] <> "" AND $sub_layer_row['layer_metadataurl'] <> NULL) {
-	    	$onlineResource = $doc->createElement("OnlineResource");
-	    	$onlineResource = $metadataUrl->appendChild($onlineResource);
-			$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
-			$onlineResource->setAttribute("xlink:href", $sub_layer_row['layer_metadataurl']);
-			//TODO set metadataUrl from mb_database
-			$onlineResource->setAttribute("xlink:type", "simple");
-	    }
-else
-{
- $onlineResource = $doc->createElement("OnlineResource");
-                $onlineResource = $metadataUrl->appendChild($onlineResource);
-                        $onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
-                        //$onlineResource->setAttribute("xlink:href", "http://www.geoportal.rlp.de/mapbender/x_geoportal/mod_layerMetadata.php?id=".$sub_layer_row['layer_id']);
-                        $onlineResource->setAttribute("xlink:href", $mapbenderMetadaUrl.$sub_layer_row['layer_id']);
-			$onlineResource->setAttribute("xlink:type", "simple");
 
-}
+	$subLayerId = $sub_layer_row['layer_id'];
+	$sql = <<<SQL
 
+SELECT metadata_id, uuid, link, linktype, md_format, origin FROM mb_metadata 
+INNER JOIN (SELECT * from ows_relation_metadata 
+WHERE fkey_layer_id = $subLayerId ) as relation ON 
+mb_metadata.metadata_id = relation.fkey_metadata_id WHERE mb_metadata.origin IN ('capabilities','external','metador')
 
+SQL;
+	$e = new mb_exception("layerid: ".$sub_layer_row['layer_id']);
+	$i = 0;
+	$res_metadata = db_query($sql);
+
+	$e = new mb_exception("row size: ".count($row_metadata));
+	while ($row_metadata = db_fetch_array($res_metadata)) {
+		$e = new mb_exception("i: ".$i);
+		//push entries into xml structure	
+		//check for kind of link - push the right one into the link field	
+		switch ($row_metadata['origin']) {
+			case 'capabilities':
+				$metadataUrl = $doc->createElement("MetadataURL");
+				$metadataUrl = $sub_layer->appendChild($metadataUrl);
+				$metadataUrl->setAttribute('type', $row_metadata['linktype']);
+				$format = $doc->createElement("Format");
+    				$format = $metadataUrl->appendChild($format);
+    				$formatText = $doc->createTextNode($row_metadata['md_format']);
+    				$formatText = $format->appendChild($formatText);
+				$onlineResource = $doc->createElement("OnlineResource");
+	    			$onlineResource = $metadataUrl->appendChild($onlineResource);
+				$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+				$onlineResource->setAttribute("xlink:href", $row_metadata['link']);
+			break;
+			case 'external':
+				$metadataUrl = $doc->createElement("MetadataURL");
+				$metadataUrl = $sub_layer->appendChild($metadataUrl);
+				$metadataUrl->setAttribute('type', 'ISO19115:2003');
+				$format = $doc->createElement("Format");
+    				$format = $metadataUrl->appendChild($format);
+    				$formatText = $doc->createTextNode("text/xml");
+    				$formatText = $format->appendChild($formatText);
+				$onlineResource = $doc->createElement("OnlineResource");
+	    			$onlineResource = $metadataUrl->appendChild($onlineResource);
+				$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+				$onlineResource->setAttribute("xlink:href", $row_metadata['link']);
+				$onlineResource->setAttribute("xlink:href", $mapbenderMetadataUrlUrl.$row_metadata['uuid']);
+			break;
+			case 'metador':
+				$metadataUrl = $doc->createElement("MetadataURL");
+				$metadataUrl = $sub_layer->appendChild($metadataUrl);
+				$metadataUrl->setAttribute('type', 'ISO19115:2003');
+				$format = $doc->createElement("Format");
+    				$format = $metadataUrl->appendChild($format);
+    				$formatText = $doc->createTextNode("text/xml");
+    				$formatText = $format->appendChild($formatText);
+				$onlineResource = $doc->createElement("OnlineResource");
+	    			$onlineResource = $metadataUrl->appendChild($onlineResource);
+				$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+				$onlineResource->setAttribute("xlink:href", $row_metadata['link']);
+				$onlineResource->setAttribute("xlink:href", $mapbenderMetadataUrlUrl.$row_metadata['uuid']);
+			break;
+			default:
+				$metadataUrl = $doc->createElement("MetadataURL");
+				$metadataUrl = $sub_layer->appendChild($metadataUrl);
+				$metadataUrl->setAttribute('type', 'ISO19115:2003');
+				$format = $doc->createElement("Format");
+    				$format = $metadataUrl->appendChild($format);
+    				$formatText = $doc->createTextNode("text/xml");
+    				$formatText = $format->appendChild($formatText);
+				$onlineResource = $doc->createElement("OnlineResource");
+	    			$onlineResource = $metadataUrl->appendChild($onlineResource);
+				$onlineResource->setAttribute("xmlns:xlink", "http://www.w3.org/1999/xlink" );
+				$onlineResource->setAttribute("xlink:href", $row['link']);
+				$onlineResource->setAttribute("xlink:href", "Url not given - please check your registry!");
+			break;
+		}
+		$onlineResource->setAttribute("xlink:type", "simple");
+		//Add linkage to Capabilities
+		$i++;
+		$e = new mb_exception("i: ".$i);
 	}
+	
+
 	# Creating DataURL Node
 	$dataUrl = $doc->createElement("DataURL");
 	$dataUrl = $sub_layer->appendChild($dataUrl);
-	
-	
-	
 	$format = $doc->createElement("Format");
-    $format = $dataUrl->appendChild($format);
-    $formatText = $doc->createTextNode('text/html');
-    $formatText = $format->appendChild($formatText); 
+    	$format = $dataUrl->appendChild($format);
+    	$formatText = $doc->createTextNode('text/html');
+   	$formatText = $format->appendChild($formatText); 
 
-
 	if($wms_row['wms_owsproxy'] <> "" AND $wms_row['wms_owsproxy'] <> NULL)
 	{
 		$onlineResource = $doc->createElement("OnlineResource");

Modified: trunk/mapbender/http/plugins/mb_metadata_layer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.js	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.js	2011-05-09 13:04:48 UTC (rev 7799)
@@ -103,13 +103,13 @@
 		//for size of md_metadata records:
 		for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
 			if (obj.md_metadata.origin[i] == "capabilities") {
-				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='"+obj.md_metadata.link[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td></td></tr>").appendTo($("#metadataTable"));
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
 			}
 			if (obj.md_metadata.origin[i] == "external") {
-				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='"+obj.md_metadata.link[i]+"'>"+obj.md_metadata.uuid[i]+"</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
 			}
 			if (obj.md_metadata.origin[i] == "metador") {
-				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='"+obj.md_metadata.link[i]+"'>"+obj.md_metadata.uuid[i]+"</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
 			}
 		}
 		$("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2011-05-09 13:04:48 UTC (rev 7799)
@@ -626,7 +626,7 @@
 		}
 		$sql = <<<SQL
 
-UPDATE mb_metadata SET link = $2, title = $3, abstract = $4, format = $5, ref_system = $6, export2csw = $7, inspire_top_consistence = $8, tmp_reference_1 = $9, tmp_reference_2 = $10, lineage = $11, spatial_res_type = $12, spatial_res_value = $13, inspire_charset = $14 WHERE metadata_id = $1
+UPDATE mb_metadata SET link = $2, title = $3, abstract = $4, format = $5, ref_system = $6, export2csw = $7, inspire_top_consistence = $8, tmp_reference_1 = $9, tmp_reference_2 = $10, lineage = $11, spatial_res_type = $12, spatial_res_value = $13, inspire_charset = $14, changedate = now() WHERE metadata_id = $1
 
 SQL;
 		$v = array($metadataId, $data->link, $data->title, $data->abstract, $data->format, $data->ref_system, $data->export2csw, $data->inspire_top_consistence, $data->tmp_reference_1, $data->tmp_reference_2, $data->lineage, $data->spatial_res_type, $data->spatial_res_value, $data->inspire_charset);
@@ -734,7 +734,7 @@
 		$dbInsertFailed = false;
 		$sql = <<<SQL
 
-INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw, inspire_top_consistence, tmp_reference_1, tmp_reference_2, lineage, spatial_res_type, spatial_res_value, inspire_charset) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15)
+INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw, inspire_top_consistence, tmp_reference_1, tmp_reference_2, lineage, spatial_res_type, spatial_res_value, inspire_charset, createdate) VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11, $12, $13, $14, $15, now())
 
 SQL;
 		$v = array($link, $uuid, $origin, $title, $abstract, $format, $ref_system, $export2csw,$inspire_top_consistence,$tmp_reference_2,$tmp_reference_2,$lineage,$spatial_res_type,$spatial_res_value,$inspire_charset);

Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2011-05-09 13:04:48 UTC (rev 7799)
@@ -132,13 +132,13 @@
 		//for size of md_metadata records:
 		for (i=0;i<obj.md_metadata.metadata_id.length;i++) {
 			if (obj.md_metadata.origin[i] == "capabilities") {
-				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='"+obj.md_metadata.link[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td></td></tr>").appendTo($("#metadataTable"));
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/server_map.png' title='capabilities'/></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td></td></tr>").appendTo($("#metadataTable"));
 			}
 			if (obj.md_metadata.origin[i] == "external") {
-				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='"+obj.md_metadata.link[i]+"'>"+obj.md_metadata.uuid[i]+"</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/osgeo_graphics/geosilk/link.png' title='linkage'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
 			}
 			if (obj.md_metadata.origin[i] == "metador") {
-				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='"+obj.md_metadata.link[i]+"'>"+obj.md_metadata.uuid[i]+"</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
+				$("<tr class='metadataEntry'><td>"+obj.md_metadata.metadata_id[i]+"</td><td><img src='../img/gnome/edit-select-all.png' title='metadata'/><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"' target='_blank'>"+obj.md_metadata.uuid[i]+"</a></td><td><a href='../php/mod_dataISOMetadata.php?outputFormat=iso19139&id="+obj.md_metadata.uuid[i]+"&validate=true' target='_blank'>validate</a></td><td><img  class='' title='edit' src='../img/pencil.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",false);return false;'/></td><td><img class='' title='delete' src='../img/cross.png' onclick='deleteAddedMetadata("+obj.md_metadata.metadata_id[i]+","+layerId+");return false;'/></td></tr>").appendTo($("#metadataTable"));
 			}
 		}
 		$("<img class='metadataEntry' title='new' src='../img/add.png' onclick='initMetadataAddon("+obj.md_metadata.metadata_id[i]+","+layerId+",true);return false;'/>").appendTo($("#metadataTable"));

Modified: trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql
===================================================================
--- trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql	2011-05-09 12:09:06 UTC (rev 7798)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql	2011-05-09 13:04:48 UTC (rev 7799)
@@ -1914,7 +1914,7 @@
 -- add column for mb_metadata
 ALTER TABLE mb_metadata ADD COLUMN lineage text;
 ALTER TABLE mb_metadata ALTER COLUMN spatial_res_type TYPE varchar(20);
-
+ALTER TABLE mb_metadata ADD COLUMN datasetid text; --needed for service data coupling!
 -- activate datepicker for forms
 INSERT INTO gui_element(fkey_gui_id, e_id, e_pos, e_public, e_comment, e_title, e_element, e_src, e_attributes, e_left, e_top, e_width, e_height, e_z_index, e_more_styles, e_content, e_closetag, e_js_file, e_mb_mod, e_target, e_requires, e_url) VALUES('admin_wms_metadata','jq_ui_datepicker',5,1,'Datepicker from jQuery UI framework','','','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','','../plugins/jq_ui_datepicker.js','../extensions/jquery-ui-1.8.1.custom/development-bundle/ui/jquery.ui.datepicker.js','','jq_ui','');
 



More information about the Mapbender_commits mailing list