[Mapbender-commits] r5770 - in trunk/mapbender/http: classes
javascripts php
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Mar 15 11:05:53 EDT 2010
Author: christoph
Date: 2010-03-15 11:05:53 -0400 (Mon, 15 Mar 2010)
New Revision: 5770
Modified:
trunk/mapbender/http/classes/class_user.php
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/classes/class_wmcToXml.php
trunk/mapbender/http/classes/class_wms.php
trunk/mapbender/http/javascripts/mod_loadwmc.js
trunk/mapbender/http/javascripts/mod_loadwmc.php
trunk/mapbender/http/javascripts/mod_savewmc.js
trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
trunk/mapbender/http/php/mod_loadwmc_server.php
trunk/mapbender/http/php/mod_savewmc_server.php
trunk/mapbender/http/php/mod_wfs_gazetteer_server.php
Log:
* added wfs conf to wmc
* refactoring
* bug fixes
Modified: trunk/mapbender/http/classes/class_user.php
===================================================================
--- trunk/mapbender/http/classes/class_user.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/classes/class_user.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -456,11 +456,12 @@
if (func_num_args() === 1) {
$arg1 = func_get_arg(0);
- if (is_array($arg1)) {
- $appIdArray = $arg1;
-
- $guisByPer = array_intersect($guisByPer, $appIdArray);
+ if (!is_array($arg1)) {
+ $arg1 = array($arg1);
}
+
+ $appIdArray = $arg1;
+ $guisByPer = array_intersect($guisByPer, $appIdArray);
}
// $e = new mb_exception(serialize($guisByPer));
Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/classes/class_wmc.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -953,7 +953,10 @@
if ($this->overviewMap !== null) {
for ($i = 0; $i < count($ovWmsArray[$wmsIndexOverview]->objLayer); $i++) {
$visStr = "Mapbender.modules['".$this->overviewMap->getFrameName().
- "'].wms[" .$wmsIndexOverview . "].handleLayer(" .
+// "'].wms[" .$wmsIndexOverview . "].handleLayer(" .
+// The above doesn't work.
+// But there is only one WMS in the overview anyway! The index 0 is hard wired for now.
+ "'].wms[0].handleLayer(" .
"'" . $ovWmsArray[$wmsIndexOverview]->objLayer[$i]->layer_name . "', " .
"'visible', " .
($ovWmsArray[$wmsIndexOverview]->objLayer[$i]->gui_layer_visible ? 1 : 0) . ");";
Modified: trunk/mapbender/http/classes/class_wmcToXml.php
===================================================================
--- trunk/mapbender/http/classes/class_wmcToXml.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/classes/class_wmcToXml.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -245,6 +245,11 @@
$e_currentExtensionTag = $this->addExtension($keyExtensionData, $valueExtensionData);
$e_extensionGeneral->appendChild($e_currentExtensionTag);
}
+ foreach ($this->wmc->generalExtensionArray as $keyExtensionData => $valueExtensionData) {
+ $e_currentExtensionTag = $this->addExtension($keyExtensionData, $valueExtensionData);
+ $e_extensionGeneral->appendChild($e_currentExtensionTag);
+ }
+
$e_general->appendChild($e_extensionGeneral);
}
return $e_general;
@@ -420,7 +425,11 @@
$layerExtensionData["gui_queryable"] = $currentLayer->gui_layer_queryable;
$layerExtensionData["gui_status"] = $currentLayer->gui_layer_status;
$layerExtensionData["layer_epsg"] = $currentLayer->layer_epsg;
-
+
+ if ($currentLayer->gui_layer_wfs_featuretype !== "") {
+ $layerExtensionData["wfsFeatureType"] = $currentLayer->gui_layer_wfs_featuretype;
+ }
+
if ($currentOverviewLayer != null) {
$layerExtensionData["overviewData"] = array("overviewHidden" => ($currentOverviewLayer->gui_layer_visible ? 0 : 1));
}
Modified: trunk/mapbender/http/classes/class_wms.php
===================================================================
--- trunk/mapbender/http/classes/class_wms.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/classes/class_wms.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -1039,13 +1039,16 @@
else {
$newLayer->gui_layer_visible = $currentLayer["visible"];
}
+ if (isset($currentLayer["extension"]["WFSFEATURETYPE"])) {
+ $newLayer->gui_layer_wfs_featuretype = strval($currentLayer["extension"]["WFSFEATURETYPE"]);
+ }
+ else {
+ $newLayer->gui_layer_wfs_featuretype = "";
+ }
$newLayer->gui_layer_queryable = $currentLayer["extension"]["GUI_QUERYABLE"];
$newLayer->gui_layer_querylayer = $currentLayer["extension"]["QUERYLAYER"];
$newLayer->gui_layer_minscale = $currentLayer["extension"]["GUI_MINSCALE"];
$newLayer->gui_layer_maxscale = $currentLayer["extension"]["GUI_MAXSCALE"];
- if (isset($currentLayer["extension"]["WFSFEATURETYPE"])) {
- $newLayer->gui_layer_wfs_featuretype = $currentLayer["extension"]["WFSFEATURETYPE"];
- }
$newLayer->layer_abstract = $currentLayer["abstract"];
//
@@ -1135,6 +1138,7 @@
}
$str .= "wms_add_data_type_format('". $this->data_type[$i] ."','". $this->data_format[$i] ."');";
}
+
for($i=0; $i<count($this->objLayer); $i++){
if($parent){
$str .= "parent.";
Modified: trunk/mapbender/http/javascripts/mod_loadwmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.js 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.js 2010-03-15 15:05:53 UTC (rev 5770)
@@ -1,520 +1,640 @@
-var wmcPopup = null;
-var wmcDisplayPopup = null;
-var wmcOpenlayersPopup = null;
-var wmcTable;
-
-var serverSideFileName = "../php/mod_loadwmc_server.php";
-
-function mod_importWmc(id){
- alert(id);
-}
-
-var checkLayerIdExists = typeof options.checkLayerIdExists !== "undefined"
- && options.checkLayerIdExists === 1 ? true : false;
-
-var checkLayerIdValid = typeof options.checkLayerIdValid !== "undefined"
- && options.checkLayerIdValid === 1 ? true : false;
-
-var checkLayerPermission = typeof options.checkLayerPermission !== "undefined"
- && options.checkLayerPermission === 1 ? true : false;
-
-var checkLayerAvailability = typeof options.checkLayerAvailability !== "undefined"
- && options.checkLayerAvailability === 1 ? true : false;
-
+// set defaults
+options.checkLayerIdExists = options.checkLayerIdExists ? true : false;
+options.checkLayerIdValid = options.checkLayerIdValid ? true : false;
+options.checkLayerPermission = options.checkLayerPermission ? true : false;
+options.checkLayerAvailability = options.checkLayerAvailability ? true : false;
options.loadWmc = typeof options.loadWmc === "number" ? options.loadWmc : 1;
-options.mergeWmc = typeof options.mergeWmc === "number" ? options.mergeWmc : 1;
-options.appendWmc = typeof options.appendWmc === "number" ? options.appendWmc : 1;
+options.mergeWmc = typeof options.mergeWmc === "number" ? options.mergeWmc : 0;
+options.appendWmc = typeof options.appendWmc === "number" ? options.appendWmc : 0;
options.publishWmc = typeof options.publishWmc === "number" ? options.publishWmc : 0;
options.showWmc = typeof options.showWmc === "number" ? options.showWmc : 1;
options.openLayers = typeof options.openLayers === "number" ? options.openLayers : 1;
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;
+
+var originalI18nObject = {
+ "labelList": "List",
+ "labelUpload": "Upload",
+ "labelWmcName": "WMC name",
+ "labelLastUpdate": "last update",
+ "labelCreated": "created",
+ "labelLoad": "load",
+ "labelMerge": "merge",
+ "labelAppend": "append",
+ "labelPublic": "public",
+ "labelShow": "show",
+ "labelDelete": "delete",
+ "labelOpenLayers": "OpenLayers",
+ "labelCurrentState": "currentState",
+ "labelDeleteWmc": "delete this WMC",
+ "confirmDelete": "Do you really want to delete WMC '%s'?",
+ "labelLoadWmc": "load this WMC",
+ "labelMergeWmc": "merge this WMC",
+ "labelAppendWmc": "append WMC",
+ "messageLoadSuccess": "WMC has been loaded successfully.",
+ "messageMergeSuccess": "WMC has been merged successfully.",
+ "messageAppendSuccess":"WMC has been appended successfully.",
+ "labelDisplayWmc": "display WMC XML",
+ "labelWmcDocument": "WMC Document",
+ "labelOpenLayersExport": "export to OpenLayers",
+ "confirmLoadAnyway": "load Service anyway?"
+};
+
+var translatedI18nObject = Mapbender.cloneObject(originalI18nObject);
-var tagName = this.tagName.toUpperCase();
+var $loadWmc = $(this);
-if (tagName === "IMG") {
+var LoadWmcApi = function () {
+ var that = this;
+ var serverSideFileName = "../php/mod_loadwmc_server.php";
+ var wmcTable;
+ var wmcPopup = null;
+ var wmcDisplayPopup = null;
+ var wmcOpenLayersPopup = null;
- $(this).click(function () {
- if (wmcPopup === null || !wmcPopup.isVisible()) {
- mod_loadwmc();
- }
- }).mouseover(function () {
- if (options.src) {
- this.src = options.src.replace(/_off/, "_over");
- }
- }).mouseout(function () {
- if (options.src) {
- this.src = options.src;
- }
- });
-}
-else {
- mod_loadwmc();
-}
+ var LOAD_WMC_OPTIONS = {
+ src: "../img/button_gray/wmc_load.png",
+ title: translatedI18nObject.labelLoadWmc,
+ method: "loadWmc",
+ message: translatedI18nObject.messageLoadSuccess
+ };
-/**
- * is called when the load WMC button is pressed
- */
-function mod_loadwmc(){
+ var MERGE_WMC_OPTIONS = {
+ src: "../img/button_gray/wmc_merge.png",
+ title: translatedI18nObject.labelMergeWmc,
+ method: "mergeWmc",
+ message: translatedI18nObject.messageMergeSuccess
+ };
+
+ var APPEND_WMC_OPTIONS = {
+ src: "../img/button_gray/wmc_append.png",
+ title: translatedI18nObject.labelAppendWmc,
+ method: "appendWmc",
+ message: translatedI18nObject.messageAppendSuccess
+ };
+
+ var PUBLISH_WMC_OPTIONS = {
+ title: translatedI18nObject.labelPublishWmc,
+ method: "setWMCPublic"
+ };
+
+ var OPENLAYERS_WMC_OPTIONS = {
+ src: "../img/OpenLayers.trac.png",
+ title: translatedI18nObject.labelOpenLayersExport
+ };
+
+ var DELETE_WMC_OPTIONS = {
+ src: "../img/button_gray/del_disabled.png",
+ title: translatedI18nObject.labelDeleteWmc,
+ method: "deleteWmc"
+ };
+
+ var DISPLAY_WMC_OPTIONS = {
+ src: "../img/button_gray/wmc_xml.png",
+ title: translatedI18nObject.labelDisplayWmc
+ };
- var initialHtml = "<div style='display:none' id='" + options.id + "_tabs'>";
-
- //
- // add tabs if both modules are available
- //
- if (options.listWmc && options.uploadWmc) {
- initialHtml += "<ul>" +
- "<li><a href='#" + options.id + "_wmclist'><?php echo _mb("List"); ?></a></li>" +
- "<li><a href='#" + options.id + "_wmcUpload'><?php echo _mb("Upload"); ?></a></li>" +
- "</ul>";
- }
- if (options.listWmc || options.uploadWmc) {
- //
- // add listWMC if available
- //
- if (options.listWmc) {
- initialHtml += "<div id='" + options.id + "_wmclist' >" +
- "<table width='100%' id='" + options.id + "_wmclist_table'>" +
- "<thead><tr>" +
- "<th><?php echo _mb("WMC name"); ?></td>" +
- "<th><?php echo _mb("last update"); ?></td>" +
- "<th><?php echo _mb("created"); ?></td>";
- initialHtml += options.loadWmc ? "<th><?php echo _mb("load"); ?></td>" : "";
- initialHtml += options.mergeWmc ? "<th><?php echo _mb("merge"); ?></td>" : "";
- initialHtml += options.appendWmc ? "<th><?php echo _mb("append"); ?></td>" : "";
- initialHtml += options.publishWmc ? "<th><?php echo _mb("public"); ?></td>" : "";
- initialHtml += options.showWmc ? "<th><?php echo _mb("show"); ?></td>" : "";
- initialHtml += options.openLayers ? "<th><?php echo _mb("OpenLayers"); ?></td>" : "";
- initialHtml += options.deleteWmc ? "<th><?php echo _mb("delete"); ?></td>" : "";
-
- initialHtml += "</thead></tr>" +
- "</table>" +
- "</div>";
+ this.events = {
+ loaded: new Mapbender.Event()
+ };
+
+ this.load = function (id) {
+ loadMergeAppendCallback($.extend(LOAD_WMC_OPTIONS, {
+ parameters: {
+ id: id
+ }
+ }));
+ };
+
+ this.show = function () {
+ // creates a new pop up (if it doesn't already exist)
+ // the pop up allows you to load, append, merge,
+ // display and delete WMC documents
+ if (tagName === "IMG") {
+ if (wmcPopup === null) {
+ wmcPopup = new mb_popup({
+ title: options.currentTitle,
+ width: 750,
+ height: 500,
+ top: 50,
+ left: 100,
+ html: getInitialDialogHtml(options.id)
+ });
+ }
+
+ // display the pop up
+ if (!wmcPopup.isVisible()) {
+ wmcPopup.setHtml(getInitialDialogHtml(options.id));
+ wmcPopup.show();
+ }
}
- //
- // add uploadWMC if available
- //
- if (options.uploadWmc) {
- initialHtml += "<div id='" + options.id + "_wmcUpload' >" +
- "</div>";
+ else {
+ $loadWmc.html(getInitialDialogHtml(options.id));
}
- }
- else {
- return;
- }
- initialHtml += "</div>";
-
- // creates a new pop up (if it doesn't already exist)
- // the pop up allows you to load, append, merge,
- // display and delete WMC documents
- if (tagName === "IMG") {
- if (wmcPopup === null) {
- wmcPopup = new mb_popup({
- title: options.currentTitle,
- width: 750,
+ this.refreshList();
+ };
+
+ this.hide = function () {
+ if (wmcPopup !== null && wmcPopup.isVisible()) {
+ wmcPopup.hide();
+ }
+ this.hideWmcXml();
+ this.hideOpenLayers();
+ };
+
+ this.showWmcXml = function (id) {
+ var url = "../javascripts/mod_displayWmc.php?wmc_id=" + id + "&" + mb_session_name + "=" + mb_nr;
+ if (wmcDisplayPopup === null) {
+ wmcDisplayPopup = new mb_popup({
+ title: translatedI18nObject.labelWmcDocument,
+ width: 600,
height: 500,
top: 50,
- left: 100,
- html: initialHtml
+ left: 700,
+ url: url
});
}
-
- // display the pop up
- if (!wmcPopup.isVisible()) {
- wmcPopup.setHtml(initialHtml);
- wmcPopup.show();
+ else {
+ wmcDisplayPopup.setUrl(url);
}
- }
- else {
- $("#" + options.id).html(initialHtml);
- }
-
- // get WMC data from server
- var req = new Mapbender.Ajax.Request({
- url: serverSideFileName,
- method: "getWmc",
- callback: function(obj, result, message){
- if (!result) {
- new Mb_exception(obj.message);
- return;
+ wmcDisplayPopup.show();
+ };
+
+ this.hideWmcXml = function () {
+ if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
+ wmcDisplayPopup.hide();
+ }
+ };
+
+ this.showOpenLayers = function (id) {
+ var url = "../php/mod_wmc2ol.php?wmc_id=" + id + "&" + mb_session_name + "=" + mb_nr;
+ if (wmcOpenLayersPopup === null) {
+ wmcOpenLayersPopup = new mb_popup({
+ title: translatedI18nObject.labelOpenLayers,
+ width: 600,
+ height: 500,
+ top: 40,
+ left: 600,
+ url: url
+ });
+ }
+ else {
+ wmcOpenLayersPopup.setUrl(url);
+ }
+ wmcOpenLayersPopup.show();
+ };
+
+ this.hideOpenLayers = function () {
+ if (wmcOpenLayersPopup !== null && wmcOpenLayersPopup.isVisible()) {
+ wmcOpenLayersPopup.hide();
+ }
+ };
+
+ this.refreshList = function () {
+ var req = new Mapbender.Ajax.Request({
+ url: serverSideFileName,
+ method: "getWmc",
+ callback: function(obj, result, message){
+ if (!result) {
+ new Mapbender.Exception(obj.message);
+ return;
+ }
+ displayWmcList(obj, status);
}
- displayWmcList(obj, status);
+ });
+ req.send();
+ };
+
+ var getInitialDialogHtml = function (id) {
+
+ if (!options.listWmc && !options.uploadWmc) {
+ return "";
}
- });
- req.send();
-}
+ var initialHtml = "";
-/**
- * Displays available WMC documents
- */
-function displayWmcList (wmcObj, status) {
- //
- // for each wmc, add a row to the table
- //
- for (var i=0; i < wmcObj.wmc.length; i++) {
- (function () {
- var currentId = wmcObj.wmc[i].id;
- var currentName = wmcObj.wmc[i].title;
- var isPublic = wmcObj.wmc[i].isPublic;
- var isDisabled = wmcObj.wmc[i].disabled;
- var $tr = $("<tr></tr>").appendTo($("#" + options.id + "_wmclist_table"));
- var $td;
- $tr.append($("<td>" + wmcObj.wmc[i].title + "</td>"));
- $tr.append($("<td>" + wmcObj.wmc[i].timestamp + "</td>"));
- $tr.append($("<td>" + wmcObj.wmc[i].timestamp_create + "</td>"));
+ // add tabs if both modules are available
+ if (options.listWmc && options.uploadWmc) {
+ initialHtml += "<ul><li><a href='#" + id + "_wmclist'>" +
+ translatedI18nObject.labelList +
+ "</a></li><li><a href='#" + id + "_wmcUpload'>" +
+ translatedI18nObject.labelUpload + "</a></li></ul>";
+ }
- if (options.loadWmc) {
-
- // Load WMC
- var $loadTd = appendTableCell({
- src: "../img/button_gray/wmc_load.png",
- title: "<?php echo _mb("load this WMC"); ?>",
- method: "loadWmc",
- message: "<?php echo _mb("WMC has been loaded successfully."); ?>",
- parameters: {
- id: currentId
- },
- callback: function(args){
- if (constraintCheckRequired()) {
- checkConstraints(args, function(args){
- executeJavaScript(args);
- });
- return;
- }
- executeJavaScript(args);
- }
- });
- $tr.append($loadTd);
- }
+ // add listWMC if available
+ var t = translatedI18nObject;
+ if (options.listWmc) {
+ initialHtml += "<div id='" + id + "_wmclist' >" +
+ "<table width='100%' id='" + id + "_wmclist_table'>" +
+ "<thead><tr>" +
+ "<th>" + t.labelWmcName + "</td>" +
+ "<th>" + t.labelLastUpdate + "</td>" +
+ "<th>" + t.labelCreated + "</td>" +
+ (options.loadWmc ? "<th>" + t.labelLoad + "</td>" : "") +
+ (options.mergeWmc ? "<th>" + t.labelMerge + "</td>" : "") +
+ (options.appendWmc ? "<th>" + t.labelAppend + "</td>" : "") +
+ (options.publishWmc ? "<th>" + t.labelPublic + "</td>" : "") +
+ (options.showWmc ? "<th>" + t.labelShow + "</td>" : "") +
+ (options.openLayers ? "<th>" + t.labelOpenLayers + "</td>" : "") +
+ (options.deleteWmc ? "<th>" + t.labelDelete + "</td>" : "") +
+ "</thead></tr></table></div>";
+ }
- if (options.mergeWmc) {
- // Merge WMC
- var $mergeTd = appendTableCell({
- src: "../img/button_gray/wmc_merge.png",
- title: "<?php echo _mb("merge WMC"); ?>",
- method: "mergeWmc",
- message: "<?php echo _mb("WMC has been merged successfully."); ?>",
- parameters: {
- id: currentId,
- extensionData: currentWmcExtensionData !== null ? currentWmcExtensionData : null,
- mapObject: mb_mapObj,
- generalTitle: "currentState"
- },
- callback: function(args){
- if (constraintCheckRequired()) {
- checkConstraints(args, function(args){
- executeJavaScript(args);
- });
- return;
- }
- executeJavaScript(args);
+ // add uploadWMC if available
+ if (options.uploadWmc) {
+ initialHtml += "<div id='" + id + "_wmcUpload' ></div>";
+ }
+ return "<div style='display:none' id='" + id + "_tabs'>" + initialHtml + "</div>";
+ };
+
+ /**
+ * args.method
+ * args.parameters
+ * args.message
+ */
+ var executeJavaScript = function (args) {
+ var req = new Mapbender.Ajax.Request({
+ url: serverSideFileName,
+ method: args.method,
+ parameters: args.parameters,
+ callback: function (obj, result, message) {
+ if (!result) {
+ new Mapbender.Warning(message);
+ return;
+ }
+ try {
+ if (args.method === "deleteWmc" || args.method === "setWMCPublic"){
+ return;
}
- });
- $tr.append($mergeTd);
- }
-
- if (options.appendWmc) {
- // Append WMC
- var $appendTd = appendTableCell({
- src: "../img/button_gray/wmc_append.png",
- title: "<?php echo _mb("append WMC"); ?>",
- method: "appendWmc",
- message: "<?php echo _mb("WMC has been appended successfully."); ?>",
- parameters: {
- id: currentId,
- extensionData: currentWmcExtensionData !== null ? currentWmcExtensionData : null,
- mapObject: mb_mapObj,
- generalTitle: "<?php echo _mb("currentState"); ?>"
- },
- callback: function(args){
- if (constraintCheckRequired()) {
- checkConstraints(args, function(args){
- executeJavaScript(args);
- });
- return;
+ if (obj.javascript && typeof(obj.javascript) == "object") {
+ for (var j = 0; j < obj.javascript.length; j++) {
+// var e = new Mb_notice("Statement: " + obj.javascript[j]);
+// console.log("Statement: " + obj.javascript[j]);
+ eval(obj.javascript[j]);
}
- executeJavaScript(args);
- }
- });
- $tr.append($appendTd);
- }
-
- if (options.publishWmc) {
- //WMC is Public
- var $publicTd = appendBoolTableCell({
- isPublic: isPublic,
- disabled: isDisabled,
- method: "setWMCPublic",
- parameters: {
- id: currentId
- },
- callback: executeJavaScript
- });
- $tr.append($publicTd);
- }
-
- // Display WMC
- if (options.showWmc) {
- var $displayTd = appendTableCell({
- src: "../img/button_gray/wmc_xml.png",
- title: "<?php echo _mb("display WMC XML"); ?>",
- callback: function(){
- // create Popup
- if (wmcDisplayPopup === null) {
- wmcDisplayPopup = new mb_popup({
- title: "<?php echo _mb("WMC Document"); ?>",
- width: 600,
- height: 500,
- top: 50,
- left: 700,
- url: "../javascripts/mod_displayWmc.php?wmc_id=" + currentId
+ if (args.method === "loadWmc") {
+ that.events.loaded.trigger({
+ extensionData: restoredWmcExtensionData
});
}
- else {
- wmcDisplayPopup.setUrl("../javascripts/mod_displayWmc.php?wmc_id=" + currentId + "&" + mb_session_name + "=" + mb_nr);
- }
- // display the pop up
- wmcDisplayPopup.show();
- }
- });
- $tr.append($displayTd);
- }
-
- if (options.openLayers) {
- // OpenLayers Export
- var $openLayersTd = appendTableCell({
- src: "../img/OpenLayers.trac.png",
- title: "<?php echo _mb("export to OpenLayers"); ?>",
- callback: function(){
- // create Popup
- if (wmcOpenlayersPopup === null) {
- wmcOpenlayersPopup = new mb_popup({
- title: "<?php echo _mb("OpenLayers"); ?>",
- width: 600,
- height: 500,
- top: 40,
- left: 600,
- url: "../php/mod_wmc2ol.php?wmc_id=" + currentId +
- "&" +
- mb_session_name +
- "=" +
- mb_nr
- });
- }
- else {
- // set correct URL
- wmcOpenlayersPopup.setUrl("../php/mod_wmc2ol.php?wmc_id=" + currentId + "&" + mb_session_name + "=" + mb_nr);
- }
- // display the pop up
- wmcOpenlayersPopup.show();
- }
- });
- $tr.append($openLayersTd);
- }
-
- if (options.deleteWmc) {
- // delete WMC
- (function(){
- var $deleteTd = appendTableCell({
- src: isDisabled ? "../img/button_gray/del_disabled.png" : "../img/button_gray/del.png",
- title: "<?php echo _mb("delete this WMC"); ?>",
- method: "deleteWmc",
- callback: function(args){
- if (!isDisabled && confirm("<?php echo _mb("Do you really want to delete WMC"); ?> '" + currentName + "'?")) {
- executeJavaScript(args);
- var aPos = wmcTable.fnGetPosition($deleteTd.get(0));
- wmcTable.fnDeleteRow(aPos[0]);
- }
- },
- parameters: {
- id: currentId
- }
- });
- $tr.append($deleteTd);
- })();
- }
- })();
- }
-
-
- if (options.listWmc && options.uploadWmc) {
- $("#" + options.id + "_tabs").tabs();
- }
-
- if (options.uploadWmc) {
- $("#" + options.id + "_wmcUpload").upload({
- callback: function(filename, success, message){
- if (!success) {
- new Mb_exception(message);
- alert(message);
+ }
+ that.hide();
+ new Mapbender.Notice(args.message);
}
- executeJavaScript({
- method: "loadWmcFromFile",
- parameters: {
- filename: filename
- },
- message: "<?php echo _mb("WMC has been loaded successfully."); ?>"
- });
+ catch (e) {
+ new Mapbender.Exception(e.message);
+ }
}
});
- }
- if (options.listWmc) {
+ req.send();
+ };
- wmcTable = $("#" + options.id + "_wmclist_table").dataTable({
- "bPaginate": true,
- "bJQueryUI": true
+ var loadMergeAppendCallback = function(args){
+ if (constraintCheckRequired()) {
+ checkConstraints(args, function(args){
+ executeJavaScript(args);
+ });
+ return;
+ }
+ executeJavaScript(args);
+ };
+
+ var createTableCell = function (args, callback) {
+ var $img = $("<img src='" + args.src + "' style='cursor:pointer' title='" + args.title + "'>");
+ $img.click(function() {
+ callback(args);
});
- }
+ return $("<td></td>").append($img);
+ };
- $("#" + options.id + "_tabs").css("display", "block");
+ var appendBoolTableCell = function (args, callback) {
+ var checked = args.isPublic ? 'checked="checked" ':'' ;
+ var disabled = args.disabled ? 'disabled="disabled" ':'' ;
+ var checkbox = $('<input type="checkbox" '+ checked + disabled + ' />');
+ checkbox.change(function(){
+ args.parameters.isPublic = $(this).attr('checked') ? 1 : 0;
+ callback(args);
+ });
+ return $("<td></td>").append(checkbox);
+ };
-}
+ var createLoadWmcCell = function (wmc) {
+ return createTableCell(
+ $.extend({
+ parameters: {
+ id: wmc.id
+ }
+ }, LOAD_WMC_OPTIONS),
+ loadMergeAppendCallback
+ );
+ };
+
+ var createMergeWmcCell = function (wmc) {
+ //
+ // WORKAROUND....cannot serialize map object,
+ // as it contains a jQuery collection, which is
+ // cyclic.
+ // Removing the $target from the map object before
+ // serialization, and re-appending it afterwards
+ //
+ var $target = [];
+ for (var i = 0; i < mb_mapObj.length; i++) {
+ $target.push(mb_mapObj[i].$target);
+ delete mb_mapObj[i].$target;
+ }
+
+ var $cell = createTableCell(
+ $.extend({
+ parameters: {
+ id: wmc.id,
+ extensionData: currentWmcExtensionData !== null ? currentWmcExtensionData : null,
+ mapObject: $.toJSON(mb_mapObj),
+ generalTitle: translatedI18nObject.labelCurrentState
+ }
+ }, MERGE_WMC_OPTIONS),
+ loadMergeAppendCallback
+ );
-function constraintCheckRequired () {
- return checkLayerIdExists
- || checkLayerIdValid
- || checkLayerPermission
- || checkLayerAvailability;
-}
+ //
+ // reversal of above WORKAROUND
+ //
+ for (var i = 0; i < mb_mapObj.length; i++) {
+ mb_mapObj[i].$target = $target[i];
+ }
+ return $cell;
+ };
+
+ var createAppendWmcCell = function (wmc) {
+ //
+ // WORKAROUND....cannot serialize map object,
+ // as it contains a jQuery collection, which is
+ // cyclic.
+ // Removing the $target from the map object before
+ // serialization, and re-appending it afterwards
+ //
+ var $target = [];
+ for (var i = 0; i < mb_mapObj.length; i++) {
+ $target.push(mb_mapObj[i].$target);
+ delete mb_mapObj[i].$target;
+ }
+
+ var $cell = createTableCell(
+ $.extend({
+ parameters: {
+ id: wmc.id,
+ extensionData: currentWmcExtensionData !== null ? currentWmcExtensionData : null,
+ mapObject: $.toJSON(mb_mapObj),
+ generalTitle: translatedI18nObject.labelCurrentState
+ }
+ }, APPEND_WMC_OPTIONS),
+ loadMergeAppendCallback
+ );
-function checkConstraints (args, callback) {
- var req = new Mapbender.Ajax.Request({
- url: serverSideFileName,
- method: "checkConstraints",
- parameters: {
- id: args.parameters.id,
- checkLayerIdExists: checkLayerIdExists,
- checkLayerIdValid: checkLayerIdValid,
- checkLayerPermission: checkLayerPermission,
- checkLayerAvailability: checkLayerAvailability
- },
- callback: function (obj, result, message) {
-
- var html = "";
- var constraintTypeArray = [];
- for (var constraintType in obj) {
- var caseObj = obj[constraintType];
+ //
+ // reversal of above WORKAROUND
+ //
+ for (var i = 0; i < mb_mapObj.length; i++) {
+ mb_mapObj[i].$target = $target[i];
+ }
+ return $cell;
+ };
+
+ var createPublishWmcCell = function (wmc) {
+ return appendBoolTableCell(
+ $.extend(PUBLISH_WMC_OPTIONS, {
+ isPublic: wmc.isPublic,
+ disabled: wmc.disabled,
+ parameters: {
+ id: wmc.id
+ }
+ }),
+ executeJavaScript
+ );
+ };
- if (caseObj.wms.length === 0) {
- continue;
+ var createOpenLayersWmcCell = function (wmc) {
+ return createTableCell(
+ OPENLAYERS_WMC_OPTIONS, function(){
+ that.showOpenLayers(wmc.id);
+ }
+ );
+ };
+
+ var createDisplayWmcCell = function (wmc) {
+ return createTableCell(
+ DISPLAY_WMC_OPTIONS,
+ function(){
+ that.showWmcXml(wmc.id);
+ }
+ );
+ };
+
+ var createDeleteWmcCell = function (wmc) {
+ var $deleteTd = createTableCell(
+ $.extend(DELETE_WMC_OPTIONS, {
+ src: wmc.disabled ? "../img/button_gray/del_disabled.png" : "../img/button_gray/del.png",
+ parameters: {
+ id: wmc.id
}
-
- html += "<fieldset>" + caseObj.message + " <?php echo _mb("load Service anyway?"); ?><br><br>";
+ }),
+ function(args){
+ if (!wmc.disabled && confirm(Mapbender.sprintf(translatedI18nObject.confirmDelete, wmc.title))) {
+ executeJavaScript(args);
+ var aPos = wmcTable.fnGetPosition($deleteTd.get(0));
+ wmcTable.fnDeleteRow(aPos[0]);
+ }
+ }
+ );
+ return $deleteTd;
+ };
+
+ var displayWmcList = function (wmcObj, status) {
+ // create table
+ for (var i=0; i < wmcObj.wmc.length; i++) {
+ (function () {
+ var currentIndex = i;
+ var currentWmc = wmcObj.wmc[currentIndex];
- for (var index in caseObj.wms) {
- var wms = caseObj.wms[index];
- html += "<label for='" + constraintType + "_" + wms.index + "'>" +
- "<input id='" + options.id + "_" + constraintType + "_" + wms.index + "' " +
- "type='checkbox' />" + wms.title + "</label><br>";
+ var $tr = $("<tr></tr>").append("<td>" + currentWmc.title + "</td><td>" +
+ currentWmc.timestamp + "</td><td>" +
+ currentWmc.timestamp_create + "</td>"
+ );
+
+ if (options.loadWmc) {
+ $tr.append(createLoadWmcCell(currentWmc));
}
- html += "</fieldset><br>";
- constraintTypeArray.push(constraintType);
- }
-
- $("<div id='" + options.id + "_constraint_form' title='Warning'>" +
- "<style> fieldset label { display: block; }</style>" +
- "<form>" + html + "</form></div>").dialog(
- {
- bgiframe: true,
- autoOpen: false,
- height: 400,
- width: 500,
- modal: true,
- buttons: {
- "Continue": function(){
- var skipWmsArray = [];
- for (var i in constraintTypeArray) {
- var currentConstraint = constraintTypeArray[i];
- var selector = options.id + "_" + currentConstraint + "_";
- var context = $("#" + options.id + "_constraint_form").get(0);
- $("input[id^='" + selector + "']", context).each(function () {
- if (!this.checked) {
- var regexp = new RegExp(selector);
- var id = parseInt(this.id.replace(regexp, ""), 10);
- skipWmsArray.push(id);
- }
- });
- }
- args.parameters.skipWms = skipWmsArray;
- if (typeof callback === "function") {
- callback(args);
- }
- $(this).dialog('close').remove();
+ if (options.mergeWmc) {
+ $tr.append(createMergeWmcCell(currentWmc));
+ }
+ if (options.appendWmc) {
+ $tr.append(createAppendWmcCell(currentWmc));
+ }
+ if (options.publishWmc) {
+ $tr.append(createPublishWmcCell(currentWmc));
+ }
+ if (options.showWmc) {
+ $tr.append(createDisplayWmcCell(currentWmc));
+ }
+ if (options.openLayers) {
+ $tr.append(createOpenLayersWmcCell(currentWmc));
+ }
+ if (options.deleteWmc) {
+ $tr.append(createDeleteWmcCell(currentWmc));
+ }
+ $tr.appendTo("#" + options.id + "_wmclist_table");
+ })();
+ }
+
+ // create horizontal tabs
+ if (options.listWmc && options.uploadWmc) {
+ $("#" + options.id + "_tabs").tabs().css("display", "block");
+ }
+
+ // create upload
+ if (options.uploadWmc) {
+ $("#" + options.id + "_wmcUpload").upload({
+ callback: function(filename, success, message){
+ if (!success) {
+ new Mb_exception(message);
+ alert(message);
+ }
+ executeJavaScript({
+ method: "loadWmcFromFile",
+ parameters: {
+ filename: filename
},
- "Cancel": function(){
- $(this).dialog('close').remove();
- }
- }
+ message: translatedI18nObject.messageLoadSuccess
+ });
}
- );
-
- $("#" + options.id + "_constraint_form").dialog('open');
+ });
}
- });
- req.send();
-}
-
-function executeJavaScript (args) {
- var req = new Mapbender.Ajax.Request({
- url: serverSideFileName,
- method: args.method, // loadWmc
- parameters: args.parameters,
- callback: function (obj, result, message) {
- if (!result) {
- new Mb_warning(message);
- return;
- }
- try {
- if (args.method === "deleteWmc") {
+
+ // create datatables
+ if (options.listWmc) {
+ wmcTable = $("#" + options.id + "_wmclist_table").dataTable({
+ "bPaginate": true,
+ "bJQueryUI": true
+ });
+ }
+ };
+
+ var constraintCheckRequired = function () {
+ return options.checkLayerIdExists
+ || options.checkLayerIdValid
+ || options.checkLayerPermission
+ || options.checkLayerAvailability;
+ };
+
+ var checkConstraints = function (args, callback) {
+ var req = new Mapbender.Ajax.Request({
+ url: serverSideFileName,
+ method: "checkConstraints",
+ parameters: {
+ id: args.parameters.id,
+ checkLayerIdExists: options.checkLayerIdExists,
+ checkLayerIdValid: options.checkLayerIdValid,
+ checkLayerPermission: options.checkLayerPermission,
+ checkLayerAvailability: options.checkLayerAvailability
+ },
+ callback: function (obj, result, message) {
+
+ var html = "";
+ var constraintTypeArray = [];
+ for (var constraintType in obj) {
+ var caseObj = obj[constraintType];
+
+ if (caseObj.wms.length === 0) {
+ continue;
+ }
+
+ html += "<fieldset>" + caseObj.message + translatedI18nObject.confirmLoadAnyway + "<br><br>";
+ for (var index in caseObj.wms) {
+ var wms = caseObj.wms[index];
+ html += "<label for='" + constraintType + "_" + wms.index + "'>" +
+ "<input id='" + options.id + "_" + constraintType + "_" + wms.index + "' " +
+ "type='checkbox' />" + wms.title + "</label><br>";
+ }
+ html += "</fieldset><br>";
+ constraintTypeArray.push(constraintType);
}
- else if (args.method == "setWMCPublic"){
-
- }
- else {
- if (obj.javascript && typeof(obj.javascript) == "object") {
- for (var j = 0; j < obj.javascript.length; j++) {
-// var e = new Mb_notice("Statement: " + obj.javascript[j]);
- eval(obj.javascript[j]);
+
+ $("<div id='" + options.id + "_constraint_form' title='Warning'>" +
+ "<style> fieldset label { display: block; }</style>" +
+ "<form>" + html + "</form></div>").dialog(
+ {
+ bgiframe: true,
+ autoOpen: false,
+ height: 400,
+ width: 500,
+ modal: true,
+ buttons: {
+ "Continue": function () {
+ var skipWmsArray = [];
+ for (var i in constraintTypeArray) {
+ var currentConstraint = constraintTypeArray[i];
+ var selector = options.id + "_" + currentConstraint + "_";
+ var context = $("#" + options.id + "_constraint_form").get(0);
+ $("input[id^='" + selector + "']", context).each(function () {
+ if (!this.checked) {
+ var regexp = new RegExp(selector);
+ var id = parseInt(this.id.replace(regexp, ""), 10);
+ skipWmsArray.push(id);
+ }
+ });
+ }
+ args.parameters.skipWms = skipWmsArray;
+ if (typeof callback === "function") {
+ callback(args);
+ }
+ $(this).dialog('close').remove();
+ },
+ "Cancel": function(){
+ $(this).dialog('close').remove();
+ }
}
- }
- // close the Pop ups
- if (wmcDisplayPopup !== null && wmcDisplayPopup.isVisible()) {
- wmcDisplayPopup.hide();
}
- wmcPopup.hide();
- new Mb_notice(args.message);
-
- }
-
+ );
+
+ $("#" + options.id + "_constraint_form").dialog('open');
}
- catch (e) {
- new Mb_exception(e.message);
+ });
+ req.send();
+ };
+
+ //
+ // constructor
+ //
+ var tagName = $loadWmc.get(0).tagName.toUpperCase();
+ if (tagName === "IMG") {
+
+ $loadWmc.click(function () {
+ that.show();
+ }).mouseover(function () {
+ if (options.src) {
+ this.src = options.src.replace(/_off/, "_over");
}
- }
- });
- req.send();
+ }).mouseout(function () {
+ if (options.src) {
+ this.src = options.src;
+ }
+ });
+ }
+ else {
+ that.show();
+ }
-}
+ // checks if element var loadFromSession exists
+ if (loadFromSession === undefined) {
+ loadFromSession = 0;
+ }
+
+ if (loadFromSession) {
+ Mapbender.events.init.register(function () {
+ load_wmc_session();
+ });
+ }
+};
-function appendTableCell (args) {
- var $img = $("<img src='" + args.src + "' style='cursor:pointer' title='" + args.title + "'>");
- $img.click(function() {
- args.callback(args);
- });
- return $("<td></td>").append($img);
-}
-
-function appendBoolTableCell (args){
- var checked = args.isPublic == true ? 'checked="checked" ':'' ;
- var disabled = args.disabled == true ? 'disabled="disabled" ':'' ;
- var checkbox = $('<input type="checkbox" '+ checked + disabled + ' />');
- checkbox.change(function(){
- args.parameters.isPublic = $(this).attr('checked') ? 1 : 0;
- args.callback(args);
- })
- return $("<td></td>").append(checkbox);
-
-}
+$loadWmc.mapbender(new LoadWmcApi());
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/mod_loadwmc.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_loadwmc.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/javascripts/mod_loadwmc.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -93,8 +93,8 @@
$e = new mb_notice("NOT merging with WMS in Session...");
$output = createJs(false);
}
- echo "\nvar loadFromSession = " . $loadFromSession . ";";
}
+echo "\nvar loadFromSession = " . intval($loadFromSession) . ";";
$output = administration::convertOutgoingString($output);
echo "function load_wmc_session() {";
@@ -111,15 +111,4 @@
// Creates a pop up with a dialogue to load, view or delete WMC documents
//
include("mod_loadwmc.js");
-?>
-
-// checks if element var loadFromSession exists
-if (typeof loadFromSession === undefined) {
- var loadFromSession = 0;
-}
-
-if (loadFromSession) {
- Mapbender.events.init.register(function () {
- load_wmc_session();
- });
-}
\ No newline at end of file
+?>
\ No newline at end of file
Modified: trunk/mapbender/http/javascripts/mod_savewmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.js 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/javascripts/mod_savewmc.js 2010-03-15 15:05:53 UTC (rev 5770)
@@ -77,9 +77,9 @@
saved: new Mapbender.Event()
};
- this.setExtensionData = function (key, value) {
- if (typeof key === "string") {
- this.extensionData[key] = value;
+ this.setExtensionData = function (obj) {
+ if (typeof obj === "object") {
+ $.extend(this.extensionData, obj);
}
return this;
};
Modified: trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php
===================================================================
--- trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/javascripts/mod_wfs_gazetteer_client.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -279,6 +279,25 @@
* event is fired whenever the form is resetted
*/
ev.onFormReset = new parent.Mapbender.Event();
+
+
+ parent.Mapbender.modules.savewmc.setExtensionData({
+ wfsConfIdString: wfsConfIdString
+ });
+ parent.Mapbender.modules.loadwmc.events.loaded.register(function (obj) {
+ console.log(obj);
+ if (obj.extensionData && obj.extensionData.WFSCONFIDSTRING) {
+ wfsConfIdString = "";
+ appendWfsConf(obj.extensionData.WFSCONFIDSTRING);
+ }
+ });
+
+ // creates a Highlight object for the request geometry
+ var styleProperties = {"position":"absolute", "top":"0px", "left":"0px", "z-index":100};
+ requestGeometryHighlight = new parent.Highlight(targetArray, "requestGeometryHighlight", styleProperties, 2);
+ parent.mb_registerSubFunctions("window.frames['" + frameName +"'].requestGeometryHighlight.paint()");
+
+
initModWfsGazetteer();
init_wfsSpatialRequest();
}
@@ -548,16 +567,10 @@
// Would be much nicer to have
// initWFSConf() and reloadWFSConf
- parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConfsForThisApplication",wfsConfIdString:wfsConfIdString}, function(json,status) {
+ parent.mb_ajax_json("../php/mod_wfs_gazetteer_server.php", {command:"getWfsConf",wfsConfIdString:wfsConfIdString}, function(json,status) {
reapplyWFSConfObject(json, status);
localizeGazetteer();
});
-
- // creates a Highlight object for the request geometry
- var styleProperties = {"position":"absolute", "top":"0px", "left":"0px", "z-index":100};
- requestGeometryHighlight = new parent.Highlight(targetArray, "requestGeometryHighlight", styleProperties, 2);
- parent.mb_registerSubFunctions("window.frames['" + frameName +"'].requestGeometryHighlight.paint()");
-
}
function clearWFSGazetteer()
@@ -571,30 +584,27 @@
}
}
-function reapplyWFSConfObject(json,status)
-{
- clearWFSGazetteer();
- global_wfsConfObj = json;
- var wfsCount = 0;
- for (var wfsConfId in global_wfsConfObj) {
- global_selectedWfsConfId = wfsConfId;
- if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
- wfsCount++;
- }
+function reapplyWFSConfObject(json,status) {
+ clearWFSGazetteer();
+ global_wfsConfObj = json;
+ var wfsCount = 0;
+ for (var wfsConfId in global_wfsConfObj) {
+ global_selectedWfsConfId = wfsConfId;
+ if (typeof(global_wfsConfObj[wfsConfId] != 'function')) {
+ wfsCount++;
}
- if (wfsCount === 0) {
- var e = new parent.Mb_exception("no wfs conf id available.");
- }
- else if (wfsCount === 1) {
- appendStyles();
- appendWfsForm();
- }
- else {
- appendWfsConfSelectBox();
-
- }
- parent.mb_setWmcExtensionData({"wfsConfIdString":wfsConfIdString});
-
+ }
+ if (wfsCount === 0) {
+ var e = new parent.Mb_exception("no wfs conf id available.");
+ }
+ else if (wfsCount === 1) {
+ appendStyles();
+ appendWfsForm();
+ }
+ else {
+ appendWfsConfSelectBox();
+
+ }
}
function setWfsInfo() {
Modified: trunk/mapbender/http/php/mod_loadwmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_loadwmc_server.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/php/mod_loadwmc_server.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -7,7 +7,7 @@
require_once(dirname(__FILE__) . "/../classes/class_administration.php");
$ajaxResponse = new AjaxResponse($_POST);
-
+$json = new Mapbender_JSON();
$userId = Mapbender::session()->get("mb_user_id");
$currentUser = new User($userId);
@@ -55,7 +55,7 @@
// loads a WMC (returns array of JS code)
case 'loadWmc':
$wmcId = $ajaxResponse->getParameter("id");
- $wmc->createFromDb($wmcId);
+ $wmc->createFromDb($wmcId);
// FIXME: maybe wrap in if condition (configurable by element vars)
$updatedWMC = $wmc->updateUrlsFromDb();
@@ -86,7 +86,6 @@
$updatedWMC = $wmc->updateUrlsFromDb();
$wmc->createFromXml($updatedWMC);
-
$jsArray = $wmc->toJavaScript();
if ($jsArray) {
$resultObj["javascript"] = $jsArray;
@@ -104,7 +103,7 @@
// generate a WMC for the current client state
$currentWmc = new wmc();
$currentWmc->createFromJs(
- $ajaxResponse->getParameter("mapObject"),
+ $json->decode($ajaxResponse->getParameter("mapObject")),
$ajaxResponse->getParameter("generalTitle"),
$ajaxResponse->getParameter("extensionData")
);
@@ -135,7 +134,7 @@
// generate a WMC for the current client state
$currentWmc = new wmc();
$currentWmc->createFromJs(
- $ajaxResponse->getParameter("mapObject"),
+ $json->decode($ajaxResponse->getParameter("mapObject")),
$ajaxResponse->getParameter("generalTitle"),
$ajaxResponse->getParameter("extensionData")
);
Modified: trunk/mapbender/http/php/mod_savewmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_savewmc_server.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/php/mod_savewmc_server.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -13,27 +13,26 @@
require_once(dirname(__FILE__)."/../classes/class_json.php");
$ajaxResponse = new AjaxResponse($_POST);
-if($ajaxResponse->getMethod() != "saveWMC")
-{
+if($ajaxResponse->getMethod() != "saveWMC") {
$ajaxResponse->setSuccess(false);
$ajaxResponse->setMessage("method invalid");
$ajaxResponse->send();
exit;
}
+$json = new Mapbender_JSON();
+
// get data from POST and SESSION
$userId = Mapbender::session()->get("mb_user_id");
$mapObject = $ajaxResponse->getParameter('mapObject');
$saveInSession = $ajaxResponse->getParameter('saveInSession');
-$extensionData = $ajaxResponse->getParameter('extensionData');
+$extensionData = $json->decode($ajaxResponse->getParameter('extensionData'));
$attributes = $ajaxResponse->getParameter('attributes');
$overwrite = $ajaxResponse->getParameter('overwrite');
$overwrite = $overwrite == "1" ? true : false;
-$json = new Mapbender_JSON();
$mapObject = $json->decode($mapObject);
-
// create WMC object
$wmc = new wmc();
$wmc->createFromJs($mapObject, $attributes->title, $extensionData);
@@ -50,7 +49,6 @@
}
else {
// insert WMC into database
-
if(isset($attributes->title)) {
$attributes->title = trim($attributes->title);
@@ -60,15 +58,14 @@
$ajaxResponse->send();
exit;
}
- }else{
-
+ }
+ else{
$ajaxResponse->setSuccess(false);
$ajaxResponse->setMessage(_mb("WMC document must have a title."));
$ajaxResponse->send();
exit;
}
- foreach($mapObject as $map)
- {
+ foreach($mapObject as $map) {
if (isset($mapObject->isOverview) && $mapObject->isOverview == "1") { continue; }
$wmc->wmc_extent = $map->extent;
$wmc->wmc_srs = $map->epsg;
@@ -77,14 +74,11 @@
$wmc->keyword = explode(" ",$attributes->keywords);
$wmc->wmc_abstract = $attributes->abstract;
$inspireCat = $attributes->inspirecat;
- foreach($inspireCat as $cat => $val)
- {
+ foreach($inspireCat as $cat => $val) {
$parts = explode("_",$cat);
$wmc->inspireCats[] = $parts[1];
}
-
-
$result = $wmc->insert($overwrite);
$ajaxResponse->setSuccess(true);
$ajaxResponse->setResult($result);
Modified: trunk/mapbender/http/php/mod_wfs_gazetteer_server.php
===================================================================
--- trunk/mapbender/http/php/mod_wfs_gazetteer_server.php 2010-03-15 15:02:53 UTC (rev 5769)
+++ trunk/mapbender/http/php/mod_wfs_gazetteer_server.php 2010-03-15 15:05:53 UTC (rev 5770)
@@ -25,6 +25,7 @@
require_once(dirname(__FILE__)."/../classes/class_universal_gml_factory.php");
require_once(dirname(__FILE__)."/../classes/class_wfs_configuration.php");
+$user = new User(Mapbender::session()->get("mb_user_id"));
$command = $_REQUEST["command"];
/**
@@ -88,6 +89,13 @@
if ($wfsConfIdString != "") {
//array_keys(array_flip()) produces an array with unique entries
$wfsConfIdArray = array_keys(array_flip(mb_split(",", $wfsConfIdString)));
+ $availableWfsConfIds = $user->getWfsConfByPermission(Mapbender::session()->get("mb_user_gui"));
+
+ $wfsConfIdArray = array_intersect($wfsConfIdArray, $availableWfsConfIds);
+ if (count($wfsConfIdArray) === 0) {
+ echo "no wfs conf available.";
+ die();
+ }
}
else {
echo "please specify wfs conf id.";
@@ -102,10 +110,8 @@
}
elseif ($command == "getWfsConfsForThisApplication") {
- $user = new User($_SESSION["mb_user_id"]);
-
// get all WFS conf IDs for this application
- $availableWfsConfIds = $user->getWfsConfByPermission($_SESSION["gui_id"]);
+ $availableWfsConfIds = $user->getWfsConfByPermission(Mapbender::session()->get("mb_user_gui"));
$obj = new WfsConf();
$obj->load($availableWfsConfIds);
More information about the Mapbender_commits
mailing list