--- a/src/pyams_content/component/paragraph/text.py Wed Mar 07 09:49:30 2018 +0100
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,106 +0,0 @@
-#
-# 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.extfile.interfaces import IExtFileContainerTarget
-from pyams_content.component.illustration.interfaces import IIllustrationTarget
-from pyams_content.component.links.interfaces import ILinkContainerTarget
-from pyams_content.component.paragraph.interfaces import IParagraphFactory
-from pyams_content.component.paragraph.interfaces.text import ITextParagraph, TEXT_PARAGRAPH_TYPE, \
- TEXT_PARAGRAPH_RENDERERS
-from pyams_content.features.checker.interfaces import IContentChecker, MISSING_VALUE, MISSING_LANG_VALUE
-from pyams_i18n.interfaces import II18n, II18nManager, INegotiator
-
-# import packages
-from pyams_content.component.paragraph import BaseParagraph, BaseParagraphContentChecker, BaseParagraphFactory
-from pyams_content.features.renderer import RenderedContentMixin, IContentRenderer
-from pyams_utils.adapter import adapter_config
-from pyams_utils.registry import utility_config, get_utility
-from pyams_utils.request import check_request
-from pyams_utils.traversing import get_parent
-from pyams_utils.vocabulary import vocabulary_config
-from zope.interface import implementer
-from zope.schema.fieldproperty import FieldProperty
-from zope.schema.vocabulary import SimpleVocabulary, SimpleTerm
-
-from pyams_content import _
-
-
-#
-# Text paragraph
-#
-
-@implementer(ITextParagraph, IIllustrationTarget, IExtFileContainerTarget, ILinkContainerTarget)
-class TextParagraph(RenderedContentMixin, BaseParagraph):
- """Framed text paragraph"""
-
- icon_class = 'fa-list-alt'
- icon_hint = _("Framed text")
-
- body = FieldProperty(ITextParagraph['body'])
- renderer = FieldProperty(ITextParagraph['renderer'])
-
-
-@utility_config(name=TEXT_PARAGRAPH_TYPE, provides=IParagraphFactory)
-class TextParagraphFactory(BaseParagraphFactory):
- """Framed text paragraph factory"""
-
- name = _("Framed text paragraph")
- content_type = TextParagraph
- secondary_menu = True
-
-
-@adapter_config(context=ITextParagraph, provides=IContentChecker)
-class TextParagraphContentChecker(BaseParagraphContentChecker):
- """Framed text paragraph content checker"""
-
- def inner_check(self, request):
- output = []
- translate = request.localizer.translate
- manager = get_parent(self.context, II18nManager)
- if manager is not None:
- langs = manager.get_languages()
- else:
- negotiator = get_utility(INegotiator)
- langs = (negotiator.server_language, )
- i18n = II18n(self.context)
- for lang in langs:
- for attr in ('title', 'body'):
- value = i18n.get_attribute(attr, lang, request)
- if not value:
- field_title = translate(ITextParagraph[attr].title)
- if len(langs) == 1:
- output.append(translate(MISSING_VALUE).format(field=field_title))
- else:
- output.append(translate(MISSING_LANG_VALUE).format(field=field_title, lang=lang))
- return output
-
-
-@vocabulary_config(name=TEXT_PARAGRAPH_RENDERERS)
-class TextParagraphRendererVocabulary(SimpleVocabulary):
- """Framed text paragraph renderers vocabulary"""
-
- def __init__(self, context=None):
- request = check_request()
- translate = request.localizer.translate
- registry = request.registry
- if not ITextParagraph.providedBy(context):
- context = TextParagraph()
- terms = [SimpleTerm(name, title=translate(adapter.label))
- for name, adapter in sorted(registry.getAdapters((context, request), IContentRenderer),
- key=lambda x: x[1].weight)]
- super(TextParagraphRendererVocabulary, self).__init__(terms)