src/pyams_content/component/links/interfaces.py
changeset 1059 34e6d07ea2e9
parent 841 d50743e69693
child 1166 32668a609c7b
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/pyams_content/component/links/interfaces.py	Tue Nov 06 14:40:22 2018 +0100
@@ -0,0 +1,84 @@
+#
+# Copyright (c) 2008-2015 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'
+
+
+# import standard library
+
+# import interfaces
+from pyams_content.component.association.interfaces import IAssociationContainerTarget, IAssociationItem
+from pyams_content.reference.pictograms.interfaces import SELECTED_PICTOGRAM_VOCABULARY
+from pyams_sequence.interfaces import IInternalReference
+
+# import packages
+from pyams_i18n.schema import I18nTextLineField, I18nTextField
+from pyams_utils.schema import MailAddressField
+from zope.interface import Attribute
+from zope.schema import Choice, TextLine, URI
+
+from pyams_content import _
+
+
+class IBaseLink(IAssociationItem):
+    """Base link interface"""
+
+    title = I18nTextLineField(title=_("Alternate title"),
+                              description=_("Link title, as shown in front-office"),
+                              required=False)
+
+    description = I18nTextField(title=_("Description"),
+                                description=_("Link description displayed by front-office template"),
+                                required=False)
+
+    pictogram_name = Choice(title=_("Pictogram"),
+                            description=_("Name of the pictogram associated with this link"),
+                            required=False,
+                            vocabulary=SELECTED_PICTOGRAM_VOCABULARY)
+
+    pictogram = Attribute("Selected pictogram object")
+
+    def get_editor_url(self):
+        """Get URL for use in HTML editor"""
+
+
+class IInternalLink(IBaseLink, IInternalReference):
+    """Internal link interface"""
+
+
+class IExternalLink(IBaseLink):
+    """External link interface"""
+
+    url = URI(title=_("Target URL"),
+              description=_("URL used to access external resource"),
+              required=True)
+
+    language = Choice(title=_("Language"),
+                      description=_("Language used in this remote resource"),
+                      vocabulary='PyAMS base languages',
+                      required=False)
+
+
+class IMailtoLink(IBaseLink):
+    """Mailto link interface"""
+
+    address = MailAddressField(title=_("Target address"),
+                               description=_("Target email address"),
+                               required=True)
+
+    address_name = TextLine(title=_("Address name"),
+                            description=_("Address as displayed in address book"),
+                            required=True)
+
+
+class ILinkContainerTarget(IAssociationContainerTarget):
+    """Links container marker interface"""