[Mapbender-commits] r8938 - in trunk/mapbender/http: classes javascripts
svn_mapbender at osgeo.org
svn_mapbender at osgeo.org
Thu Jun 26 02:48:31 PDT 2014
Author: hwbllmnn
Date: 2014-06-26 02:48:31 -0700 (Thu, 26 Jun 2014)
New Revision: 8938
Modified:
trunk/mapbender/http/classes/class_wmc.php
trunk/mapbender/http/javascripts/map.php
trunk/mapbender/http/javascripts/mod_savewmc.js
Log:
added option to limit local data size in wmcs
Modified: trunk/mapbender/http/classes/class_wmc.php
===================================================================
--- trunk/mapbender/http/classes/class_wmc.php 2014-06-26 09:22:57 UTC (rev 8937)
+++ trunk/mapbender/http/classes/class_wmc.php 2014-06-26 09:48:31 UTC (rev 8938)
@@ -228,6 +228,19 @@
// set title
$this->wmc_title = $generalTitle;
+ if($mapObject[0]->kmls) {
+ $this->has_local_data = true;
+ $this->local_data_size = strlen(json_encode($mapObject[0]->kmls));
+ if(defined('MAX_WMC_LOCAL_DATA_SIZE')) {
+ if($this->local_data_size > MAX_WMC_LOCAL_DATA_SIZE) {
+ $this->has_local_data = false;
+ $this->local_data_size = '0';
+ unset($mapObject[0]->kmls);
+ unset($mapObject[0]->kmlOrder);
+ }
+ }
+ }
+
// create the map objects
for ($i = 0; $i < count($mapObject); $i++) {
$currentMap = new Map();
@@ -241,11 +254,6 @@
}
}
- if($mapObject[0]->kmls) {
- $this->has_local_data = true;
- $this->local_data_size = strlen(json_encode($mapObject[0]->kmls));
- }
-
// create XML
$this->createXml();
Modified: trunk/mapbender/http/javascripts/map.php
===================================================================
--- trunk/mapbender/http/javascripts/map.php 2014-06-26 09:22:57 UTC (rev 8937)
+++ trunk/mapbender/http/javascripts/map.php 2014-06-26 09:48:31 UTC (rev 8938)
@@ -23,7 +23,7 @@
$json = new Mapbender_JSON();
// see http://trac.osgeo.org/mapbender/ticket/79
-ini_set('session.bug_compat_42',0);
+ini_set('session.bug_compat_42',0);
ini_set('session.bug_compat_warn',0);
Mapbender::session()->set("mb_user_gui", $gui_id);
@@ -33,6 +33,9 @@
//
// Define global variables (TODO: move to mapbender object later on)
//
+if(defined('MAX_WMC_LOCAL_DATA_SIZE')) {
+ echo "Mapbender.options = {MAX_WMC_LOCAL_DATA_SIZE: " . MAX_WMC_LOCAL_DATA_SIZE . "};\n";
+}
echo "Mapbender.sessionId = '".session_id()."';\n";
echo "var mb_nr = Mapbender.sessionId;\n";
echo "Mapbender.sessionName = '".session_name()."';\n";
@@ -95,8 +98,8 @@
//
$libPath = dirname(__FILE__) . "/../../lib/";
$libFileArray = array(
- "exception.js",
- "ajax.js",
+ "exception.js",
+ "ajax.js",
"basic.js",
"div.js",
"list.js",
@@ -178,8 +181,8 @@
$linkJsPluginsArray = array();
//get language code
$langCode = Mapbender::session()->get("mb_lang");
-$mb_sql = "SELECT DISTINCT e_js_file, e_id, e_src, e_target, e_pos, e_url, " .
- "e_left, e_top, e_title, gettext($2, e_title) AS e_current_title, " .
+$mb_sql = "SELECT DISTINCT e_js_file, e_id, e_src, e_target, e_pos, e_url, " .
+ "e_left, e_top, e_title, gettext($2, e_title) AS e_current_title, " .
"e_width, e_height, e_requires FROM gui_element WHERE e_public = 1 AND " .
"fkey_gui_id = $1 ORDER BY e_pos";
$mb_v = array($gui_id, $langCode);
@@ -190,7 +193,7 @@
//
// Create element properties
//
- $e_id = isset($row_js["e_id"]) ?
+ $e_id = isset($row_js["e_id"]) ?
str_replace(" ", "", $row_js["e_id"]) : "";
$e_src = $row_js["e_src"];
$e_require = $row_js["e_requires"];
@@ -203,17 +206,17 @@
$e_left = intval($row_js["e_left"]);
$e_url = $row_js["e_url"];
- $elementAttributes = "{" .
- "id:'$e_id'," .
+ $elementAttributes = "{" .
+ "id:'$e_id'," .
"target:" . ($e_target[0] != "" ? $json->encode($e_target) : "[]") . "," .
"url:'$e_url'," .
- "top:$e_top," .
- "left:$e_left," .
- "width:$e_width," .
- "height:$e_height," .
- "src:'$e_src'," .
- "title:'$e_title'," .
- "currentTitle:'$e_currentTitle'" .
+ "top:$e_top," .
+ "left:$e_left," .
+ "width:$e_width," .
+ "height:$e_height," .
+ "src:'$e_src'," .
+ "title:'$e_title'," .
+ "currentTitle:'$e_currentTitle'" .
"}";
echo "Mapbender.modules." . $e_id . " = " . $elementAttributes . ";\n";
@@ -221,7 +224,7 @@
echo "var sel = [];for (var k in t) {t[k] = $.trim(t[k]);if($('#' + t[k]).size() > 0) {sel.push($('#' + t[k]).get(0))}}\n";
echo "Mapbender.modules." . $e_id . ".\$target = sel.length > 0 ? \$(sel) : $([]);\n";
echo "$('#" . $e_id . "').data('api', Mapbender.modules." . $e_id . ");";
-
+
//
// Include JavaScript files
//
@@ -238,17 +241,17 @@
ob_start();
echo "var options = Mapbender.modules." . $e_id . ";\n";
-
- // extend the options variable by JS element vars
+
+ // extend the options variable by JS element vars
echo $elementVars;
-
- echo "\n$.fn.$e_id = function (options) {\n" .
+
+ echo "\n$.fn.$e_id = function (options) {\n" .
"\treturn this.each(function () {\n\n";
-
+
$jsArray = explode(",", $jsFileString);
for ($i = 0; $i < count($jsArray); $i++) {
$currentFile = trim($jsArray[$i]);
-
+
if (!file_exists($currentFile)) {
$e = new mb_exception("Javascript not found: " . $currentFile);
echo "var e = new Mb_exception('Javascript not found: " . $currentFile . "');";
@@ -260,21 +263,21 @@
* folder?
*/
require(secure($currentFile));
- }
+ }
echo "\n\t});\n};\n\n";
-
+
echo "$('#$e_id').$e_id(options);\n";
$executeJsPluginsArray[] = ob_get_contents();
ob_end_clean();
- $linkJsPluginsArray[] = "var options = {'id':'" . $e_id .
+ $linkJsPluginsArray[] = "var options = {'id':'" . $e_id .
"'};" . $elementVars . ";linkPlugins(options);";
}
else {
$jsArray = explode(",", $jsFileString);
for ($i = 0; $i < count($jsArray); $i++) {
$currentFile = trim($jsArray[$i]);
-
+
if (!file_exists($currentFile)) {
$e = new mb_exception("Javascript not found: " . $currentFile);
echo "var e = new Mb_exception('Javascript not found: " . $currentFile . "');";
@@ -334,13 +337,13 @@
})();
}
})();
- }
+ }
};
Mapbender.events.hideSplashScreen.trigger();
$jsText
-
+
$linkJsPluginsText
$("img").bind("mousedown", function (e) {
@@ -350,7 +353,7 @@
}).bind("mousemove", function (e) {
e.preventDefault();
});
-
+
// creates the map objects (mapframe1, overview...)
Mapbender.events.initMaps.trigger();
Modified: trunk/mapbender/http/javascripts/mod_savewmc.js
===================================================================
--- trunk/mapbender/http/javascripts/mod_savewmc.js 2014-06-26 09:22:57 UTC (rev 8937)
+++ trunk/mapbender/http/javascripts/mod_savewmc.js 2014-06-26 09:48:31 UTC (rev 8938)
@@ -170,6 +170,12 @@
if(kml) {
mb_mapObj[0].kmls = kml._kmls;
mb_mapObj[0].kmlOrder = kml.kmlOrder;
+ var json = JSON.stringify(kml._kmls);
+ if(Mapbender.options && Mapbender.options.MAX_WMC_LOCAL_DATA_SIZE && json.length > Mapbender.options.MAX_WMC_LOCAL_DATA_SIZE) {
+ alert('The maximum local data size is ' + Math.round(Mapbender.options.MAX_WMC_LOCAL_DATA_SIZE / 1024) + 'kb, your data is ' + Math.round(json.length / 1024) + 'kb, data will NOT be saved.');
+ mb_mapObj[0].kmls = null;
+ mb_mapObj[0].kmlOrder = null;
+ }
}
var mapObjectToSend = $.toJSON(mb_mapObj);
More information about the Mapbender_commits
mailing list