1 | from AccessControl import ClassSecurityInfo |
---|
2 | try: |
---|
3 | from Products.CMFCore.permissions import ModifyPortalContent, View |
---|
4 | except ImportError: |
---|
5 | from Products.CMFCore.CMFCorePermissions import ModifyPortalContent, View |
---|
6 | from Products.CMFCore.utils import getToolByName |
---|
7 | |
---|
8 | try: |
---|
9 | from Products.LinguaPlone.public import * |
---|
10 | except ImportError: |
---|
11 | from Products.Archetypes.public import * |
---|
12 | |
---|
13 | from Products.ATContentTypes.content.base import ATCTFolder, updateActions |
---|
14 | from Products.ATContentTypes.content.schemata import finalizeATCTSchema |
---|
15 | |
---|
16 | #from Products.CMFPlone.interfaces.NonStructuralFolder import INonStructuralFolder |
---|
17 | |
---|
18 | from Products.qPloneGoogleMaps.field import * |
---|
19 | from Products.qPloneGoogleMaps.config import * |
---|
20 | |
---|
21 | zoom_vocaburary = range(18) |
---|
22 | zoom_vocaburary.reverse() |
---|
23 | |
---|
24 | MapSchema = ATCTFolder.schema.copy() + Schema(( |
---|
25 | MapField('location', |
---|
26 | default=None, |
---|
27 | required=True, |
---|
28 | validators=('isLocation',), |
---|
29 | widget=MapWidget( |
---|
30 | label='Map Center', |
---|
31 | label_msgid='label_map_center', |
---|
32 | description='Here you can choose map center point on the map by mouse clicking', |
---|
33 | description_msgid='help_map_center', |
---|
34 | i18n_domain='googlemaps', |
---|
35 | ) |
---|
36 | ), |
---|
37 | |
---|
38 | StringField('auto', |
---|
39 | vocabulary=('None', 'Zoom', 'Center', 'Full'), |
---|
40 | default='None', |
---|
41 | widget=SelectionWidget( |
---|
42 | label='Auto Control', |
---|
43 | label_msgid='label_auto_control', |
---|
44 | description_msgid='help_auto_control', |
---|
45 | i18n_domain='googlemaps', |
---|
46 | format = 'radio', |
---|
47 | ) |
---|
48 | ), |
---|
49 | |
---|
50 | IntegerField('height', |
---|
51 | default="480", |
---|
52 | required=True, |
---|
53 | widget=IntegerWidget( |
---|
54 | label='Height', |
---|
55 | label_msgid='label_height', |
---|
56 | description_msgid='help_height', |
---|
57 | i18n_domain='googlemaps', |
---|
58 | ) |
---|
59 | ), |
---|
60 | |
---|
61 | IntegerField('zoom', |
---|
62 | default=3, |
---|
63 | vocabulary=zoom_vocaburary, |
---|
64 | widget=SelectionWidget( |
---|
65 | label='Zoom', |
---|
66 | label_msgid='label_zoom', |
---|
67 | description_msgid='help_zoom', |
---|
68 | i18n_domain='googlemaps', |
---|
69 | ) |
---|
70 | ), |
---|
71 | |
---|
72 | StringField('mapControl', |
---|
73 | vocabulary=('large', 'small', 'nothing'), |
---|
74 | default='large', |
---|
75 | widget=SelectionWidget( |
---|
76 | label='Map Control', |
---|
77 | label_msgid='label_map_control', |
---|
78 | description_msgid='help_map_control', |
---|
79 | i18n_domain='googlemaps', |
---|
80 | ) |
---|
81 | ), |
---|
82 | |
---|
83 | StringField('mapType', |
---|
84 | vocabulary=('map', 'satellite', 'hybrid'), |
---|
85 | default='hybrid', |
---|
86 | widget=SelectionWidget( |
---|
87 | label='Map Type', |
---|
88 | label_msgid='label_map_type', |
---|
89 | description_msgid='help_map_type', |
---|
90 | i18n_domain='googlemaps', |
---|
91 | ) |
---|
92 | ), |
---|
93 | |
---|
94 | BooleanField('typeControl', |
---|
95 | default=1, |
---|
96 | widget=BooleanWidget( |
---|
97 | label='Type Control', |
---|
98 | label_msgid='label_type_control', |
---|
99 | description_msgid='help_type_control', |
---|
100 | i18n_domain='googlemaps', |
---|
101 | ) |
---|
102 | ), |
---|
103 | |
---|
104 | BooleanField('overviewControl', |
---|
105 | default=1, |
---|
106 | widget=BooleanWidget( |
---|
107 | label='Overview Control', |
---|
108 | label_msgid='label_overview_control', |
---|
109 | description_msgid='help_overview_control', |
---|
110 | i18n_domain='googlemaps', |
---|
111 | ) |
---|
112 | ), |
---|
113 | ), |
---|
114 | ) |
---|
115 | |
---|
116 | finalizeATCTSchema(MapSchema) |
---|
117 | |
---|
118 | class Map(ATCTFolder): |
---|
119 | """Google Map class""" |
---|
120 | |
---|
121 | schema = MapSchema |
---|
122 | |
---|
123 | content_icon = 'map_icon.gif' |
---|
124 | portal_type = 'Map' |
---|
125 | meta_type = 'Map' |
---|
126 | archetype_name = 'Map' |
---|
127 | default_view = 'map_view' |
---|
128 | immediate_view = 'map_view' |
---|
129 | suppl_views = () |
---|
130 | typeDescription = 'Maps Folder' |
---|
131 | typeDescMsgId = 'map_description_edit' |
---|
132 | |
---|
133 | security = ClassSecurityInfo() |
---|
134 | |
---|
135 | # Get the standard actions (tabs) |
---|
136 | actions = updateActions(ATCTFolder, |
---|
137 | ({'id' : 'edit', |
---|
138 | 'name' : 'Edit', |
---|
139 | 'action' : 'string:${object_url}/map_edit', |
---|
140 | 'permissions' : (ModifyPortalContent,) |
---|
141 | }, |
---|
142 | ) |
---|
143 | ) |
---|
144 | |
---|
145 | #__implements__ = (ATCTFolder.__implements__, INonStructuralFolder) |
---|
146 | |
---|
147 | allowed_content_types = ['Marker', 'Overlay'] |
---|
148 | |
---|
149 | # Make sure we get title-to-id generation when an object is created |
---|
150 | _at_rename_after_creation = True |
---|
151 | |
---|
152 | def canSetDefaultPage(self): |
---|
153 | return False |
---|
154 | |
---|
155 | security.declareProtected(View, 'geoLocation') |
---|
156 | def geoLocation(self): |
---|
157 | """ Return geolocation tuple """ |
---|
158 | return self.getLocation() |
---|
159 | |
---|
160 | security.declareProtected(View, 'getOverlayMarkers') |
---|
161 | def getOverlayMarkers(self): |
---|
162 | """ Return markers of the contained overlays """ |
---|
163 | catalog = getToolByName(self, 'portal_catalog') |
---|
164 | result = {} |
---|
165 | for el in self.folderlistingFolderContents(): |
---|
166 | if el.portal_type == 'Overlay': |
---|
167 | color = el.getMarkersColor() |
---|
168 | markers = el.getMarkers() |
---|
169 | elif el.portal_type == 'Marker': |
---|
170 | color = el.getColor() |
---|
171 | markers = list(catalog(path='/'.join(el.getPhysicalPath()))) |
---|
172 | else: continue |
---|
173 | result[(el.getId(),color)] = result.get(el.getId(), []) + markers |
---|
174 | return result |
---|
175 | |
---|
176 | registerType(Map, PROJECTNAME) |
---|