src/pyams_content/component/links/interfaces/__init__.py
changeset 1059 34e6d07ea2e9
parent 1058 1fe028e17f70
child 1060 29b1aaf9e080
equal deleted inserted replaced
1058:1fe028e17f70 1059:34e6d07ea2e9
     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.association.interfaces import IAssociationContainerTarget, IAssociationItem
       
    20 from pyams_content.reference.pictograms.interfaces import SELECTED_PICTOGRAM_VOCABULARY
       
    21 from pyams_sequence.interfaces import IInternalReference
       
    22 
       
    23 # import packages
       
    24 from pyams_i18n.schema import I18nTextLineField, I18nTextField
       
    25 from pyams_utils.schema import MailAddressField
       
    26 from zope.interface import Attribute
       
    27 from zope.schema import Choice, TextLine, URI
       
    28 
       
    29 from pyams_content import _
       
    30 
       
    31 
       
    32 class IBaseLink(IAssociationItem):
       
    33     """Base link interface"""
       
    34 
       
    35     title = I18nTextLineField(title=_("Alternate title"),
       
    36                               description=_("Link title, as shown in front-office"),
       
    37                               required=False)
       
    38 
       
    39     description = I18nTextField(title=_("Description"),
       
    40                                 description=_("Link description displayed by front-office template"),
       
    41                                 required=False)
       
    42 
       
    43     pictogram_name = Choice(title=_("Pictogram"),
       
    44                             description=_("Name of the pictogram associated with this link"),
       
    45                             required=False,
       
    46                             vocabulary=SELECTED_PICTOGRAM_VOCABULARY)
       
    47 
       
    48     pictogram = Attribute("Selected pictogram object")
       
    49 
       
    50     def get_editor_url(self):
       
    51         """Get URL for use in HTML editor"""
       
    52 
       
    53 
       
    54 class IInternalLink(IBaseLink, IInternalReference):
       
    55     """Internal link interface"""
       
    56 
       
    57 
       
    58 class IExternalLink(IBaseLink):
       
    59     """External link interface"""
       
    60 
       
    61     url = URI(title=_("Target URL"),
       
    62               description=_("URL used to access external resource"),
       
    63               required=True)
       
    64 
       
    65     language = Choice(title=_("Language"),
       
    66                       description=_("Language used in this remote resource"),
       
    67                       vocabulary='PyAMS base languages',
       
    68                       required=False)
       
    69 
       
    70 
       
    71 class IMailtoLink(IBaseLink):
       
    72     """Mailto link interface"""
       
    73 
       
    74     address = MailAddressField(title=_("Target address"),
       
    75                                description=_("Target email address"),
       
    76                                required=True)
       
    77 
       
    78     address_name = TextLine(title=_("Address name"),
       
    79                             description=_("Address as displayed in address book"),
       
    80                             required=True)
       
    81 
       
    82 
       
    83 class ILinkContainerTarget(IAssociationContainerTarget):
       
    84     """Links container marker interface"""