[Mapbender-commits] r8951 - in trunk/mapbender/http: php plugins
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Mon Jun 30 06:34:37 PDT 2014
Author: hwbllmnn
Date: 2014-06-30 06:34:37 -0700 (Mon, 30 Jun 2014)
New Revision: 8951
Added:
trunk/mapbender/http/php/mb_list_wmc_local_data.php
trunk/mapbender/http/php/mb_load_local_data.php
Modified:
trunk/mapbender/http/plugins/kmlTree.js
Log:
implemented loading data from stored wmcs
Added: trunk/mapbender/http/php/mb_list_wmc_local_data.php
===================================================================
--- trunk/mapbender/http/php/mb_list_wmc_local_data.php (rev 0)
+++ trunk/mapbender/http/php/mb_list_wmc_local_data.php 2014-06-30 13:34:37 UTC (rev 8951)
@@ -0,0 +1,42 @@
+<?php
+# $Id: mb_listWMCs.php 1686 2007-09-26 09:05:01Z christoph $
+# http://www.mapbender.org/index.php/mb_listWMCs.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+
+$user_id = Mapbender::session()->get("mb_user_id");
+
+$sql = 'select wmc_id, wmc_title, wmc_timestamp, wmc_local_data_size from mb_user_wmc where wmc_has_local_data = 1 and (fkey_user_id = $1 or wmc_local_data_public = 1);';
+
+$v = array($user_id);
+$t = array("i");
+$res = db_prep_query($sql, $v, $t);
+$wmcs = array();
+while($row = db_fetch_array($res)){
+ $wmc = array();
+ $wmc[] = $row['wmc_id'];
+ $wmc[] = $row['wmc_title'];
+ $wmc[] = $row['wmc_timestamp'];
+ $wmc[] = $row['wmc_local_data_size'];
+ $wmcs[] = $wmc;
+}
+
+header("Content-Type: application/json");
+
+echo(json_encode($wmcs));
+
+?>
Added: trunk/mapbender/http/php/mb_load_local_data.php
===================================================================
--- trunk/mapbender/http/php/mb_load_local_data.php (rev 0)
+++ trunk/mapbender/http/php/mb_load_local_data.php 2014-06-30 13:34:37 UTC (rev 8951)
@@ -0,0 +1,46 @@
+<?php
+# $Id: mb_listWMCs.php 1686 2007-09-26 09:05:01Z christoph $
+# http://www.mapbender.org/index.php/mb_listWMCs.php
+# Copyright (C) 2002 CCGIS
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2, or (at your option)
+# any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
+
+require_once(dirname(__FILE__)."/../php/mb_validateSession.php");
+require_once(dirname(__FILE__) . "/../classes/class_wmc.php");
+
+$user_id = Mapbender::session()->get("mb_user_id");
+
+$wmc = new wmc();
+
+$wmc_id = $_POST["id"];
+
+$form_target = $self;
+
+$sql = 'select wmc from mb_user_wmc where wmc_id = $1 and wmc_has_local_data = 1 and (fkey_user_id = $2 or wmc_local_data_public = 1);';
+
+$v = array($wmc_id, $user_id);
+$t = array("i", "i");
+$res = db_prep_query($sql, $v, $t);
+
+header("Content-Type: application/json");
+
+if($row = db_fetch_array($res)){
+ $wmc->createFromXml($row['wmc']);
+ $kmls = $wmc->generalExtensionArray['KMLS'];
+ echo($kmls);
+} else {
+ echo('{}');
+}
+
+?>
Modified: trunk/mapbender/http/plugins/kmlTree.js
===================================================================
--- trunk/mapbender/http/plugins/kmlTree.js 2014-06-30 12:15:02 UTC (rev 8950)
+++ trunk/mapbender/http/plugins/kmlTree.js 2014-06-30 13:34:37 UTC (rev 8951)
@@ -77,7 +77,10 @@
var dlg = $('<div ></div>').dialog({
"title": "KML hinzufügen",
width: 450,
- height: 210
+ height: 420,
+ close: function() {
+ $(this).html('').dialog('destroy');
+ }
});
var dlgcontent = '<div id="kml-load-tabs">'
+ '<ul><li><a class="icon icon-wmc" href="#kml-from-wmc">Stored data</a></li>'
@@ -101,6 +104,40 @@
+ '</div>'
+ '</div>';
$(dlg).append(dlgcontent);
+ $.ajax({
+ type: 'get',
+ url: '../php/mb_list_wmc_local_data.php',
+ success: function(data) {
+ $.each(data, function(_, v) {
+ v[2] = new Date(v[2] * 1000);
+ v[3] = Math.round(v[3] / 1024) + 'kb';
+ });
+ $('#kml-from-wmc').html('<table class="display"></table>').find('table').dataTable({
+ aaData: data,
+ aoColumns: [{sTitle: 'ID'}, {sTitle: 'Title'}, {sTitle: 'last change'}, {sTitle: 'size'}]
+ })
+ .find('tr').bind('click', function() {
+ $(this).addClass('row_selected').siblings().removeClass('row_selected');
+ })
+ .bind('dblclick', function() {
+ var id = $($(this).find('td')[0]).text();
+ $.ajax({
+ type: 'post',
+ url: '../php/mb_load_local_data.php',
+ data: {
+ id: id
+ },
+ success: function(data) {
+ var kml = $('#mapframe1').data('kml');
+ $.each(data, function(url, json) {
+ kml.addLayer(url, json.data);
+ });
+ $(dlg).dialog('destroy');
+ }
+ });
+ });
+ }
+ });
$('#kml-load-tabs').tabs();
$('#kml-load-tabs').find('button.add').bind('click', function() {
$('#mapframe1').kml({ url: $('#kml-load-tabs').find('.kmlurl').val()});
More information about the Mapbender_commits
mailing list