[Mapbender-commits] r6178 - in trunk/mapbender: http/plugins lib
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Tue May 11 11:55:40 EDT 2010
Author: christoph
Date: 2010-05-11 11:55:35 -0400 (Tue, 11 May 2010)
New Revision: 6178
Modified:
trunk/mapbender/http/plugins/mb_metadata_edit.js
trunk/mapbender/http/plugins/mb_metadata_edit.php
trunk/mapbender/http/plugins/mb_metadata_layer.js
trunk/mapbender/http/plugins/mb_metadata_layer.php
trunk/mapbender/http/plugins/mb_metadata_server.php
trunk/mapbender/http/plugins/mb_metadata_submit.js
trunk/mapbender/lib/basic.js
Log:
Modified: trunk/mapbender/http/plugins/mb_metadata_edit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_edit.js 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/http/plugins/mb_metadata_edit.js 2010-05-11 15:55:35 UTC (rev 6178)
@@ -25,36 +25,42 @@
var MetadataEditApi = function (o) {
var that = this;
var validator;
+ var formReady = false;
var wmsId;
this.events = {
showOriginalMetadata : new Mapbender.Event(),
submit: new Mapbender.Event()
};
+
+ this.valid = function () {
+ if (validator && validator.numberOfInvalids() > 0) {
+ $metadataForm.valid();
+ return false;
+ }
+ return true;
+ };
this.serialize = function (callback) {
- var data = $metadataForm.easyform("serialize");
+ $metadataForm.submit();
+ var data = null;
+ if (this.valid()) {
+ data = {
+ wms: $metadataForm.easyform("serialize")
+ };
+ }
if ($.isFunction(callback)) {
- callback({
- wms: data
- });
+ callback(data);
}
- return data;
+ return data !== null ? data.wms : data;
};
- this.valid = function () {
- if (validator && validator.numberOfInvalids() > 0) {
- $metadataForm.valid();
- }
- };
-
- var formReady = false;
-
// second optional parameter formData
var fillForm = function (obj) {
if (arguments.length >= 2) {
$metadataForm.easyform("reset");
$metadataForm.easyform("fill", arguments[1]);
+ that.valid();
return;
}
@@ -71,6 +77,7 @@
}
$metadataForm.easyform("reset");
$metadataForm.easyform("fill", obj);
+ that.valid();
}
});
req.send();
@@ -89,7 +96,12 @@
});
};
+ var validate = function () {
+ return false;
+ };
+
this.init = function (obj) {
+
wmsId = obj;
var formData = arguments.length >= 2 ? arguments[1] : undefined;
@@ -114,6 +126,8 @@
fillForm(obj);
};
+ $metadataForm.bind("submit", validate);
+
Mapbender.events.localize.register(function () {
that.valid();
var formData = $metadataForm.easyform("serialize");
Modified: trunk/mapbender/http/plugins/mb_metadata_edit.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_edit.php 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/http/plugins/mb_metadata_edit.php 2010-05-11 15:55:35 UTC (rev 6178)
@@ -1,8 +1,7 @@
<?php
require_once dirname(__FILE__) . "/../../core/globalSettings.php";
?>
-
-<fieldset class="ui-widget">
+<fieldset>
<input name="wms_id" id="wms_id" type="hidden"/>
<legend>Service Level Metadata: <img class="help-dialog" title="<?php echo _mb("Help");?>" help="{text:'<?php echo _mb("Help text");?>'}" src="../img/questionmark.png"></img></legend>
@@ -58,7 +57,7 @@
</p>
</fieldset>
<fieldset>
- <legend>WMS Provider Section (OWS):</legend>
+ <legend>WMS Provider Section (OWS)</legend>
<p>
<label for="contactperson">Contact Individual Name (OWS):</label>
<input name="contactperson" id="contactperson"/>
Modified: trunk/mapbender/http/plugins/mb_metadata_layer.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.js 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.js 2010-05-11 15:55:35 UTC (rev 6178)
@@ -26,84 +26,67 @@
var that = this;
var validator;
var formReady = false;
-
+ var wmsId;
+ var layerId;
+
+ this.events = {
+ initialized: new Mapbender.Event(),
+ submit: new Mapbender.Event()
+ };
+
this.valid = function () {
if (validator && validator.numberOfInvalids() > 0) {
$metadataForm.valid();
+ return false;
}
+ return true;
};
this.serialize = function (callback) {
- var data = $metadataForm.easyform("serialize");
+ $metadataForm.submit();
+ var data = null;
+ if (this.valid()) {
+ data = {
+ layer: $metadataForm.easyform("serialize")
+ };
+ }
if ($.isFunction(callback)) {
- callback({
- layer: data
- });
+ callback(data);
}
- return data;
+ return data !== null ? data.layer : data;
};
-
- this.events = {
- initialized: new Mapbender.Event(),
- submit: new Mapbender.Event()
- };
-
this.fillForm = function (obj) {
- // layer data
- $metadataForm.easyform("reset");
- $metadataForm.easyform("fill", obj);
- return;
- // layer keywords
- var req = new Mapbender.Ajax.Request({
- url: "../plugins/mb_metadata_server.php",
- method: "getLayerKeywords",
- parameters: {
- "id": obj.layer_id
- },
- callback: function(o, r, m) {
- if (!r) {
- return;
- }
- for (var i in o) {
- var $node = $("#" + i).val("");
- if ($node.size() > 0) {
- for (var j = 0; j < o[i].length; j++) {
- $node.val($node.val() !== "" ? $node.val() + ", " + o[i][j][1] : o[i][j][1]);
- }
- }
- }
- }
- });
- req.send();
+ layerId = obj.layer_id;
- // layer categories
+ // get metadata from server
var req = new Mapbender.Ajax.Request({
url: "../plugins/mb_metadata_server.php",
- method: "getLayerCategories",
+ method: "getLayerMetadata",
parameters: {
- "id": obj.layer_id
+ "id": layerId
},
- callback: function(o, r, m) {
- if (!r) {
+ callback: function (obj, result, message) {
+ if (!result) {
return;
}
- for (var i in o) {
- var $node = $("#" + i);
- if ($node.size() > 0) {
- $node.find("option").removeAttr("selected");
- for (var j = 0; j < o[i].length; j++) {
- $node.find("option[value="+ o[i][j] +"]").attr("selected", "selected");
- }
- }
- }
+ $metadataForm.easyform("reset");
+ $metadataForm.easyform("fill", obj);
+ that.valid();
}
});
- req.send();
+ req.send();
};
+ var validate = function () {
+ return false;
+ };
+
+ this.init = function (obj) {
+ $metadataForm.easyform("reset");
- this.init = function (wmsId) {
+ wmsId = obj;
+
var formData = arguments.length >= 2 ? arguments[1] : undefined;
if (!formReady) {
@@ -126,6 +109,8 @@
});
};
+ $metadataForm.bind("submit", validate);
+
Mapbender.events.localize.register(function () {
that.valid();
var formData = $metadataForm.easyform("serialize");
Modified: trunk/mapbender/http/plugins/mb_metadata_layer.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_layer.php 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/http/plugins/mb_metadata_layer.php 2010-05-11 15:55:35 UTC (rev 6178)
@@ -29,6 +29,8 @@
<div id="layer">
<fieldset class="">
+ <input name="layer_name" id="layer_name" type="hidden"/>
+
<legend>Layer metadata</legend>
<p>
<label for="wms_title"><?php echo _mb("Show original Service Metadata from last update");?></label>
@@ -45,7 +47,7 @@
<label for="layer_title">Layer Title (WMS):</label>
<img class="metadata_img" src="../img/misc/inspire_eu_klein.png"></img>
<span class="metadata_span"></span>
- <input name="layer_title" id="layer_title"/>
+ <input name="layer_title" id="layer_title" class="required" />
</p>
<p>
<label for="layer_abstract">Layer Abstract (WMS):</label>
@@ -54,10 +56,10 @@
<input name="layer_abstract" id="layer_abstract"/>
</p>
<p>
- <label for="fkey_keyword_id">Layer Keywords (WMS):</label>
+ <label for="layer_keyword">Layer Keywords (WMS):</label>
<span class="metadata_span"></span>
<span class="metadata_span"></span>
- <input name="fkey_keyword_id" id="fkey_keyword_id"/>
+ <input name="layer_keyword" id="layer_keyword"/>
</p>
<p>
<div id="buttons">
@@ -94,9 +96,9 @@
<fieldset class="">
<legend>Classification</legend>
<p>
- <label for="fkey_md_topic_category_id" class="label_classification">ISO Topic Category:</label>
+ <label for="layer_md_topic_category_id" class="label_classification">ISO Topic Category:</label>
<img class="metadata_img" src="../img/misc/inspire_eu_klein.png"></img>
- <select class="metadata_selectbox" id="fkey_md_topic_category_id" name="fkey_md_topic_category_id" size="2" multiple="multiple">
+ <select class="metadata_selectbox" id="layer_md_topic_category_id" name="layer_md_topic_category_id" size="2" multiple="multiple">
<?php
$sql = "SELECT md_topic_category_id AS id, md_topic_category_code_en AS name FROM md_topic_category";
echo displayCategories($sql);
@@ -104,9 +106,9 @@
</select>
</p>
<p>
- <label for="fkey_inspire_category_id" class="label_classification">INSPIRE Category:</label>
+ <label for="layer_inspire_category_id" class="label_classification">INSPIRE Category:</label>
<img class="metadata_img" src="../img/misc/inspire_eu_klein.png"></img>
- <select class="metadata_selectbox" id="fkey_inspire_category_id" name="fkey_inspire_category_id" size="2" multiple="multiple">
+ <select class="metadata_selectbox" id="layer_inspire_category_id" name="layer_inspire_category_id" size="2" multiple="multiple">
<?php
$sql = "SELECT inspire_category_id AS id, inspire_category_code_en AS name FROM inspire_category";
echo displayCategories($sql);
@@ -114,9 +116,9 @@
</select>
</p>
<p>
- <label for="fkey_custom_category_id" class="label_classification">Custom Category:</label>
+ <label for="layer_custom_category_id" class="label_classification">Custom Category:</label>
<span class="metadata_span"></span>
- <select class="metadata_selectbox" id="fkey_custom_category_id" name="fkey_custom_category_id" size="2" multiple="multiple">
+ <select class="metadata_selectbox" id="layer_custom_category_id" name="layer_custom_category_id" size="2" multiple="multiple">
<?php
$sql = "SELECT custom_category_id AS id, custom_category_code_en AS name FROM custom_category";
echo displayCategories($sql);
Modified: trunk/mapbender/http/plugins/mb_metadata_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_server.php 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/http/plugins/mb_metadata_server.php 2010-05-11 15:55:35 UTC (rev 6178)
@@ -33,7 +33,7 @@
}
$wmsId = wms::getWmsIdByLayerId($layerId);
if (is_null($wmsId) || !in_array($wmsId, $wmsIdArray)) {
- abort(_mb("You are not allowed to access this WMS."));
+ abort(_mb("You are not allowed to access WMS " . $wmsId));
}
return;
}
@@ -146,8 +146,8 @@
$sql = <<<SQL
-SELECT layer_id, layer_title, layer_abstract, layer_searchable
-FROM layer WHERE wms_id = $wmsId;
+SELECT layer_id, layer_name, layer_title, layer_abstract, layer_searchable
+FROM layer WHERE layer_id = $layerId;
SQL;
$res = db_query($sql);
@@ -155,51 +155,18 @@
$resultObj = array();
while ($row = db_fetch_assoc($res)) {
foreach ($row as $key => $value) {
- $resultObj["layer:".$key] = $value;
+ $resultObj[$key] = $value;
}
}
- $ajaxResponse->setResult($resultObj);
- $ajaxResponse->setSuccess(true);
- break;
- case "getLayerKeywords" :
- $layerId = $ajaxResponse->getParameter("id");
- getLayer($layerId);
$sql = <<<SQL
-
-SELECT keyword, fkey_keyword_id FROM keyword, layer_keyword
-WHERE keyword_id = fkey_keyword_id AND fkey_layer_id = $layerId
-
-SQL;
- $res = db_query($sql);
-
- $resultObj = array(
- "fkey_keyword_id" => array()
- );
- while ($row = db_fetch_assoc($res)) {
- $resultObj["fkey_keyword_id"][]= array($row["fkey_keyword_id"], $row["keyword"]);
- }
- $ajaxResponse->setResult($resultObj);
- $ajaxResponse->setSuccess(true);
- break;
-
- case "getLayerCategories" :
- $layerId = $ajaxResponse->getParameter("id");
- getLayer($layerId);
-
- $resultObj = array(
- "fkey_md_topic_category_id" => array(),
- "fkey_inspire_category_id" => array(),
- "fkey_custom_category_id" => array()
- );
- $sql = <<<SQL
SELECT fkey_md_topic_category_id
FROM layer_md_topic_category
WHERE fkey_layer_id = $layerId
SQL;
$res = db_query($sql);
while ($row = db_fetch_assoc($res)) {
- $resultObj["fkey_md_topic_category_id"][]= $row["fkey_md_topic_category_id"];
+ $resultObj["layer_md_topic_category_id"][]= $row["fkey_md_topic_category_id"];
}
$sql = <<<SQL
@@ -209,7 +176,7 @@
SQL;
$res = db_query($sql);
while ($row = db_fetch_assoc($res)) {
- $resultObj["fkey_inspire_category_id"][]= $row["fkey_inspire_category_id"];
+ $resultObj["layer_inspire_category_id"][]= $row["fkey_inspire_category_id"];
}
$sql = <<<SQL
@@ -219,9 +186,20 @@
SQL;
$res = db_query($sql);
while ($row = db_fetch_assoc($res)) {
- $resultObj["fkey_custom_category_id"][]= $row["fkey_custom_category_id"];
+ $resultObj["layer_custom_category_id"][]= $row["fkey_custom_category_id"];
}
+ $sql = <<<SQL
+SELECT keyword FROM keyword, layer_keyword
+WHERE keyword_id = fkey_keyword_id AND fkey_layer_id = $layerId
+SQL;
+ $res = db_query($sql);
+
+ $resultObj["layer_keyword"] = array();
+ while ($row = db_fetch_assoc($res)) {
+ $resultObj["layer_keyword"][]= $row["keyword"];
+ }
+
$ajaxResponse->setResult($resultObj);
$ajaxResponse->setSuccess(true);
break;
@@ -342,7 +320,8 @@
"stateorprovince",
"postcode",
"country",
- "contactelectronicmailaddress"
+ "contactelectronicmailaddress",
+ "wms_termsofuse"
);
foreach ($columns as $c) {
$value = $data->wms->$c;
@@ -362,15 +341,40 @@
if (!is_null($layer)) {
$columns = array(
"layer_abstract",
- "layer_title"
+ "layer_title",
+ "layer_keyword",
+ "layer_md_topic_category_id",
+ "layer_inspire_category_id",
+ "layer_custom_category_id"
);
foreach ($columns as $c) {
$value = $data->layer->$c;
- if (!is_null($value)) {
- $layer->$c = $value;
+ if ($c === "layer_keyword") {
+ $layer->$c = explode(",", $value);
+ foreach ($layer->$c as &$val) {
+ $val = trim($val);
+ }
}
+ elseif ($c === "layer_md_topic_category_id"
+ || $c === "layer_inspire_category_id"
+ || $c === "layer_custom_category_id"
+ ) {
+ if (!is_array($value)) {
+ $layer->$c = array($value);
+ $firephp->log($layer->$c);
+ }
+ else {
+ $layer->$c = $value;
+ }
+ }
+ else {
+ if (!is_null($value)) {
+ $layer->$c = $value;
+ }
+ }
}
+ $firephp->log($layer);
}
}
Modified: trunk/mapbender/http/plugins/mb_metadata_submit.js
===================================================================
--- trunk/mapbender/http/plugins/mb_metadata_submit.js 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/http/plugins/mb_metadata_submit.js 2010-05-11 15:55:35 UTC (rev 6178)
@@ -5,16 +5,29 @@
var formData = {};
var serializeCallback = function (data) {
- formData = $.extend(formData, data);
+ if (data === null) {
+ formData = null;
+ return;
+ }
+ if (formData !== null) {
+ formData = $.extend(formData, data);
+ }
};
+ this.enable = function () {
+ $submit.find("input[type='submit']").removeAttr("disabled");
+ };
+
this.submit = function () {
formData = {};
this.events.submit.trigger({
callback: serializeCallback
});
-// console.log(formData);
+ if (formData === null) {
+ return;
+ }
+
// get metadata from server
var req = new Mapbender.Ajax.Request({
url: "../plugins/mb_metadata_server.php",
@@ -24,8 +37,14 @@
},
callback: function (obj, result, message) {
if (!result) {
+ $("<div></div>").text(!message ? "An error occured." : message).dialog({
+ modal: true
+ });
return;
}
+ $("<div></div>").text(message).dialog({
+ modal: true
+ });
}
});
Modified: trunk/mapbender/lib/basic.js
===================================================================
--- trunk/mapbender/lib/basic.js 2010-05-11 14:44:56 UTC (rev 6177)
+++ trunk/mapbender/lib/basic.js 2010-05-11 15:55:35 UTC (rev 6178)
@@ -389,7 +389,16 @@
var f = $(this).serializeArray();
var r = {};
for (var i in f) {
- r[f[i].name] = f[i].value;
+ var n = r[f[i].name];
+ if (n === undefined) {
+ r[f[i].name] = $(f[i]).val();
+ }
+ else if (n.length && typeof n === "object") {
+ r[f[i].name].push($(f[i]).val());
+ }
+ else {
+ r[f[i].name] = [n, $(f[i]).val()];
+ }
}
return r;
case "fill":
@@ -407,7 +416,29 @@
return this.each(function () {
if (data) {
for (var i in data) {
- $(this[i]).val(data[i]);
+ if (!this[i]) {
+ continue;
+ }
+ var $node = $(this[i]);
+ if ($node.size() === 1) {
+ if ($node.get(0).tagName.toUpperCase() === "SELECT") {
+ $node.find("option").each(function () {
+ var $opt = $(this);
+ var value = data[i];
+ if (!value.length) {
+ value = [value];
+ }
+ for (var j in value) {
+ if ($opt.val() === value[j]) {
+ $opt.attr("selected", "selected");
+ }
+ }
+ });
+ }
+ else {
+ $node.val(data[i]);
+ }
+ }
}
return;
}
More information about the Mapbender_commits
mailing list