src/pyams_content/shared/imagemap/interfaces/__init__.py
branchdev-dc
changeset 1086 3d259e1718ef
parent 1079 a5e56749ca3d
parent 1084 6b6a884fa28a
child 1087 978a2b9123b9
equal deleted inserted replaced
1079:a5e56749ca3d 1086:3d259e1718ef
     1 #
       
     2 # Copyright (c) 2008-2015 Thierry Florac <tflorac AT ulthar.net>
       
     3 # All Rights Reserved.
       
     4 #
       
     5 # This software is subject to the provisions of the Zope Public License,
       
     6 # Version 2.1 (ZPL).  A copy of the ZPL should accompany this distribution.
       
     7 # THIS SOFTWARE IS PROVIDED "AS IS" AND ANY AND ALL EXPRESS OR IMPLIED
       
     8 # WARRANTIES ARE DISCLAIMED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
       
     9 # WARRANTIES OF TITLE, MERCHANTABILITY, AGAINST INFRINGEMENT, AND FITNESS
       
    10 # FOR A PARTICULAR PURPOSE.
       
    11 #
       
    12 
       
    13 __docformat__ = 'restructuredtext'
       
    14 
       
    15 
       
    16 # import standard library
       
    17 
       
    18 # import interfaces
       
    19 from pyams_content.component.paragraph.interfaces import IBaseParagraph
       
    20 from pyams_content.shared.common.interfaces import ISharedTool, IWfSharedContent, ISharedContent
       
    21 from pyams_sequence.interfaces import IInternalReference
       
    22 from zope.annotation.interfaces import IAttributeAnnotatable
       
    23 
       
    24 # import packages
       
    25 from pyams_content.shared.imagemap.schema import MapArea
       
    26 from pyams_i18n.schema import I18nTextLineField, I18nImageField
       
    27 from pyams_sequence.schema import InternalReferenceField
       
    28 from pyams_utils.schema import PersistentDict
       
    29 from zope.interface import Interface
       
    30 from zope.schema import Object, Choice
       
    31 
       
    32 from pyams_content import _
       
    33 
       
    34 
       
    35 IMAGEMAP_CONTENT_TYPE = 'imagemap'
       
    36 IMAGEMAP_CONTENT_NAME = _("Image map")
       
    37 
       
    38 
       
    39 class IImageMapManager(ISharedTool):
       
    40     """Image maps manager interface"""
       
    41 
       
    42 
       
    43 class IImageMapManagerFactory(Interface):
       
    44     """Image maps manager factory interface"""
       
    45 
       
    46 
       
    47 class IImageMapArea(IAttributeAnnotatable):
       
    48     """Image map area interface"""
       
    49 
       
    50     link = Choice(title=_("Link target"),
       
    51                   description=_("Internal or external link associated with this map area"),
       
    52                   vocabulary="PyAMS content associations",
       
    53                   required=True)
       
    54 
       
    55     title = I18nTextLineField(title=_("Alternate title"),
       
    56                               description=_("Alternate label associated with this area"),
       
    57                               required=False)
       
    58 
       
    59     area = MapArea(title=_("Map area coordinates"),
       
    60                    description=_("List of coordinates of image area"),
       
    61                    required=True)
       
    62 
       
    63 
       
    64 class IWfImageMap(IWfSharedContent):
       
    65     """Image map interface"""
       
    66 
       
    67     image = I18nImageField(title=_("Image"),
       
    68                            description=_("Image supporting map areas"),
       
    69                            required=True)
       
    70 
       
    71     areas = PersistentDict(title=_("Image map areas"),
       
    72                            description=_("List of defined map areas"),
       
    73                            value_type=Object(schema=IImageMapArea),
       
    74                            required=False)
       
    75 
       
    76     def get_association(self, area):
       
    77         """Get association for given area"""
       
    78 
       
    79 
       
    80 class IWfImageMapFactory(Interface):
       
    81     """Image map factory interface"""
       
    82 
       
    83 
       
    84 class IImageMap(ISharedContent):
       
    85     """Workflow managed image map interface"""
       
    86 
       
    87 
       
    88 IMAGEMAP_PARAGRAPH_TYPE = 'ImageMap'
       
    89 IMAGEMAP_PARAGRAPH_NAME = _("Image map")
       
    90 IMAGEMAP_PARAGRAPH_RENDERERS = 'PyAMS.paragraph.imagemap.renderers'
       
    91 
       
    92 
       
    93 class IImageMapParagraph(IBaseParagraph, IInternalReference):
       
    94     """Image map paragraph"""
       
    95 
       
    96     reference = InternalReferenceField(title=_("Internal reference"),
       
    97                                        description=_("Reference to image map object"),
       
    98                                        content_type=IMAGEMAP_CONTENT_TYPE)
       
    99 
       
   100     renderer = Choice(title=_("Image map template"),
       
   101                       description=_("Presentation template used for this paragraph"),
       
   102                       vocabulary=IMAGEMAP_PARAGRAPH_RENDERERS,
       
   103                       default='default')