Ticket #9278: geoadmin_rtl_fix_v2.diff
File geoadmin_rtl_fix_v2.diff, 4.6 KB (added by , 16 years ago) |
---|
-
django/contrib/gis/admin/options.py
28 28 scale_text = True 29 29 layerswitcher = True 30 30 scrollable = True 31 admin_media_prefix = settings.ADMIN_MEDIA_PREFIX32 31 map_width = 600 33 32 map_height = 400 34 33 map_srid = 4326 35 34 map_template = 'gis/admin/openlayers.html' 36 openlayers_url = 'http://openlayers.org/api/2. 6/OpenLayers.js'35 openlayers_url = 'http://openlayers.org/api/2.7/OpenLayers.js' 37 36 wms_url = 'http://labs.metacarta.com/wms/vmap0' 38 37 wms_layer = 'basic' 39 38 wms_name = 'OpenLayers WMS' … … 76 75 class OLMap(self.widget): 77 76 template = self.map_template 78 77 geom_type = db_field._geom 79 params = {'admin_media_prefix' : self.admin_media_prefix, 80 'default_lon' : self.default_lon, 78 params = {'default_lon' : self.default_lon, 81 79 'default_lat' : self.default_lat, 82 80 'default_zoom' : self.default_zoom, 83 81 'display_wkt' : self.debug or self.display_wkt, -
django/contrib/gis/admin/widgets.py
1 from django.conf import settings 1 2 from django.contrib.gis.gdal import OGRException 2 3 from django.contrib.gis.geos import GEOSGeometry, GEOSException 3 4 from django.forms.widgets import Textarea 4 from django.template.loader import render_to_string 5 from django.template import loader, Context 6 from django.utils import translation 5 7 8 # Creating a template context that will contain settings values needed 9 # by the OpenLayers templates. 10 geo_context = Context({'ADMIN_MEDIA_PREFIX' : settings.ADMIN_MEDIA_PREFIX, 11 'LANGUAGE_BIDI' : translation.get_language_bidi(), 12 }) 13 6 14 class OpenLayersWidget(Textarea): 7 15 """ 8 16 Renders an OpenLayers map using the WKT of the geometry. … … 40 48 srid = self.params['srid'] 41 49 if value.srid != srid: 42 50 try: 43 value.transform(srid) 44 wkt = value.wkt 51 ogr = value.ogr 52 ogr.transform(srid) 53 wkt = ogr.wkt 45 54 except OGRException: 46 55 wkt = '' 47 56 else: … … 51 60 # geometry. 52 61 self.params['wkt'] = wkt 53 62 54 return render_to_string(self.template, self.params) 63 return loader.render_to_string(self.template, self.params, 64 context_instance=geo_context) 55 65 56 66 def map_options(self): 57 67 "Builds the map options hash for the OpenLayers template." -
django/contrib/gis/templates/gis/admin/openlayers.html
2 2 <style type="text/css"> 3 3 #{{ id }}_map { width: {{ map_width }}px; height: {{ map_height }}px; } 4 4 #{{ id }}_map .aligned label { float:inherit; } 5 #{{ id }}_admin_map { position: relative; vertical-align: top; float: left; }5 #{{ id }}_admin_map { position: relative; vertical-align: top; float: {{ LANGUAGE_BIDI|yesno:"right,left" }}; } 6 6 {% if not display_wkt %}#{{ id }} { display: none; }{% endif %} 7 7 .olControlEditingToolbar .olControlModifyFeatureItemActive { 8 background-image: url("{{ admin_media_prefix}}img/gis/move_vertex_on.png");8 background-image: url("{{ ADMIN_MEDIA_PREFIX }}img/gis/move_vertex_on.png"); 9 9 background-repeat: no-repeat; 10 10 } 11 11 .olControlEditingToolbar .olControlModifyFeatureItemInactive { 12 background-image: url("{{ admin_media_prefix}}img/gis/move_vertex_off.png");12 background-image: url("{{ ADMIN_MEDIA_PREFIX }}img/gis/move_vertex_off.png"); 13 13 background-repeat: no-repeat; 14 14 } 15 15 </style> … … 29 29 {% block openlayers %}{% include "gis/admin/openlayers.js" %}{% endblock %} 30 30 //]]> 31 31 </script> 32 <div id="{{ id }}_map" ></div>32 <div id="{{ id }}_map"{% if LANGUAGE_BIDI %} dir="ltr"{% endif %}></div> 33 33 <a href="javascript:{{ module }}.clearFeatures()">Delete all Features</a> 34 34 {% if display_wkt %}<p> WKT debugging window:</p>{% endif %} 35 35 <textarea id="{{ id }}" class="vWKTField required" cols="150" rows="10" name="{{ field_name }}">{{ wkt }}</textarea>