[Commits] r1812 - in sandbox/cmoullet/ux/LayerManager: examples ux ux/controllers ux/data
commits at geoext.org
commits at geoext.org
Sun Jan 24 07:36:56 CET 2010
Author: cmoullet
Date: 2010-01-24 07:36:56 +0100 (Sun, 24 Jan 2010)
New Revision: 1812
Added:
sandbox/cmoullet/ux/LayerManager/ux/controllers/
sandbox/cmoullet/ux/LayerManager/ux/controllers/filemanager.py
Modified:
sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
Log:
Add downloadService and sample controller
Modified: sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js 2010-01-24 05:56:53 UTC (rev 1811)
+++ sandbox/cmoullet/ux/LayerManager/examples/LayerManagerExample.js 2010-01-24 06:36:56 UTC (rev 1812)
@@ -58,7 +58,8 @@
text: 'Export KML',
enableToggle: false,
handler: function() {
- GeoExt.ux.data.Export.KMLExport(map, [sundials], null);
+ //GeoExt.ux.data.Export.KMLExport(map, [sundials], null, 'http://localhost:5000/filemanager/download');
+ GeoExt.ux.data.Export.KMLExport(map, [sundials], null, null);
}
});
Added: sandbox/cmoullet/ux/LayerManager/ux/controllers/filemanager.py
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/controllers/filemanager.py (rev 0)
+++ sandbox/cmoullet/ux/LayerManager/ux/controllers/filemanager.py 2010-01-24 06:36:56 UTC (rev 1812)
@@ -0,0 +1,27 @@
+import logging
+
+from pylons import request, response, session, tmpl_context as c
+from pylons.controllers.util import abort, redirect_to
+
+from mapfishapp.lib.base import BaseController, render
+
+log = logging.getLogger(__name__)
+
+class FilemanagerController(BaseController):
+
+ def index(self):
+ # Return a rendered template
+ #return render('/filemanager.mako')
+ # or, return a response
+ return 'Hello World'
+
+ def upload(self):
+ return 'not implemented'
+
+ def download(self):
+ # Sample python controller used to download a file. Necessary to avoir client side flash.
+ self.format = request.params.get('format', 'KML')
+ if self.format == 'KML':
+ response.content_type = 'application/vnd.google-earth.kml+xml'
+ response.headers['Content-disposition'] = 'attachment; filename=export.kml'
+ return request.params.get('content', 'no data sent')
\ No newline at end of file
Modified: sandbox/cmoullet/ux/LayerManager/ux/data/Export.js
===================================================================
--- sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2010-01-24 05:56:53 UTC (rev 1811)
+++ sandbox/cmoullet/ux/LayerManager/ux/data/Export.js 2010-01-24 06:36:56 UTC (rev 1812)
@@ -127,16 +127,39 @@
* :param map ``OpenLayers.Map`` Map.
* :param layers ``Array(OpenLayers.Layer)`` (Optional) Array of layers. Supported: 'OpenLayers.Layer.Vector','OpenLayers.Layer.WFS','OpenLayers.Layer.GML','OpenLayers.Layer.GeoRSS'. If null, all supported layers of thd map are exported.
* :param features ``Array(OpenLayers.Feature.Vector)`` (Optional) Array of features. If null, all features of the layers are exported.
+ * :param features ``Array(OpenLayers.Feature.Vector)`` (Optional) Array of features. If null, all features of the layers are exported.
*
*/
-GeoExt.ux.data.Export.KMLExport = function(map, layers, features) {
+GeoExt.ux.data.Export.KMLExport = function(map, layers, features, downloadService) {
GeoExt.ux.data.Export.format = 'KML';
GeoExt.ux.data.Export.content = GeoExt.ux.data.Export(map, GeoExt.ux.data.Export.format, layers, features);
- if (GetFlashVersion() > 10.00) {
- GeoExt.ux.data.Export.OpenWindowDownloadify();
+ if (downloadService) {
+ var form = document.createElement("form");
+ form.setAttribute("method", 'POST');
+ form.setAttribute("action", downloadService);
+
+ var formatField = document.createElement("input");
+ formatField.setAttribute("type", "hidden");
+ formatField.setAttribute("name", "format");
+ formatField.setAttribute("value", GeoExt.ux.data.Export.format);
+
+ var contentField = document.createElement("input");
+ contentField.setAttribute("type", "hidden");
+ contentField.setAttribute("name", "content");
+ contentField.setAttribute("value", GeoExt.ux.data.Export.content.replace(/</g, '<').replace(/>/g, '>'));
+
+ form.appendChild(formatField);
+ form.appendChild(contentField);
+
+ document.body.appendChild(form);
+ form.submit();
} else {
- alert('Please install Flash 10 in order to use the following window.');
- GeoExt.ux.data.Export.OpenWindowDownloadify();
+ if (GetFlashVersion() > 10.00) {
+ GeoExt.ux.data.Export.OpenWindowDownloadify();
+ } else {
+ alert('Please install Flash 10 in order to use the following window.');
+ GeoExt.ux.data.Export.OpenWindowDownloadify();
+ }
}
};
\ No newline at end of file
More information about the Commits
mailing list