Hello,
I would like to have the collective.geo.kml.kmlcontentviewlet to be
configurable to display either
above or below content (or in another viewlet manager)
I made some changes to achieve this which works quite well - diff attached :)
These changes enable to choose the viewletmanager of that viewlet
globally as a default or locally per content item.
eventually it should be possible to configure the manager on a per
type basis (i.e. Events could have the maps below, Documents above
the main content area, and my custom type in a custom viewlet manager)
the changes seem to me not very intrusive.
what do you think?
shall i commit to trunk or rather make a branch?
--
Best Regards,
Christian Ledermann
Nairobi - Kenya
Mobile : +254 729495789
<*)))>{
If you save the living environment, the biodiversity that we have left,
you will also automatically save the physical environment, too. But If
you only save the physical environment, you will ultimately lose both.
}<(((*>
Index: src/collective.geo.contentlocations/collective/geo/contentlocations/browser/geostylesform.py
===================================================================
--- src/collective.geo.contentlocations/collective/geo/contentlocations/browser/geostylesform.py (revision 228306)
+++ src/collective.geo.contentlocations/collective/geo/contentlocations/browser/geostylesform.py (working copy)
@@ -15,7 +15,8 @@
'polygoncolor',
'marker_image',
'marker_image_size',
- 'display_properties')
+ 'display_properties',
+ 'map_display_manager')
fields['linecolor'].widgetFactory = ColorpickerAlphaFieldWidget
fields['polygoncolor'].widgetFactory = ColorpickerAlphaFieldWidget
Index: src/collective.geo.contentlocations/collective/geo/contentlocations/geostylemanager.py
===================================================================
--- src/collective.geo.contentlocations/collective/geo/contentlocations/geostylemanager.py (revision 228306)
+++ src/collective.geo.contentlocations/collective/geo/contentlocations/geostylemanager.py (working copy)
@@ -37,6 +37,7 @@
self.geostyles['marker_image'] = self.defaultstyles.marker_image
self.geostyles['marker_image_size'] = self.defaultstyles.marker_image_size
self.geostyles['display_properties'] = self.defaultstyles.display_properties
+ self.geostyles['map_display_manager'] = self.defaultstyles.map_display_manager
@property
def use_custom_styles(self):
@@ -66,6 +67,10 @@
def display_properties(self):
return self.get('display_properties')
+ @property
+ def map_display_manager(self):
+ return self.get('map_display_manager')
+
def set(self, key, val):
return self.geostyles.__setitem__(key, val)
Index: src/collective.geo.kml/collective/geo/kml/browser/configure.zcml
===================================================================
--- src/collective.geo.kml/collective/geo/kml/browser/configure.zcml (revision 228306)
+++ src/collective.geo.kml/collective/geo/kml/browser/configure.zcml (working copy)
@@ -79,6 +79,18 @@
permission="zope2.View"
/>
+ <browser:viewlet
+ name="collective.geo.kml.kmlbelowcontentviewlet"
+ for="collective.geo.geographer.interfaces.IGeoreferenceable"
+ class=".viewlets.ContentViewlet"
+ manager="plone.app.layout.viewlets.interfaces.IBelowContentBody"
+ template="kmlcontentviewlet.pt"
+ layer="..interfaces.IGeoKmlLayer"
+ permission="zope2.View"
+ />
+
+
+
<adapter
for="..interfaces.IKMLOpenLayersViewlet
zope.interface.Interface
Index: src/collective.geo.kml/collective/geo/kml/browser/viewlets.py
===================================================================
--- src/collective.geo.kml/collective/geo/kml/browser/viewlets.py (revision 228306)
+++ src/collective.geo.kml/collective/geo/kml/browser/viewlets.py (working copy)
@@ -1,7 +1,12 @@
from zope.interface import implements
+from zope.component import getUtility
+
from plone.app.layout.viewlets import ViewletBase
+from plone.registry.interfaces import IRegistry
+
from collective.geo.geographer.interfaces import IGeoreferenced
+from collective.geo.settings.interfaces import IGeoCustomFeatureStyle, IGeoFeatureStyle
from collective.geo.mapwidget.browser.widget import MapLayers
from collective.geo.kml.browser.maplayers import KMLMapLayer
@@ -11,14 +16,30 @@
class ContentViewlet(ViewletBase):
implements(IKMLOpenLayersViewlet)
+
@property
+ def display_manager(self):
+ dm = IGeoCustomFeatureStyle(self.context).map_display_manager
+ if dm:
+ return dm
+ else:
+ defaultstyles = getUtility(IRegistry).forInterface(
+ IGeoFeatureStyle)
+ return defaultstyles.map_display_manager
+
+
+ @property
def coordinates(self):
return IGeoreferenced(self.context)
def render(self):
- coords = self.coordinates
- if coords.type and coords.coordinates:
- return super(ContentViewlet, self).render()
+ display_manager = self.display_manager
+ if self.manager.__name__ == display_manager:
+ coords = self.coordinates
+ if coords.type and coords.coordinates:
+ return super(ContentViewlet, self).render()
+ else:
+ return ''
else:
return ''
Index: src/collective.geo.settings/collective/geo/settings/configure.zcml
===================================================================
--- src/collective.geo.settings/collective/geo/settings/configure.zcml (revision 228306)
+++ src/collective.geo.settings/collective/geo/settings/configure.zcml (working copy)
@@ -22,4 +22,9 @@
name="displaypropertiesVocab"
provides="zope.app.schema.vocabulary.IVocabularyFactory" />
+ <utility
+ factory=".vocabularies.managerpropertiesVocab"
+ name="managerpropertiesVocab"
+ provides="zope.app.schema.vocabulary.IVocabularyFactory" />
+
</configure>
Index: src/collective.geo.settings/collective/geo/settings/vocabularies.py
===================================================================
--- src/collective.geo.settings/collective/geo/settings/vocabularies.py (revision 228306)
+++ src/collective.geo.settings/collective/geo/settings/vocabularies.py (working copy)
@@ -3,8 +3,15 @@
from zope.app.schema.vocabulary import IVocabularyFactory
+from Products.CMFCore.utils import getToolByName
+
from collective.geo.settings import DISPLAY_PROPERTIES
+# config for possible viewlet managers
+PROPERTY_SHEET = 'collective_geo_settings_properties'
+PROPERTY_DEFAULT_MAP_MANAGER = 'default_map_manager'
+PROPERTY_MAP_MANAGERS = 'map_managers'
+
class baseVocabulary(object):
implements(IVocabularyFactory)
terms = []
@@ -21,3 +28,18 @@
class displaypropertiesVocab(baseVocabulary):
terms = DISPLAY_PROPERTIES
+
+class managerpropertiesVocab(baseVocabulary):
+
+ def __call__(self, context):
+ terms = []
+ portal_props = getToolByName(context, 'portal_properties')
+ properties = getattr(portal_props, PROPERTY_SHEET, None)
+ if properties:
+ self.terms = getattr(properties, PROPERTY_MAP_MANAGERS, [])
+ for term in self.terms:
+ terms.append(vocabulary.SimpleVocabulary.createTerm(term[0],
+ term[0],
+ term[0]))
+ return vocabulary.SimpleVocabulary(terms)
+
Index: src/collective.geo.settings/collective/geo/settings/interfaces.py
===================================================================
--- src/collective.geo.settings/collective/geo/settings/interfaces.py (revision 228306)
+++ src/collective.geo.settings/collective/geo/settings/interfaces.py (working copy)
@@ -63,7 +63,14 @@
default=u"YOUR_API_KEY",
required=False)
+ default_manager = schema.TextLine(
+ title=_(u"Default Viewlet Manager"),
+ description=_(u"Select where you want your map to be displayed"),
+ default=u"plone.abovecontentbody",
+ required=False)
+
+
class IGeoFeatureStyle(Interface):
"""IGeoFeatureStyle
describe some properties used to display different
@@ -103,7 +110,15 @@
vocabulary='displaypropertiesVocab'),
default = ['Title', 'Description'])
+ map_display_manager = schema.TextLine(
+ title=_(u"Viewlet Manager"),
+ description=_(u"Select where you want your map to be displayed"),
+ #value_type=schema.Choice(
+ # vocabulary='managerpropertiesVocab'),
+ default=u"plone.abovecontentbody",
+ required=False)
+
class IGeoCustomFeatureStyle(IGeoFeatureStyle):
"""IGeoCustomFeatureStyle
describe some properties used to display different
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community