Пример #1
0
 def specific_actions(self):
     return OrderedDict([
         ('imageLeft', {
             'class': 'icon-image-left server-action',
             'title': translate(
                 _(u'label_float_image_left', default=u'Float image left'),
                 context=self.request),
             'href': './sl-ajax-reload-block-view',
             'data-scale': 'sl_textblock_small',
             'data-imagefloat': 'left'
         }),
         ('imageLeftLarge', {
             'class': 'icon-image-left-large server-action',
             'title': translate(
                 _(u'label_float_large_image_left',
                   default=u'Float large image left'),
                 context=self.request),
             'href': './sl-ajax-reload-block-view',
             'data-scale': 'sl_textblock_middle',
             'data-imagefloat': 'left'
         }),
         ('image', {
             'class': 'icon-image server-action',
             'title': translate(
                 _(u'label_image_without_floating',
                   default=u'Image without floating'),
                 context=self.request),
             'href': './sl-ajax-reload-block-view',
             'data-scale': 'sl_textblock_large',
             'data-imagefloat': 'no-float'
         }),
         ('imageRightLarge', {
             'class': 'icon-image-right-large server-action',
             'title': translate(
                 _(u'label_float_large_image_right',
                   default=u'Float large image right'),
                 context=self.request),
             'href': './sl-ajax-reload-block-view',
             'data-scale': 'sl_textblock_middle',
             'data-imagefloat': 'right'
         }),
         ('imageRight', {
             'class': 'icon-image-right server-action',
             'title': translate(
                 _(u'label_float_image_right',
                   default=u'Float image right'),
                 context=self.request),
             'href': './sl-ajax-reload-block-view',
             'data-scale': 'sl_textblock_small',
             'data-imagefloat': 'right'
         }),
     ])
Пример #2
0
def sort_index_vocabulary(context):
    terms = []
    terms.append(SimpleVocabulary.createTerm(
        'sortable_title',
        'sortable_title',
        _(u'label_sort_by_title',
            default=u'Title')))
    terms.append(SimpleVocabulary.createTerm(
        'modified',
        'modified',
        _(u'column_modified',
            default=u'Latest changes')))

    return SimpleVocabulary(terms)
Пример #3
0
    def create(self, file_):
        content_type, width, height = getImageInfo(file_.read())
        file_.seek(0)
        if not content_type:
            error = translate(_('Only images can be added to the gallery.'), context=self.request)
            raise BadRequest(error)

        return self.create_obj('Image', 'image', file_)
Пример #4
0
 def validate_video_url(data):
     if is_youtube_url(data.video_url):
         return
     elif is_vimeo_url(data.video_url):
         return
     elif is_youtube_nocookie_url(data.video_url):
         return
     else:
         raise Invalid(_(u'This is no a valid youtube, or vimeo url.'))
def sort_index_vocabulary(context):
    adapter = queryMultiAdapter((context, context.REQUEST),
                                interfaces.IListingBlockColumns)
    terms = []
    for col in adapter.columns():
        if 'sort_index' in col:
            terms.append(SimpleVocabulary.createTerm(
                col['sort_index'],
                col['sort_index'],
                _(u'label_%s' % col['sort_index'],
                  default=col['sort_index'])))
    terms.append(SimpleVocabulary.createTerm(
        'getObjPositionInParent',
        'getObjPositionInParent',
        _(u'label_position_in_folder',
          default=u'Position in Folder')))

    return SimpleVocabulary(terms)
Пример #6
0
 def specific_actions(self):
     return OrderedDict([
         ('upload', {
             'class': 'upload icon-image-upload',
             'title': translate(
                 _(u'label_upload', default=u'Upload'),
                 context=self.request),
             'href': './sl-ajax-upload-block-view'
         }),
         ('folderContents', {
             'class': 'icon-folder-contents redirect',
             'title': translate(
                 _(u'label_folder_contents_images',
                   default=u'Go to folder contents for managing images'),
                 context=self.request),
             'href': '/folder_contents'
         }),
     ])
 def specific_actions(self):
     return OrderedDict([
         ('folderContents', {
             'class': 'sl-icon-folder-contents redirect',
             'title': translate(
                 _(u'label_folder_contents_files',
                   default=u'Go to folder contents for managing files'),
                 context=self.request),
             'href': '/folder_contents'
         }),
     ])
    def columns(self):
        columns = (
            {'column': 'getContentType',
             'column_title': _(u'column_type', default=u'Type'),
             'sort_index': 'portal_type',
             'transform': download_link(icon=True, icon_only=True)},

            {'column': 'Title',
             'column_title': _(u'column_title', default=u'Title'),
             'sort_index': 'sortable_title',
             'transform': download_link(icon=False)},

            {'column': 'modified',
             'column_title': _(u'column_modified', default=u'modified'),
             'sort_index': 'modified',
             'transform': helper.readable_date,
             },

            {'column': 'Creator',
             'column_title': _(u'column_creater', default=u'creater'),
             'transform': helper.readable_author,
             },

            {'column': 'getObjSize',
             'column_title': _(u'column_size', default=u'size'),
             },

            {'column': 'id',
             'column_title': _(u'ID', default=u'ID'),
             'sort_index': 'id',
             },
        )
        return columns
Пример #9
0
    def _get_link_title(self):
        alttext = ITextBlockSchema(self.context).image_alt_text

        if not alttext:
            return ""

        elif self.context.open_image_in_overlay and not self.teaser_url:
            return translate(
                _(u"image_link_alttext", default=u"${title}, enlarged picture.", mapping={"title": alttext}),
                context=self.request,
            )
        else:
            return alttext
Пример #10
0
    def _get_link_title(self):
        alttext = ITextBlockSchema(self.context).image_alt_text

        if not alttext:
            return ''

        elif self.context.open_image_in_overlay and not self.teaser_url:
            return translate(_(u'image_link_alttext',
                               default=u'${title}, enlarged picture.',
                               mapping={'title': alttext}),
                             context=self.request)
        else:
            return alttext
Пример #11
0
 def default_actions(self):
     """Contains default action - move, edit, delete"""
     return OrderedDict([
         ('move', {
             'class': 'move sl-icon-move',
             'title': translate(
                 _(u'label_move_block', default='Move block'),
                 context=self.request),
         }),
         ('edit', {
             'class': 'edit sl-icon-edit',
             'title': translate(
                 _(u'label_edit_block', default='Edit block'),
                 context=self.request),
             'href': self.context.absolute_url() + '/sl-ajax-edit-block-view'
         }),
         ('delete', {
             'class': 'delete sl-icon-delete',
             'title': translate(
                 _(u'label:delete_block', default='Delete block'),
                 context=self.request),
             'href': self.context.absolute_url() + '/sl-ajax-delete-blocks-view'
         })
     ])
Пример #12
0
    def limit_str(self, limit_type, identifier, image):
        limits = self._get_image_limits_for(limit_type, identifier)

        current_width = image._width
        current_height = image._height

        width = limits.get('width', 0)
        height = limits.get('height', 0)

        width_str = self._width_str(width, current_width)
        height_str = self._height_str(height, current_height)

        limit_str = ''
        if width and height:
            limit_str = _(u'limit_width_and_height',
                          default=u"${width_str} and ${height_str}",
                          mapping={'width_str': width_str, 'height_str': height_str})
        elif width:
            limit_str = width_str

        elif height:
            limit_str = height_str

        return limit_str
Пример #13
0
    def _hard_limit_not_satisfied_message(self, identifier, image):
        limit_str = self.limit_str('hard', identifier, image)

        return _(u'hard_limit_not_satisfied',
                 default=u"The image doesn't fit the required dimensions of ${limit_str}",
                 mapping={'limit_str': limit_str})
Пример #14
0
        'sortable_title',
        _(u'label_sort_by_title',
            default=u'Title')))
    terms.append(SimpleVocabulary.createTerm(
        'modified',
        'modified',
        _(u'column_modified',
            default=u'Latest changes')))

    return SimpleVocabulary(terms)

directlyProvides(sort_index_vocabulary, IContextSourceBinder)

sort_order_vocabulary = SimpleVocabulary([
    SimpleTerm(value='ascending',
               title=_(u'label_ascending', default=u'Ascending')),
    SimpleTerm(value='descending',
               title=_(u'label_descending', default=u'Descending'))
])


class IGalleryBlockSchema(form.Schema):
    """GalleryBlock for simplelayout
    """

    title = schema.TextLine(
        title=_(u'label_title', default=u'Title'),
        required=False)

    show_title = schema.Bool(
        title=_(u'label_show_title', default=u'Show title'),
Пример #15
0
 def generate_image_alttext(self, img):
     title = safe_unicode(img.title_or_id())
     return translate(_(u'image_link_alttext',
                        default=u'${title}, enlarged picture.',
                        mapping={'title': title}),
                      context=self.request)
Пример #16
0
 def title(self):
     if self.limit_type == 'hard':
         return _('imageresolution_too_small_label',
                  default="imageresolution is too small")
     elif self.limit_type == 'soft':
         return _('low_quality_image_label', default="low image quality")
Пример #17
0
    def _soft_limit_not_satisfied_message(self, identifier, image):
        limit_str = self.limit_str('soft', identifier, image)

        return _(u'soft_limit_not_satisfied',
                 default=u"Optimal image quality: ${limit_str}",
                 mapping={'limit_str': limit_str})
Пример #18
0
 def _height_str(self, height, current_height):
     return _(u'limit_height_str',
              default=u"height: ${height}px (current: ${current_height}px)",
              mapping={'height': height, 'current_height': current_height}
              )
Пример #19
0
 def _width_str(self, width, current_width):
     return _(u'limit_width_str',
              default=u"width: ${width}px (current: ${current_width}px)",
              mapping={'width': width, 'current_width': current_width}
              )
Пример #20
0
 def link_invariant(data):
     if data.external_link and data.internal_link:
         raise Invalid(_(
             u"It's not possible to have an internal_link and an "
             u"external_link together"))
from ftw.simplelayout import _
from ftw.simplelayout.interfaces import ISimplelayoutDefaultSettings
from plone.app.registry.browser.controlpanel import ControlPanelFormWrapper
from plone.app.registry.browser.controlpanel import RegistryEditForm
from plone.z3cform import layout
from z3c.form import form


class SimplelayoutDefaultSettingsForm(RegistryEditForm):
    form.extends(RegistryEditForm)
    schema = ISimplelayoutDefaultSettings

SimplelayoutDefaultSettingsView = layout.wrap_form(
    SimplelayoutDefaultSettingsForm,
    ControlPanelFormWrapper)
SimplelayoutDefaultSettingsView.label = _(u'Simplelayout settings')