示例#1
0
 def __call__(self, context):
     items = []
     styles = getVocabulary(context)
     charset = self._charset(context)
     for value, title in styles:
         if not isinstance(title, unicode):
             title = title.decode(charset)
         if not isinstance(value, unicode):
             value = value.decode(charset)
         items.append(SimpleTerm(value, value, _(title)))
     items.sort(lambda x,y:cmp(x.title,y.title))
     return SimpleVocabulary(items)
 def getLinkTitle(self):
     if self.data.target_attr:
         return _(u"Opens in a new window")
     else:
         return ""
class IRERPortletAdvancedStatic(static.IStaticPortlet):
    """
    A custom static text portlet
    """

    target_attr = schema.Bool(
        title=_(u"Open links in a new window"),
        description=_(
            u"Tick this box if you want to open the header "
            "and footer links in a new window"
        ),
        required=False,
        default=False,
    )

    image_ref = schema.Choice(
        title=_(u"Background image"),
        description=_(
            u"Insert an image that will be shown as background of the header"
        ),
        required=False,
        source=CatalogSource(portal_type="Image"),
    )

    image_ref_height = schema.Int(
        title=_(u"Background image height"),
        description=_(
            u"Specify image background's height (in pixels). If empty will"
            " be used image's height."
        ),
        required=False,
    )

    internal_url = schema.Choice(
        title=_(u"Internal link"),
        description=_(
            u"Insert an internal link. This field override external link field"
        ),
        required=False,
        source=CatalogSource(),
    )

    portlet_class = schema.TextLine(
        title=_(u"Portlet class"),
        required=False,
        description=_(u"CSS class to add at the portlet"),
    )

    css_style = schema.Choice(
        title=_(u"Portlet style"),
        description=_(u"Choose a CSS style for the portlet"),
        required=False,
        vocabulary="rer.portlet.advanced_static.CSSVocabulary",
    )
 def getLinkTitle(self):
     if self.data.target_attr:
         return _(u'Opens in a new window')
     else:
         return ''
示例#5
0
from Products.ATContentTypes.interface import IATImage
from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile
from plone.app.form.widgets.uberselectionwidget import UberSelectionWidget
from plone.app.form.widgets.wysiwygwidget import WYSIWYGWidget
from plone.app.vocabularies.catalog import SearchableTextSourceBinder
from plone.portlet.static import static
from rer.portlet.advanced_static import \
    RERPortletAdvancedStaticMessageFactory as _
from zope import schema
from zope.app.form.browser.itemswidgets import SelectWidget
from zope.formlib import form
from zope.interface import implements
from zope.component import getMultiAdapter
import sys

SelectWidget._messageNoValue = _("vocabulary-missing-single-value-for-edit",
                      "-- select a value --")


class IRERPortletAdvancedStatic(static.IStaticPortlet):
    """
    A custom static text portlet
    """

    target_attr = schema.Bool(
        title=_(u"Open links in a new window"),
        description=_(u"Tick this box if you want to open the header "
            "and footer links in a new window"),
        required=False,
        default=False
        )