--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_default_theme/component/paragraph/map.py Wed Jul 18 15:51:05 2018 +0200
@@ -0,0 +1,99 @@
+#
+# Copyright (c) 2008-2018 Thierry Florac <tflorac AT ulthar.net>
+# All Rights Reserved.
+#
+# This software is subject to the provisions of the Zope Public License,
+# Version 2.1 (ZPL). A copy of the ZPL should accompany this distribution.
+# THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
+# WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+# WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
+# FOR A PARTICULAR PURPOSE.
+#
+
+__docformat__ = 'restructuredtext'
+
+
+from pyams_content.component.paragraph.interfaces.map import have_gis, IMapParagraph
+if have_gis:
+
+ # import standard library
+
+ # import interfaces
+ from pyams_content.features.renderer.interfaces import IContentRenderer
+ from pyams_default_theme.component.paragraph.interfaces.map import IMapParagraphDefaultRendererSettings
+ from pyams_gis.interfaces.configuration import IMapConfiguration
+ from pyams_gis.interfaces.utility import IMapManager
+ from pyams_skin.layer import IPyAMSLayer
+
+ # import packages
+ from pyams_content.features.renderer.skin import BaseContentRenderer
+ from pyams_gis.configuration import MapConfiguration
+ from pyams_template.template import template_config
+ from pyams_utils.adapter import adapter_config, get_annotation_adapter
+ from pyams_utils.registry import get_utility
+ from zope.interface import implementer
+ from zope.schema.fieldproperty import FieldProperty
+
+ from pyams_default_theme import _
+
+
+ #
+ # Map paragraph default renderer settings
+ #
+
+ MAP_DEFAULT_RENDERER_SETTINGS_KEY = 'pyams_content.map.renderer:default'
+
+
+ @implementer(IMapParagraphDefaultRendererSettings)
+ class MapParagraphDefaultRendererSettings(MapConfiguration):
+ """Map paragraph default renderer settings"""
+
+ _use_default_map_configuration = FieldProperty(IMapParagraphDefaultRendererSettings[
+ 'use_default_map_configuration'])
+
+ @property
+ def use_default_map_configuration(self):
+ return self._use_default_map_configuration
+
+ @use_default_map_configuration.setter
+ def use_default_map_configuration(self, value):
+ self._use_default_map_configuration = value
+
+ @property
+ def no_use_default_map_configuration(self):
+ return not bool(self.use_default_map_configuration)
+
+ @no_use_default_map_configuration.setter
+ def no_use_default_map_configuration(self, value):
+ self.use_default_map_configuration = not bool(value)
+
+ @property
+ def configuration(self):
+ if self.use_default_map_configuration:
+ manager = get_utility(IMapManager)
+ return IMapConfiguration(manager)
+ else:
+ return self
+
+
+ @adapter_config(context=IMapParagraph, provides=IMapParagraphDefaultRendererSettings)
+ def map_paragraph_default_renderer_settings_factory(context):
+ """Map paragraph default renderer settings factory"""
+ return get_annotation_adapter(context, MAP_DEFAULT_RENDERER_SETTINGS_KEY,
+ MapParagraphDefaultRendererSettings)
+
+
+ #
+ # Map paragraph default renderer
+ #
+
+ @adapter_config(name='default', context=(IMapParagraph, IPyAMSLayer), provides=IContentRenderer)
+ @template_config(template='templates/map-default.pt', layer=IPyAMSLayer)
+ class MapParagraphDefaultRenderer(BaseContentRenderer):
+ """Map paragraph default renderer"""
+
+ label = _("Default map renderer")
+
+ settings_interface = IMapParagraphDefaultRendererSettings
+
+ i18n_context_attrs = ('title', )