[Mapbender-commits] r9595 - in trunk/mapbender/http: php plugins

svn_mapbender at osgeo.org svn_mapbender at osgeo.org
Tue Sep 13 04:48:32 PDT 2016


Author: pschmidt
Date: 2016-09-13 04:48:32 -0700 (Tue, 13 Sep 2016)
New Revision: 9595

Modified:
   trunk/mapbender/http/php/mb_validateSession.php
   trunk/mapbender/http/plugins/mb_digitize_widget.php
Log:
fixing export digitize

Modified: trunk/mapbender/http/php/mb_validateSession.php
===================================================================
--- trunk/mapbender/http/php/mb_validateSession.php	2016-09-13 06:35:27 UTC (rev 9594)
+++ trunk/mapbender/http/php/mb_validateSession.php	2016-09-13 11:48:32 UTC (rev 9595)
@@ -67,7 +67,7 @@
 }
 //
 //use lang parameter to set the session var mb_lang
-if (isset($_REQUEST["lang"]) & $_REQUEST["lang"] != "") {
+if (isset($_REQUEST["lang"]) && $_REQUEST["lang"] != "") {
 	//validate to de, en, fr, ... give a whitelist
 	$testMatch = $_REQUEST["lang"];	
  	if (!($testMatch == 'de' or $testMatch == 'en' or $testMatch == 'fr')){ 

Modified: trunk/mapbender/http/plugins/mb_digitize_widget.php
===================================================================
--- trunk/mapbender/http/plugins/mb_digitize_widget.php	2016-09-13 06:35:27 UTC (rev 9594)
+++ trunk/mapbender/http/plugins/mb_digitize_widget.php	2016-09-13 11:48:32 UTC (rev 9595)
@@ -383,58 +383,40 @@
 
 var exportItem = function(data) {
     var dlg = $(exportHtml).dialog({ width: 330, height: 220 });
-    // $(dlg).find('input').bind('change', function() {
-    //     if(!$(this).is(':checked')) {
-    //         return;
-    //     }
-    //     var fmt = $(this).val();
-    //     var url;
-    //     if(fmt === 'kml') {
-    //         url = tokml(data, {simplestyle: true});
-    //     }
-    //     if(fmt === 'gpx') {
-    //         url = togpx(data, {simplestyle: true});
-    //     }
-    //     if(fmt === 'geojson') {
-    //         url = JSON.stringify(data);
-    //     }
-    //     url = 'data:application/octet-stream,' + encodeURIComponent(url);
-
-    //     var lnk = $(dlg).find('.digitize-export')
-    //     .attr('download', 'myfeatures.' + fmt)
-    //     .attr('href', url);
-    // }).change();
-
     $(dlg).find('.exportDataLink').bind('click', function() {
-
         var outputformat = $(this).attr('outputformat');
-        var url;
-            // var fmt = $(dlg).find('input:checked').val();
-            if(outputformat === 'kml') {
-                url = tokml(data, {simplestyle: true});
+        var content;
+        if(outputformat === 'kml') {
+            content = tokml(data, {simplestyle: true});
+        } else if(outputformat === 'gpx') {
+            content = togpx(data, {simplestyle: true});
+        } else if(outputformat === 'geojson') {
+            if (data.type != "Feature") {
+                content = JSON.stringify(data);
+            } else {
+                var newFeatureJson = $.extend(true, {}, data);
+                var jsonFeatureHeader = {"type": "FeatureCollection", "features": [newFeatureJson]};
+                content = JSON.stringify(jsonFeatureHeader);
             }
-            if(outputformat === 'gpx') {
-                url = togpx(data, {simplestyle: true});
-            }
-            if(outputformat === 'geojson') {
-                if (data.type != "Feature") {
 
-                    url = JSON.stringify(data);
-                } else {
-
-                    var newFeatureJson = $.extend(true, {}, data);
-                    var jsonFeatureHeader = {"type": "FeatureCollection", "features": [newFeatureJson]};
-                    url = JSON.stringify(jsonFeatureHeader);
-                }
-
-            }
+        } else {
+            alert('The output format "' + outputformat + '" is not supported.');
+            return false;
+        }
+        var ua = window.navigator.userAgent;
+        var msie = ua.indexOf("MSIE ");
+        if ((msie > 0 && parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))) === 10) || !!ua.match(/Trident.*rv\:11\./)){
+            var blob = new Blob([content],{type:'application/' + outputformat});
+            window.navigator.msSaveBlob(blob, 'data.' + outputformat);
+        } else {
             var link = document.createElement("a");
-            link.setAttribute('href', 'data:text/text;charset=utf-8,' +      encodeURIComponent(url));
+            link.setAttribute('href', 'data:application/octet-stream;charset=utf-8,' + encodeURIComponent(content));
             link.setAttribute('download', 'myfeatures.' + outputformat);
             $(dlg).append(link);
             link.click();
             $(dlg).remove(link);
-            return false;
+        }
+        return false;
     });
 };
 



More information about the Mapbender_commits mailing list