[Mapbender-commits] r6995 - in trunk/mapbender/http: php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Fri Oct 1 09:29:34 EDT 2010
Author: christoph
Date: 2010-10-01 13:29:34 +0000 (Fri, 01 Oct 2010)
New Revision: 6995
Added:
trunk/mapbender/http/php/mod_sessionWmc_server.php
trunk/mapbender/http/plugins/mb_sessionWmc.js
Log:
module that helps the user to resolve conflicts that arose when loading services via the GET API
Added: trunk/mapbender/http/php/mod_sessionWmc_server.php
===================================================================
--- trunk/mapbender/http/php/mod_sessionWmc_server.php (rev 0)
+++ trunk/mapbender/http/php/mod_sessionWmc_server.php 2010-10-01 13:29:34 UTC (rev 6995)
@@ -0,0 +1,50 @@
+<?php
+require_once(dirname(__FILE__) . "/../../core/globalSettings.php");
+require_once(dirname(__FILE__) . "/../classes/class_user.php");
+require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+require_once(dirname(__FILE__) . "/../classes/class_wmcToXml.php");
+require_once(dirname(__FILE__) . "/../classes/class_json.php");
+require_once(dirname(__FILE__) . "/../classes/class_administration.php");
+
+$ajaxResponse = new AjaxResponse($_POST);
+$json = new Mapbender_JSON();
+$currentUser = new User();
+
+$wmc = new wmc();
+
+$resultObj = array();
+
+switch ($ajaxResponse->getMethod()) {
+
+ case 'checkConstraints':
+ $resultObj = Mapbender::session()->get("wmcConstraints");
+ $ajaxResponse->setResult($resultObj);
+ $ajaxResponse->setSuccess(true);
+ break;
+ case 'updateWmc':
+ if (
+ !Mapbender::session()->exists("wmcGetApi") ||
+ !is_a(Mapbender::session()->get("wmcGetApi"), "wmc")
+ ) {
+ $ajaxResponse->setMessage(_mb("No WMC in session."));
+ $ajaxResponse->setSuccess(true);
+ break;
+ }
+ $wmc = Mapbender::session()->get("wmcGetApi");
+ $skipWms = $ajaxResponse->getParameter("wmsIndices");
+ $skipWms = is_array($skipWms) ? $skipWms : array();
+ $js = $wmc->toJavaScript($skipWms);
+ $resultObj = array(
+ "js" => $js
+ );
+ $ajaxResponse->setResult($resultObj);
+ $ajaxResponse->setSuccess(true);
+ break;
+ // Invalid command
+ default:
+ $ajaxResponse->setMessage(_mb("No method specified."));
+ $ajaxResponse->setSuccess(false);
+}
+
+$ajaxResponse->send();
+?>
Added: trunk/mapbender/http/plugins/mb_sessionWmc.js
===================================================================
--- trunk/mapbender/http/plugins/mb_sessionWmc.js (rev 0)
+++ trunk/mapbender/http/plugins/mb_sessionWmc.js 2010-10-01 13:29:34 UTC (rev 6995)
@@ -0,0 +1,153 @@
+/**
+ * Package: sessionWmc
+ *
+ * Description:
+ * Checks whether the GET API has loaded services and conflicts arose.
+ * This module will display the conflicts and allows the user to resolve
+ * these conflicts. Possible conflicts are: no permission, service not in
+ * repository, service not up to date, etc.
+ *
+ * Files:
+ * - http/plugins/mb_sessionWmc.js
+ * - http/php/mb_sessionWmc_server.php
+ *
+ * SQL:
+ * > 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('gui1','sessionWmc',1,1,'','Please confirm','div','','',NULL ,NULL ,NULL ,NULL ,NULL ,'','','div','../plugins/mb_sessionWmc.js','','','mapframe1','');
+ *
+ * Help:
+ * http://www.mapbender.org/<wiki site name>
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:<user>
+ *
+ * License:
+ * Copyright (c) 2009, Open Source Geospatial Foundation
+ * This program is dual licensed under the GNU General Public License
+ * and Simplified BSD license.
+ * http://svn.osgeo.org/mapbender/trunk/mapbender/license/license.txt
+ */
+
+var $sessionWmc = $(this);
+
+var SessionWmcApi = function (o) {
+ var that = this;
+ var $dialog;
+
+ var closeDialog = function () {
+ if ($dialog === undefined || !$dialog.jquery) {
+ console.log($dialog);
+ return;
+ }
+ $dialog.dialog('close').remove();
+ };
+
+ var confirmConstraints = function (constraintTypeArray) {
+ 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);
+ }
+ });
+ }
+ updateWmc(skipWmsArray);
+ };
+
+ var updateWmc = function (wmsIndices) {
+ var req = new Mapbender.Ajax.Request({
+ url: "../php/mod_sessionWmc_server.php",
+ method: "updateWmc",
+ parameters: {
+ wmsIndices: wmsIndices
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ $sessionWmc.text(message).dialog();
+ return;
+ }
+ // execute JS code
+ for (var j = 0; j < obj.js.length; j++) {
+ eval(obj.js[j]);
+ }
+
+ closeDialog();
+ }
+ });
+ req.send();
+ };
+
+ var displayConstraints = function (obj) {
+ var html = "";
+ var constraintTypeArray = [];
+ for (var constraintType in obj) {
+ var caseObj = obj[constraintType];
+
+ if (caseObj.wms.length === 0) {
+ continue;
+ }
+
+ html += "<fieldset>" + caseObj.message +
+ (constraintType === "noPermission" ? "<br><ul>" : " Sollen diese Dienste trotzdem hinzugeladen werden?<br><br>");
+
+ for (var index in caseObj.wms) {
+ var wms = caseObj.wms[index];
+ html += "<label for='" + constraintType + "_" + wms.index + "'>" +
+ (constraintType === "noPermission" ? "<li>" : "<input id='" + options.id + "_" + constraintType + "_" + wms.index + "' " + "type='checkbox' />") +
+ wms.title + "</label><br>";
+ }
+ html += (constraintType === "noPermission" ? "</ul>" : "");
+ html += "</fieldset><br>";
+ constraintTypeArray.push(constraintType);
+ }
+ if (html === "") {
+ return;
+ }
+
+ $dialog = $("<div id='" + o.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: {
+ "Weiter": function () {
+ confirmConstraints(constraintTypeArray);
+ }
+ },
+ close: function () {
+ }
+ }
+ );
+
+ $("#" + options.id + "_constraint_form").dialog('open');
+ };
+
+
+ var checkConstraints = function () {
+ var req = new Mapbender.Ajax.Request({
+ url: "../php/mod_sessionWmc_server.php",
+ method: "checkConstraints",
+ parameters: {
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ $sessionWmc.text(message).dialog();
+ return;
+ }
+ displayConstraints(obj);
+ }
+ });
+ req.send();
+ };
+
+ Mapbender.events.beforeInit.register(checkConstraints);
+};
+
+$sessionWmc.mapbender(new SessionWmcApi(options));
\ No newline at end of file
More information about the Mapbender_commits
mailing list