[Mapbender-commits] r7796 - in trunk/mapbender: conf http/plugins resources/db/pgsql/UTF-8/update

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Thu May 5 15:55:50 EDT 2011


Author: armin11
Date: 2011-05-05 12:55:50 -0700 (Thu, 05 May 2011)
New Revision: 7796

Modified:
   trunk/mapbender/conf/mapbender.conf-dist
   trunk/mapbender/http/plugins/mb_metadata_addon.php
   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 enhancement of simple metadataurl editor - validation ...

Modified: trunk/mapbender/conf/mapbender.conf-dist
===================================================================
--- trunk/mapbender/conf/mapbender.conf-dist	2011-05-05 07:11:51 UTC (rev 7795)
+++ trunk/mapbender/conf/mapbender.conf-dist	2011-05-05 19:55:50 UTC (rev 7796)
@@ -184,7 +184,7 @@
 # srs like e.g. geoserver offers. The array should include all the srs which are used in the mapbender installation and 
 # which are usefull for the special community for which the installation was done (local-sdi, INSPIRE, ...) 
 # --------------------------------------------
-#define("SRS_ARRAY", "4326, 31466, 31467, 31468, 25832");
+#define("SRS_ARRAY", "4326,31466,31467,31468,25832");
 
 # --------------------------------------------
 # define a wrapper for index.php/login.php to use e.g. the get api when integrated in external applications like cms

Modified: trunk/mapbender/http/plugins/mb_metadata_addon.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_addon.php	2011-05-05 07:11:51 UTC (rev 7795)
+++ trunk/mapbender/http/plugins/mb_metadata_addon.php	2011-05-05 19:55:50 UTC (rev 7796)
@@ -23,139 +23,94 @@
 	</fieldset>
 	<!--fieldset for metadata form-->
 	<fieldset id="simple_metadata_editor" name="simple_metadata_editor" type="hidden"  style="display: none">
-		<legend><?php echo _mb("Simple metadata editor");?> <img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" /></legend>
-		<p>
-			<label for=""><?php echo _mb("MD Title");?>:</label>
-			<img class="metadata_img" src="../img/questionmark.png" alt="" />
-			<span class="metadata_span"></span>
-			<input name="title" id="title"/>
-			<img class="metadata_img" src=""></img>
-			<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-		</p>
-		<p>
-		<label for=""><?php echo _mb("MD Abstract");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<span class="metadata_span"></span>
-		<input name="abstract" id="abstract"/>
-		<img class="metadata_img" src=""></img>
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
-	<p>
-		<label for=""><?php echo _mb("MD Lineage");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<span class="metadata_span"></span>
-		<input name="lineage" id="lineage"/>
-		<img class="metadata_img" src=""></img>
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
-	<p>
-		<label for=""><?php echo _mb("MD Temporal Reference");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
-	<p>
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input type="checkbox" name="" value=""> Time
-	</p>
-	<p>
-		<label for=""><?php echo _mb("from");?>:</label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input name="tmp_reference_1" id="tmp_reference_1"/>
-		<img class="metadata_img" src="../img/book.png" alt="" />
-	</p>
-	<p>
-		<label for=""><?php echo _mb("to");?>:</label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input name="tmp_reference_2" id="tmp_reference_2"/>
-		<img class="metadata_img" src="../img/book.png" alt="" />
-	</p>
-	<p>
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input type="checkbox" name="" value=""> <?php echo _mb("Cycling Update");?>
-	</p>
-	<p>	
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<select class="metadata_selectbox" size="2" multiple>
-			<option><?php echo _mb("directly");?></option>
-			<option><?php echo _mb("daily");?></option>
-			<option><?php echo _mb("weekly");?></option>
-			<option><?php echo _mb("yearly");?></option>
+		<legend><?php echo _mb("Simple metadata editor");?></legend>
+		<fieldset>
+			<legend><?php echo _mb("Title");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Help for title");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<input class="required" name="title" id="title"/>
+		</fieldset>
+		<fieldset>
+			<legend><?php echo _mb("Abstract");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Help for abstract");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<input class="required" name="abstract" id="abstract"/>
+		</fieldset>
+		<fieldset>
+			<legend><?php echo _mb("Lineage");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Help for lineage");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<input class="required" name="lineage" id="lineage"/>
+		</fieldset>
+	<fieldset id="tempref" name="tempref">
+		<legend><?php echo _mb("Temporal reference");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Help for temporal reference");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<fieldset id="timespan" name="timespan">
+				<label for=""><?php echo _mb("from");?>:</label>
+				<input class="required hasdatepicker" name="tmp_reference_1" id="tmp_reference_1"/>
+				<label for=""><?php echo _mb("to");?>:</label>
+				<input class="required hasdatepicker" name="tmp_reference_2" id="tmp_reference_2"/>
+		</fieldset>
+		<fieldset id="cyclicupdate" name="cyclicupdate" style="display: none">
+			<p>
+				<label></label>
+				<input type="checkbox" name="" value=""> <?php echo _mb("Cycling Update");?>
+			</p>
+			<p>	
+				<label></label>
+				<select class="metadata_selectbox" size="2" multiple>
+					<option><?php echo _mb("directly");?></option>
+					<option><?php echo _mb("daily");?></option>
+					<option><?php echo _mb("weekly");?></option>
+					<option><?php echo _mb("yearly");?></option>
+				</select>
+			</p>
+		</fieldset>
+	</fieldset>
+	<fieldset id="spatialres">
+		<legend><?php echo _mb("Spatial Resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Help for spatial resolution");?>'}" src="../img/questionmark.png" alt="" /></legend>
+			<label for="groundDistance">
+				<input class="required radioRes" name="spatial_res_type" id="groundDistance" type="radio"/ value="groundDistance" checked="checked">
+			<?php echo _mb("Ground distance in [m]");?>
+			</label>
+			<label for="scaleDenominator">
+				<input class="required radioRes" name="spatial_res_type" id="scaleDenominator" type="radio"/ value="scaleDenominator">
+			<?php echo _mb("Scale denominator [1:X]");?>
+			</label>
+			<!--<label for="spatial_res_type" class="error"><?php echo _mb("Please set the resolution type!");?>-->
+			</label>
+			<label><?php echo _mb("Value of resolution");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Value of spatial resolution in [m] or scale denominator");?>'}" src="../img/questionmark.png" alt="" /></label>
+			<input class="required" name="spatial_res_value" id="spatial_res_value"/>
+	</fieldset>
+	<!-- Dropdown List of CRS which are defined in mapbender.conf. For those CRS the layer extents will be computed by mapbender - this is relevant for INSPIRE.-->
+	<fieldset id="referencesystem">
+		<legend><?php echo _mb("Reference System");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Choose the Coordinate Reference System in which the data is stored");?>'}" src="../img/questionmark.png" alt="" /></legend>
+<?php
+	if (defined('SRS_ARRAY')) {
+		$srs_array = explode(",", SRS_ARRAY);
+		echo '<select class="required ref_system_selectbox" name="ref_system" id="ref_system">';
+		foreach ($srs_array as $epsg) {
+			echo "<option value='" . "EPSG:" .$epsg . "'>" . _mb("EPSG:".$epsg) . "</option>";
+		}
+		echo "</select>";
+		
+	} else {
+		echo '<input name="ref_system" id="ref_system"/>';
+	}
+?>
+	</fieldset>
+	<fieldset id="data_format">
+		<legend><?php echo _mb("Data Format");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Choose the format of the underlying dataset");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<select class="required format_selectbox" id='format' name='format' size="2">
+			<option value="database"><?php echo _mb("Database");?></option>
+			<option value="shapefile"><?php echo _mb("Shape");?></option>
+			<option value="csv"><?php echo _mb("CSV");?></option>
+			<option value="gml"><?php echo _mb("GML");?></option>
 		</select>
-	</p>
-	<p>
-		<label for=""><?php echo _mb("MD Spatial Resolution");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
-	<p>
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input type="checkbox" name="" value=""><?php echo _mb("Ground Distance [m]");?>
-	</p>
-	<p>
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input name="" id=""/>
-		<img class="metadata_img" src="../img/book.png" alt="" />
-	</p>
-	<p>
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input type="checkbox" name="" value=""><?php echo _mb("Equivalent Scale [1:X]");?>
-	</p>
-	<p>
-		<label></label>
-		<span class="metadata_span"></span>
-		<span class="metadata_span"></span>
-		<input name="" id=""/>
-		<img class="metadata_img" src="../img/book.png" alt="" />
-	</p>
-	<p>
-		<label for=""><?php echo _mb("MD Reference System");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<span class="metadata_span"></span>
-		<input name="ref_system" id="ref_system"/>
-		<img class="metadata_img" src="../img/book.png" alt="" />
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
-	<p>
-		<label for=""><?php echo _mb("MD Format");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<span class="metadata_span"></span>
-		<select class="metadata_selectbox" id='format' name='format' size="2" multiple>
-			<option><?php echo _mb("Shape");?></option>
-			<option><?php echo _mb("Database");?></option>
-			<option><?php echo _mb("CSV");?></option>
-			<option><?php echo _mb("GML");?></option>
+	</fieldset>
+	<fieldset id="charset">
+		<legend><?php echo _mb("Charset of dataset");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Charset of dataset");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<select class="required charset_selectbox" id='inspire_charset' name='inspire_charset' size="2">
+			<option value="utf8"><?php echo _mb("utf8");?></option>
+			<option value="latin1"><?php echo _mb("latin1");?></option>
 		</select>
-	</p>
-	<p>
-		<label for=""><?php echo _mb("MD Charset");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<span class="metadata_span"></span>
-		<select class="metadata_selectbox" id='inspire_charset' name='inspire_charset' size="2" multiple>
-			<option><?php echo _mb("UTF8");?></option>
-			<option><?php echo _mb("latin1");?></option>
-		</select>
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
-	<p>
-		<label for=""><?php echo _mb("Topological Consistance");?>:</label>
-		<img class="metadata_img" src="../img/questionmark.png" alt="" />
-		<span class="metadata_span"></span>
-		<input type="checkbox" name="" value="">
-		<img class="metadata_img" src="../img/misc/inspire_eu_klein.png" alt="" />
-	</p>
 	</fieldset>
+	<fieldset id="consistance">
+		<legend><?php echo _mb("Topological Consistance");?><img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("If the data is topological correct, check this box.");?>'}" src="../img/questionmark.png" alt="" /></legend>
+		<input name="inspire_top_consistence" id="inspire_top_consistence" type="checkbox" checked="checked"/>
+	</fieldset>
+	</fieldset>
 </fieldset>

Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php	2011-05-05 07:11:51 UTC (rev 7795)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php	2011-05-05 19:55:50 UTC (rev 7796)
@@ -568,17 +568,22 @@
 		$row = array();
 		if ($res) {
 			$row = db_fetch_assoc($res);
-			$resultObj["metadata_id"]= $row['metadata_id'];
-			$resultObj["uuid"] = $row["uuid"];
-			$resultObj["origin"] = $row["origin"];
-			$resultObj["link"] = $row["link"];
-			$resultObj["linktype"] = $row["linktype"];
-			$resultObj["title"] = $row["title"];
-			$resultObj["abstract"] = $row["abstract"];
-			$resultObj["format"] = $row["format"];
-			$resultObj["ref_system"] = $row["ref_system"];			
-			$export2csw = $row["export2csw"];
-			$e = new mb_exception($export2csw);
+			$resultObj["metadata_id"]= $row['metadata_id']; //serial
+			$resultObj["uuid"] = $row["uuid"]; //char
+			$resultObj["origin"] = $row["origin"]; //char
+			$resultObj["link"] = $row["link"]; //char
+			$resultObj["linktype"] = $row["linktype"]; //char
+			$resultObj["title"] = $row["title"]; //char -- prefill from layer
+			$resultObj["abstract"] = $row["abstract"]; //char - prefill from layer
+			$resultObj["format"] = $row["format"]; //char
+			$resultObj["ref_system"] = $row["ref_system"]; //char
+			$resultObj["spatial_res_type"] = $row["spatial_res_type"]; //integer
+			$resultObj["spatial_res_value"] = $row["spatial_res_value"]; //char
+			$resultObj["inspire_charset"] = $row["inspire_charset"]; //char
+			$resultObj["lineage"] = $row["lineage"]; //text
+			$resultObj["tmp_reference_1"] = $row["tmp_reference_1"]; //text
+			$resultObj["tmp_reference_2"] = $row["tmp_reference_2"]; //text
+			$export2csw = $row["export2csw"]; //boolean
 			switch ($export2csw) {
 				case "t" :
 					$resultObj["export2csw"] = true;
@@ -588,6 +593,17 @@
 					break;
 				default:
 				break;	
+			}
+			$inspire_top_consistence = $row["inspire_top_consistence"]; //boolean
+			switch ($inspire_top_consistence) {
+				case "t" :
+					$resultObj["inspire_top_consistence"] = true;
+					break;
+				case "f" :
+					$resultObj["inspire_top_consistence"] = false;
+					break;
+				default:
+				break;	
 			}					
 			
 		}
@@ -603,18 +619,18 @@
 		} else {
 			$data->export2csw = 'f';
 		}
-		//$e = new mb_exception("update: ":$data->export2csw);	
-
-
-
-
+		if ($data->inspire_top_consistence) {
+			$data->inspire_top_consistence = 't';
+		} else {
+			$data->inspire_top_consistence = 'f';
+		}
 		$sql = <<<SQL
 
-UPDATE mb_metadata SET link = $2, title = $3, abstract = $4, format = $5, ref_system = $6, export2csw = $7 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 WHERE metadata_id = $1
 
 SQL;
-		$v = array($metadataId, $data->link, $data->title, $data->abstract, $data->format, $data->ref_system, $data->export2csw);
-		$t = array('i','s','s','s','s','s','b');
+		$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);
+		$t = array('i','s','s','s','s','s','b','b','s','s','s','s','s','s');
 		try {
 			$res = db_prep_query($sql,$v,$t);
 		}
@@ -647,24 +663,34 @@
 		} else {
 			$data->export2csw = 'f';
 		}
-
+		//consistance
+		if ($data->inspire_top_consistence == "on") {
+			$data->inspire_top_consistence = 't';
+		} else {
+			$data->inspire_top_consistence = 'f';
+		}
 		//generate a uuid for the record:
 		$uuid = new Uuid();
-
 		//initialize database objects
 		$link = '';
 		$title = '';
 		$abstract = '';
 		$format = '';	
 		$ref_system = '';
-		$export2csw = false;
-
+		$export2csw = 'f';
+		$inspire_top_consistence = 'f';
+		$tmp_reference_1 = '';
+		$tmp_reference_2 = '';
+		$lineage = '';
+		$spatial_res_type = '';
+		$spatial_res_value = '';
+		$inspire_charset = '';
 		//read out json objects 
 		if (isset($data->link)) {
 			$link = $data->link;
 		}
 		if (isset($data->export2csw)) {
-			$export2csw= $data->export2csw;
+			$export2csw = $data->export2csw;
 		}
 		if (isset($data->title)) {
 			$title = $data->title;
@@ -678,63 +704,93 @@
 		if (isset($data->ref_system)) {
 			$ref_system = $data->ref_system;
 		}
+		if (isset($data->inspire_top_consistence)) {
+			$inspire_top_consistence = $data->inspire_top_consistence;
+		}
+		if (isset($data->tmp_reference_1)) {
+			$tmp_reference_1 = $data->tmp_reference_1;
+		}
+
+		if (isset($data->tmp_reference_2)) {
+			$tmp_reference_2 = $data->tmp_reference_2;
+		}
+		if (isset($data->lineage)) {
+			$lineage = $data->lineage;
+		}
+		if (isset($data->spatial_res_type)) {
+			$spatial_res_type = $data->spatial_res_type;
+		}
+		if (isset($data->spatial_res_value)) {
+			$spatial_res_valu = $data->spatial_res_value;
+		}
+		if (isset($data->inspire_charset)) {
+			$inspire_charset = $data->inspire_charset;
+		}
+		$dbInsertFailed = false;
 		$sql = <<<SQL
 
-INSERT INTO mb_metadata (link, uuid, origin, title, abstract, format, ref_system, export2csw) VALUES ($1, $2, $3, $4, $5, $6, $7, $8)
+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)
 
 SQL;
-		$v = array($link, $uuid, $origin, $title, $abstract, $format, $ref_system, $export2csw);
-		$t = array('s','s','s','s','s','s','s','b');
+		$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);
+		$t = array('s','s','s','s','s','s','s','b','b','s','s','s','s','s','s');
+		$res = db_prep_query($sql,$v,$t);
+		if (db_error()) {
+			$test = new mb_exception("test");
+		}
 		try {
 			$res = db_prep_query($sql,$v,$t);
 		}
 		catch (Exception $e){
 			$ajaxResponse->setSuccess(false);
-			$ajaxResponse->setMessage(_mb("Could not insert metadata object into database!"));
-			$ajaxResponse->send();
-			die;	
+			$ajaxResponse->setMessage(_mb("Could not insert metadata object into database!"));	
+			$dbInsertFailed = true;	
+			$e = new mb_exception($dbInsertFailed);
 		}
 		//set relation into relation table
-		//get metadata_id of record which have been inserted before	
-		$sql = <<<SQL
+		//get metadata_id of record which have been inserted before
+		if ($dbInsertFailed != true) {	
+			$sql = <<<SQL
 
-SELECT metadata_id FROM mb_metadata WHERE uuid = $1
+	SELECT metadata_id FROM mb_metadata WHERE uuid = $1
 
 SQL;
-		$v = array($uuid);
-		$t = array('s');
-		try {
-			$res = db_prep_query($sql,$v,$t);
-		}
-		catch (Exception $e){
-			$ajaxResponse->setSuccess(false);
-			$ajaxResponse->setMessage(_mb("Cannot get metadata record with following uuid from database: ".$uuid));
-			$ajaxResponse->send();
-			die;	
-		}
-		if ($res) {
-			$row = db_fetch_assoc($res);
-			$metadata_id = $row['metadata_id'];
-		}
-		$error = new mb_exception("metadata_id:".$metadata_id);
-		$sql = <<<SQL
+			$v = array($uuid);
+			$t = array('s');
+			try {
+				$res = db_prep_query($sql,$v,$t);
+			}
+			catch (Exception $e){
+				$ajaxResponse->setSuccess(false);
+				$ajaxResponse->setMessage(_mb("Cannot get metadata record with following uuid from database: ".$uuid));
+				$dbInsertFailed = true;	
+			}
+			if ($dbInsertFailed != true) {
+				if ($res) {
+					$row = db_fetch_assoc($res);
+					$metadata_id = $row['metadata_id'];
+				}
+				$sql = <<<SQL
 
-INSERT INTO ows_relation_metadata (fkey_metadata_id, fkey_layer_id) VALUES ($1, $2)
+				INSERT INTO ows_relation_metadata (fkey_metadata_id, fkey_layer_id) VALUES ($1, $2)
 
 SQL;
-		$v = array($metadata_id, $layerId);
-		$t = array('i','i');
-		try {
-			$res = db_prep_query($sql,$v,$t);
+				$v = array($metadata_id, $layerId);
+				$t = array('i','i');
+				try {
+					$res = db_prep_query($sql,$v,$t);
+				}
+				catch (Exception $e){
+					$ajaxResponse->setSuccess(false);
+					$ajaxResponse->setMessage(_mb("Cannot write relation between ows and metadata to database!"));
+					$dbInsertFailed = true;
+				}
+				if ($dbInsertFailed != true) {	
+					$ajaxResponse->setMessage("Metadata object inserted into md_metadata!");
+					$ajaxResponse->setSuccess(true);
+				}				
+			}
 		}
-		catch (Exception $e){
-			$ajaxResponse->setSuccess(false);
-			$ajaxResponse->setMessage(_mb("Cannot write relation between ows and metadata to database!"));
-			$ajaxResponse->send();
-			die;	
-		}				
-		$ajaxResponse->setMessage("Metadata object inserted into md_metadata!");
-		$ajaxResponse->setSuccess(true);
 		break;
 	case "deleteLayerMetadataAddon" :
 		$metadataId = $ajaxResponse->getParameter("metadataId");

Modified: trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2011-05-05 07:11:51 UTC (rev 7795)
+++ trunk/mapbender/http/plugins/mb_metadata_showMetadataAddon.js	2011-05-05 19:55:50 UTC (rev 7796)
@@ -7,6 +7,14 @@
 	var layerId;
 	var metadataId;
 	//Function, which pulls the metadata out off the mapbender registry and give a possibility to edit the record or link
+	this.valid = function () {
+		if (validator && validator.numberOfInvalids() > 0) {
+			$metadataAddonForm.valid();
+			return false;
+		}
+		return true;
+	};
+
 	this.getAddedMetadata = function(metadataId, layerId){
 		// get metadata from server
 		var req = new Mapbender.Ajax.Request({
@@ -22,6 +30,7 @@
 				}
 				$metadataAddonForm.easyform("reset");
 				$metadataAddonForm.easyform("fill", obj);
+				
 				//enable link element to edit link!
 				$("#link").removeAttr("disabled");
 
@@ -40,7 +49,12 @@
     						break;
 					default:
     						break;
-				}	
+				}
+				//select the right list entries:
+				$(".format_selectbox").val(obj.format); 				$(".charset_selectbox").val(obj.inspire_charset);
+				$(".ref_system_selectbox").val(obj.ref_system);
+				$(".radioRes").filter('[value='+obj.spatial_res_type+']').attr('checked', true);
+
 			}
 		});
 		req.send();	
@@ -172,7 +186,11 @@
 				},
 				"save": function() {
 					//get data from form
-					$metadataAddonForm.valid();
+					//validate form before send it!
+					if ($metadataAddonForm.valid() != true) {
+						alert("Form not valid - please check your input!"); //TODO use translations and make a php file from this
+						return;
+					}
 					var formData = $metadataAddonForm.easyform("serialize");
 					if (!isNew) {
 						that.updateAddedMetadata(metadataId, layerId, formData);
@@ -191,6 +209,11 @@
 	this.init = function (metadataId, layerId, isNew) {
 		$metadataAddonPopup.dialog("close");
 		$metadataAddonForm.load("../plugins/mb_metadata_addon.php", function () {
+			//push infos to help dialogs
+			$metadataAddonForm.find(".help-dialog").helpDialog();
+			//initialize datepicker
+			$('.hasdatepicker').datepicker({dateFormat:'yy-mm-dd', buttonImageOnly: true, changeYear: true,
+constraintInput: true});
 			//first get json
 			if (!isNew) {
 				that.getAddedMetadata(metadataId, layerId);

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-05 07:11:51 UTC (rev 7795)
+++ trunk/mapbender/resources/db/pgsql/UTF-8/update/update_2.7rc1_to_2.7rc2_pgsql_UTF-8.sql	2011-05-05 19:55:50 UTC (rev 7796)
@@ -1911,5 +1911,10 @@
     }
 ]', '' ,'var');
 
+-- 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);
 
+-- 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