[Mapbender-commits] r6871 - trunk/mapbender/http/plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Sep 2 04:44:28 EDT 2010
Author: christoph
Date: 2010-09-02 08:44:28 +0000 (Thu, 02 Sep 2010)
New Revision: 6871
Added:
trunk/mapbender/http/plugins/mb_sql.js
trunk/mapbender/http/plugins/mb_sql_server.php
Log:
http://trac.osgeo.org/mapbender/ticket/702
Added: trunk/mapbender/http/plugins/mb_sql.js
===================================================================
--- trunk/mapbender/http/plugins/mb_sql.js (rev 0)
+++ trunk/mapbender/http/plugins/mb_sql.js 2010-09-02 08:44:28 UTC (rev 6871)
@@ -0,0 +1,51 @@
+/**
+ * Package: sql
+ *
+ * Description:
+ * Exports the current application as SQL
+ *
+ * Files:
+ * - http/plugins/mb_sql.js
+ * - http/plugins/mb_sql_server.js
+ *
+ * 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('test_sql','sql',1,1,'','Export to SQL','a','','href=''#''',900,20,NULL ,NULL ,NULL ,'','Export to SQL','a','../plugins/mb_sql.js','','','jq_ui_dialog','');
+ *
+ * Help:
+ * http://www.mapbender.org/<wiki site name>
+ *
+ * Maintainer:
+ * http://www.mapbender.org/User:Christoph_Baudson
+ *
+ * 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 $sql = $(this);
+
+var SqlApi = function (o) {
+ $sql.bind("click", function () {
+ var req = new Mapbender.Ajax.Request({
+ url: "../plugins/mb_sql_server.php",
+ method: "sql",
+ parameters: {
+ applicationId: Mapbender.application
+ },
+ callback: function (obj, result, message) {
+ if (!result) {
+ alert(message);
+ return;
+ }
+ $("<textarea />").attr({
+ "title": "SQL of application '" + Mapbender.application + "'"
+ }).text(obj.sql).dialog();
+ }
+ });
+ req.send();
+ });
+};
+
+$sql.mapbender(new SqlApi(options));
Added: trunk/mapbender/http/plugins/mb_sql_server.php
===================================================================
--- trunk/mapbender/http/plugins/mb_sql_server.php (rev 0)
+++ trunk/mapbender/http/plugins/mb_sql_server.php 2010-09-02 08:44:28 UTC (rev 6871)
@@ -0,0 +1,41 @@
+<?php
+# 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
+
+require_once dirname(__FILE__) . "/../php/mb_validateSession.php";
+require_once dirname(__FILE__) . "/../classes/class_gui.php";
+require_once dirname(__FILE__) . "/../classes/class_user.php";
+
+$ajaxResponse = new AjaxResponse($_POST);
+
+switch ($ajaxResponse->getMethod()) {
+ case "sql" :
+ $application = new gui($ajaxResponse->getParameter("applicationId"));
+
+ $user = new User();
+ $apps = $user->getApplicationsByPermission();
+
+ if (in_array($application->id, $apps)) {
+ $sql = $application->toSql();
+ $resultObj = array(
+ "sql" => $sql
+ );
+ $ajaxResponse->setResult($resultObj);
+ $ajaxResponse->setSuccess(true);
+ break;
+ }
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("You are not allowed to access this application."));
+ break;
+
+ default:
+ $ajaxResponse->setSuccess(false);
+ $ajaxResponse->setMessage(_mb("An unknown error occured."));
+ break;
+}
+
+$ajaxResponse->send();
+?>
\ No newline at end of file
More information about the Mapbender_commits
mailing list