[Mapbender-commits] r6473 - in trunk/mapbender/http: classes
javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Jul 1 04:22:42 EDT 2010
Author: verenadiewald
Date: 2010-07-01 08:22:42 +0000 (Thu, 01 Jul 2010)
New Revision: 6473
Modified:
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/javascripts/mod_loadwmc.js
trunk/mapbender/http/javascripts/mod_savewmc.js
trunk/mapbender/http/javascripts/mod_savewmc.php
trunk/mapbender/http/php/mod_savewmc_server.php
Log:
added possibility to edit wmc from loadwmc list
Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php 2010-06-30 14:41:58 UTC (rev 6472)
+++ trunk/mapbender/http/classes/class_wmc.php 2010-07-01 08:22:42 UTC (rev 6473)
@@ -195,7 +195,7 @@
* @param object $extensionData data exclusive to Mapbender, which will be
* mapped into the extension part of the WMC
*/
- public function createFromJs($mapObject, $generalTitle, $extensionData) {
+ public function createFromJs($mapObject, $generalTitle,$extensionData, $id=null) {
if (count($mapObject) > 2) {
$e = new mb_exception("Save WMC only works for two concurrent map frames (overview plus main) at the moment.");
@@ -204,6 +204,11 @@
// set extension data
$this->generalExtensionArray = $extensionData;
+ if ($id !== null) {
+ //set id
+ $this->wmc_id = $id;
+ }
+
// set title
$this->wmc_title = $generalTitle;
@@ -604,9 +609,9 @@
if($overwrite) {
- $findsql = "SELECT fkey_user_id,wmc_title,wmc_timestamp, wmc_id FROM mb_user_wmc WHERE fkey_user_id = $1 AND wmc_title = $2 ORDER BY wmc_timestamp DESC LIMIT 1;";
- $v = array($this->userId, administration::convertOutgoingString($this->wmc_title));
- $t = array("i","s");
+ $findsql = "SELECT fkey_user_id,wmc_title,wmc_timestamp, wmc_id FROM mb_user_wmc WHERE fkey_user_id = $1 AND wmc_id = $2 ORDER BY wmc_timestamp DESC LIMIT 1;";
+ $v = array($this->userId, $this->wmc_id);
+ $t = array("i","i");
$res = db_prep_query($findsql,$v,$t);
if (db_error()) {
@@ -619,10 +624,10 @@
if($row = db_fetch_row($res)) {
$sql = "UPDATE mb_user_wmc SET wmc = $1, wmc_timestamp = $2, abstract = $3, srs = $4, minx = $5, miny = $6,".
- " maxx = $7, maxy = $8 WHERE fkey_user_id = $9 AND wmc_title=$10 AND wmc_timestamp = $11;";
+ " maxx = $7, maxy = $8, wmc_title = $9 WHERE fkey_user_id = $10 AND wmc_id=$11 AND wmc_timestamp = $12;";
$v = array($this->xml, time(), $this->wmc_abstract, $this->wmc_srs, $this->wmc_extent->minx, $this->wmc_extent->minx,
- $this->wmc_extent->maxx, $this->wmc_extent->maxy ,$this->userId, administration::convertOutgoingString($this->wmc_title),$row[2]);
- $t = array("s", "s","s","s","i","i","i","i", "i", "s","s");
+ $this->wmc_extent->maxx, $this->wmc_extent->maxy ,administration::convertOutgoingString($this->wmc_title), $this->userId, $this->wmc_id,$row[2]);
+ $t = array("s", "s","s","s","i","i","i","i", "s", "i", "i","s");
// need the database Id
$wmc_DB_ID = $row[3];
$delsql = "DELETE FROM wmc_md_topic_category WHERE fkey_wmc_id = $1;";
Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js 2010-06-30 14:41:58 UTC (rev 6472)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js 2010-07-01 08:22:42 UTC (rev 6473)
@@ -12,6 +12,8 @@
options.deleteWmc = typeof options.deleteWmc === "number" ? options.deleteWmc : 1;
options.uploadWmc = typeof options.uploadWmc === "number" ? options.uploadWmc : 1;
options.listWmc = typeof options.listWmc === "number" ? options.listWmc : 1;
+options.editWmc = typeof options.editWmc === "number" ? options.editWmc : 1;
+options.saveWmcTarget = typeof options.saveWmcTarget === "string" ? options.saveWmcTarget : "savewmc";
var originalI18nObject = {
"labelList": "List",
@@ -25,6 +27,7 @@
"labelPublic": "public",
"labelShow": "show",
"labelDelete": "delete",
+ "labelEdit": "edit",
"labelOpenLayers": "OpenLayers",
"labelCurrentState": "currentState",
"labelDeleteWmc": "delete this WMC",
@@ -52,6 +55,7 @@
var wmcPopup = null;
var wmcDisplayPopup = null;
var wmcOpenLayersPopup = null;
+ var wmcListTableInitialized = false;
var LOAD_WMC_OPTIONS = {
src: "../img/button_gray/wmc_load.png",
@@ -94,6 +98,12 @@
src: "../img/button_gray/wmc_xml.png",
title: translatedI18nObject.labelDisplayWmc
};
+
+ var EDIT_WMC_OPTIONS = {
+ src: "../img/pencil.png",
+ title: translatedI18nObject.labelEditWmc,
+ method: "editWmc"
+ };
this.events = {
loaded: new Mapbender.Event()
@@ -207,6 +217,31 @@
req.send();
};
+ this.showWmcSaveForm = function (id) {
+ Mapbender.modules[options.saveWmcTarget].getExistingWmcData(function (obj) {
+ for (var i = 0; i < obj.length; i++) {
+ var wmc = obj[i];
+ if (wmc.id === id) {
+ $("#" + options.saveWmcTarget + "_wmc_id").val(wmc.id);
+ $("#" + options.saveWmcTarget + "_wmctype").append("<option value='" + wmc.id + "' selected>" + wmc.title + "</option>");
+ $("#" + options.saveWmcTarget + "_wmctype").attr("disabled","disabled");
+ $("#" + options.saveWmcTarget + "_wmcname").val(wmc.title);
+ $("#" + options.saveWmcTarget + "_wmcabstract").val(wmc.abstract);
+ $("#" + options.saveWmcTarget + "_wmckeywords").val(wmc.keywords.join(","));
+ $("input[id^='" + options.saveWmcTarget + "_wmcinspire_']").removeAttr("checked");
+ for (var j = 0; j < wmc.categories.length; j++) {
+ var cat = wmc.categories[j];
+ $("#" + options.saveWmcTarget + "_wmcinspire_" + cat).attr("checked", "checked");
+ }
+ }
+ }
+ $("#" + options.saveWmcTarget + "_saveWMCForm").dialog('open');
+ });
+ Mapbender.modules[options.saveWmcTarget].events.saved.register(function () {
+ //that.refreshList();
+ });
+ };
+
var getInitialDialogHtml = function (id) {
if (!options.listWmc && !options.uploadWmc) {
@@ -222,11 +257,12 @@
translatedI18nObject.labelUpload + "</a></li></ul>";
}
+ initialHtml += "<div id='" + id + "_wmclist' >";
+
// add listWMC if available
var t = translatedI18nObject;
if (options.listWmc) {
- initialHtml += "<div id='" + id + "_wmclist' >" +
- "<table width='100%' id='" + id + "_wmclist_table'>" +
+ initialHtml += "<table width='100%' id='" + id + "_wmclist_table'>" +
"<thead><tr>" +
"<th>" + t.labelWmcName + "</td>" +
"<th>" + t.labelLastUpdate + "</td>" +
@@ -237,14 +273,17 @@
(options.publishWmc ? "<th>" + t.labelPublic + "</td>" : "") +
(options.showWmc ? "<th>" + t.labelShow + "</td>" : "") +
(options.openLayers ? "<th>" + t.labelOpenLayers + "</td>" : "") +
+ (options.editWmc ? "<th>" + t.labelEdit + "</td>" : "") +
(options.deleteWmc ? "<th>" + t.labelDelete + "</td>" : "") +
- "</thead></tr></table></div>";
+ "</tr></thead></table>";
}
-
+
+ initialHtml += "</div>";
// add uploadWMC if available
if (options.uploadWmc) {
initialHtml += "<div id='" + id + "_wmcUpload' ></div>";
}
+
return "<div style='display:none' id='" + id + "_tabs'>" + initialHtml + "</div>";
};
@@ -430,6 +469,15 @@
);
};
+ var createEditWmcCell = function (wmc) {
+ return createTableCell(
+ EDIT_WMC_OPTIONS,
+ function(){
+ that.showWmcSaveForm(wmc.id);
+ }
+ );
+ };
+
var createDeleteWmcCell = function (wmc) {
var $deleteTd = createTableCell(
$.extend({}, DELETE_WMC_OPTIONS, {
@@ -450,6 +498,49 @@
};
var displayWmcList = function (wmcObj, status) {
+/*
+ if(wmcListTableInitialized === true) {
+ wmcTable.fnClearTable();
+
+ for (var i=0; i < wmcObj.wmc.length; i++) {
+ (function () {
+
+ var currentIndex = i;
+ var currentWmc = wmcObj.wmc[currentIndex];
+
+ var dataArray = [currentWmc.title, currentWmc.timestamp, currentWmc.timestamp_create];
+
+ if (options.loadWmc) {
+ dataArray.push(createLoadWmcCell(currentWmc));
+ }
+ if (options.mergeWmc) {
+ dataArray.push(createMergeWmcCell(currentWmc));
+ }
+ if (options.appendWmc) {
+ dataArray.push(createAppendWmcCell(currentWmc));
+ }
+ if (options.publishWmc) {
+ dataArray.push(createPublishWmcCell(currentWmc));
+ }
+ if (options.showWmc) {
+ dataArray.push(createDisplayWmcCell(currentWmc));
+ }
+ if (options.openLayers) {
+ dataArray.push(createOpenLayersWmcCell(currentWmc));
+ }
+ if (options.editWmc) {
+ dataArray.push(createEditWmcCell(currentWmc));
+ }
+ if (options.deleteWmc) {
+ dataArray.push(createDeleteWmcCell(currentWmc));
+ }
+ wmcTable.fnAddData(dataArray);
+ //$tr.appendTo($("tbody", wmcTable));
+ })();
+ }
+ }
+ else {
+*/
// create table
for (var i=0; i < wmcObj.wmc.length; i++) {
(function () {
@@ -479,13 +570,25 @@
if (options.openLayers) {
$tr.append(createOpenLayersWmcCell(currentWmc));
}
+ if (options.editWmc) {
+ $tr.append(createEditWmcCell(currentWmc));
+ }
if (options.deleteWmc) {
$tr.append(createDeleteWmcCell(currentWmc));
}
$tr.appendTo("#" + options.id + "_wmclist_table");
})();
}
+/*
+ }
+
+
+
+
+ if(wmcListTableInitialized === false) {
+*/
+ // create horizontal tabs
// create horizontal tabs
if (options.listWmc && options.uploadWmc) {
$("#" + options.id + "_tabs").tabs().css("display", "block");
@@ -511,16 +614,19 @@
}
// create datatables
- Mapbender.languageId;
if (options.listWmc) {
wmcTable = $("#" + options.id + "_wmclist_table").dataTable({
"bPaginate": true,
- "bJQueryUI": true,
- "oLanguage": {
- "sUrl":"../extensions/dataTables-1.5/lang/"+Mapbender.languageId +".txt"
- }
+ "bJQueryUI": true
});
}
+/*
+ wmcListTableInitialized = true;
+ }
+ else {
+ wmcTable.fnDraw();
+ }
+*/
};
var constraintCheckRequired = function () {
Modified: trunk/mapbender/http/javascripts/mod_savewmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.js 2010-06-30 14:41:58 UTC (rev 6472)
+++ trunk/mapbender/http/javascripts/mod_savewmc.js 2010-07-01 08:22:42 UTC (rev 6473)
@@ -168,7 +168,7 @@
$(this).text(translatedI18nObj.labelNewOrOverwrite).next()
.children().eq(0).text(translatedI18nObj.labelNewWmc);
break;
- case options.id + ":wmcname" :
+ case options.id + "_wmcname" :
$(this).text(translatedI18nObj.labelName);
break;
case options.id + "_wmcabstract" :
@@ -186,7 +186,7 @@
$legend.text(translatedI18nObj.labelCategories);
};
- var getExistingWmcData = function (callback) {
+ this.getExistingWmcData = function (callback) {
// get WMC data from server
var req = new Mapbender.Ajax.Request({
url: "../php/mod_loadwmc_server.php",
@@ -207,6 +207,7 @@
var createSelectBoxForExistingWmcs = function (obj) {
(function () {
$select = $("#" + options.id + "_wmctype").empty();
+ $select.removeAttr("disabled");
var select = "<option value=''>" + translatedI18nObj.labelNewWmc + "</option>";
if (typeof obj === "object" && obj.length) {
for (var i = 0; i < obj.length; i++) {
@@ -224,6 +225,7 @@
// reset fields if new wmc is saved
//
if (this.value === "") {
+ $("#" + options.id + "_wmc_id").val("");
$("#" + options.id + "_wmcname").val("");
$("#" + options.id + "_wmcabstract").val("");
$("#" + options.id + "_wmckeywords").val("");
@@ -236,6 +238,7 @@
for (var i = 0; i < obj.length; i++) {
var wmc = obj[i];
if (wmc.id === this.value) {
+ $("#" + options.id + "_wmc_id").val(wmc.id);
$("#" + options.id + "_wmcname").val(wmc.title);
$("#" + options.id + "_wmcabstract").val(wmc.abstract);
$("#" + options.id + "_wmckeywords").val(wmc.keywords.join(","));
@@ -262,6 +265,7 @@
}
});
var attributes = {};
+ attributes.wmc_id = $("#" + options.id + "_wmc_id").val();
attributes.title = $("#" + options.id + "_wmcname").val();
attributes.abstract = $("#" + options.id + "_wmcabstract").val();
attributes.keywords = $("#" + options.id + "_wmckeywords").val();
@@ -285,7 +289,7 @@
};
var mod_savewmc = function () {
- getExistingWmcData(function (obj) {
+ that.getExistingWmcData(function (obj) {
createSelectBoxForExistingWmcs(obj);
$("#" + options.id + "_saveWMCForm").dialog('open');
});
Modified: trunk/mapbender/http/javascripts/mod_savewmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.php 2010-06-30 14:41:58 UTC (rev 6472)
+++ trunk/mapbender/http/javascripts/mod_savewmc.php 2010-07-01 08:22:42 UTC (rev 6473)
@@ -76,6 +76,7 @@
'<textarea id="{$e_id}_wmcabstract" class="text ui-widget-content ui-corner-all"></textarea>' +
'<label for="{$e_id}_wmckeywords">{$labelKeywords}</label>' +
'<input id="{$e_id}_wmckeywords" type="text" class="text ui-widget-content ui-corner-all" />' +
+ '<input id="{$e_id}_wmc_id" type="hidden" />' +
'</fieldset><fieldset id="{$e_id}_inspire_cat"><legend>{$labelCategories}' +
'</legend>' +
'{$saveWmcCategoryString}' +
Modified: trunk/mapbender/http/php/mod_savewmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_savewmc_server.php 2010-06-30 14:41:58 UTC (rev 6472)
+++ trunk/mapbender/http/php/mod_savewmc_server.php 2010-07-01 08:22:42 UTC (rev 6473)
@@ -35,7 +35,12 @@
// create WMC object
$wmc = new wmc();
-$wmc->createFromJs($mapObject, $attributes->title, $extensionData);
+if($overwrite) {
+ $wmc->createFromJs($mapObject, $attributes->title, $extensionData, $attributes->wmc_id);
+}
+else {
+ $wmc->createFromJs($mapObject, $attributes->title, $extensionData);
+}
if ($saveInSession === 1) {
// store XML in session
More information about the Mapbender_commits
mailing list