diff -r 000000000000 -r 7c0001cacf8e src/pyams_content/component/links/interfaces/__init__.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/src/pyams_content/component/links/interfaces/__init__.py Thu Oct 08 13:37:29 2015 +0200 @@ -0,0 +1,103 @@ +# +# Copyright (c) 2008-2015 Thierry Florac +# 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 zope.annotation.interfaces import IAttributeAnnotatable +from zope.container.interfaces import IContainer + +# import packages +from pyams_i18n.schema import I18nTextLineField, I18nTextField +from pyams_sequence.schema import InternalReference +from pyams_utils.schema import PersistentList +from zope.container.constraints import containers, contains +from zope.interface import Interface, Attribute +from zope.schema import Choice, TextLine + +from pyams_content import _ + + +LINK_CONTAINER_KEY = 'pyams_content.link' +LINK_LINKS_CONTAINER_KEY = 'pyams_content.link.links' + + +class IBaseLink(IAttributeAnnotatable): + """Base link interface""" + + containers('.ILinkContainer') + + title = I18nTextLineField(title=_("Title"), + description=_("Link title, as shown in front-office"), + required=True) + + description = I18nTextField(title=_("Description"), + description=_("Link description displayed by front-office template"), + required=False) + + def get_editor_url(self): + """Get URL for use in HTML editor""" + + def get_url(self, request, view_name=None): + """Get link URL""" + + +class IInternalLink(IBaseLink): + """Internal link interface""" + + reference = InternalReference(title=_("Internal reference"), + description=_("Internal link target reference. You can search a reference using " + "'+' followed by internal number, of by entering text matching " + "content title."), + required=True) + + def get_target(self, state=None): + """Get reference target""" + + +class IExternalLink(IBaseLink): + """External link interface""" + + url = TextLine(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 ILinkContainer(IContainer): + """Links container""" + + contains(IBaseLink) + + +class ILinkContainerTarget(Interface): + """Links container marker interface""" + + +class ILinkLinksContainer(Interface): + """Links links container interface""" + + links = PersistentList(title=_("Contained links"), + description=_("List of internal or external links linked to this object"), + value_type=Choice(vocabulary="PyAMS content links"), + required=False) + + +class ILinkLinksContainerTarget(Interface): + """Links links container marker interface"""