Esempio n. 1
0
    def insertAlias(self):
        uid_catalog = cmfutils.getToolByName(self.context,
                                             'uid_catalog')

        uid = self.request.get('uid')
        container = self.context

        # check that target object exists
        brains = uid_catalog(UID=uid)
        if brains:
            # find first available id for the alias object
            ids = [i[6:]
                   for i in container.objectIds() if i.startswith('alias-')]
            alias_id = 'alias-%s' % findFirstAvailableInteger(ids)

            # create new alias
            container.invokeFactory('CollageAlias', id=alias_id)
            alias = container[alias_id]

            # set target
            alias.set_target(uid)
            event.notify(ObjectModifiedEvent(alias))
            msg = _(u'msg_alias_inserted', default=u"Alias inserted.")
        else:
            msg = _(
                u'msg_target_object_not_found',
                default=u"Target object not found.")

        referer = self.request.get('HTTP_REFERER', self.context.absolute_url())
        self.context.plone_utils.addPortalMessage(msg)
        return self.request.RESPONSE.redirect(referer)
Esempio n. 2
0
    def getLayouts(self):
        context = self.context

        # handle aliased objects
        alias = getattr(self.__parent__, '__alias__', None)
        if alias: context = alias

        manager = IDynamicViewManager(context)

        # lookup active layout
        active = manager.getLayout()

        if not active:
            active, title = manager.getDefaultLayout()

        # compile list of registered layouts
        layouts = manager.getLayouts()

        # filter out fallback view
        layouts = filter(lambda (name, title): name != u'fallback', layouts)

        # make sure the active layout (which may not be available) is
        # included
        if active not in [name for name, title in layouts]:
            layouts.append(
                (active, _(u"Missing: $name", mapping={'name': active})))

        return [{
            'id': name,
            'name': title,
            'active': name == active} for (name, title) in layouts]
Esempio n. 3
0
    def getLayouts(self):
        context = self.context

        # handle aliased objects
        alias = getattr(self.__parent__, '__alias__', None)
        if alias:
            context = alias

        manager = IDynamicViewManager(context)

        # lookup active layout
        active = manager.getLayout()

        if not active:
            active, _title = manager.getDefaultLayout()

        # compile list of registered layouts
        layouts = manager.getLayouts()

        # filter out fallback view
        layouts = filter(lambda name_title: name_title[0] != u'fallback',
                         layouts)

        # make sure the active layout (which may not be available) is
        # included
        if active not in [name for name, title in layouts]:
            layouts.append(
                (active, _(u"Missing: $name", mapping={'name': active})))

        return [{
            'id': name,
            'name': title,
            'active': name == active
        } for (name, title) in layouts]
Esempio n. 4
0
    def insertColumn(self):
        container = self.context
        desired_id = generateNewId(container)

        container.invokeFactory(id=desired_id, type_name='CollageColumn')

        self.context.plone_utils.addPortalMessage(_(u'msg_column_inserted', default="Column inserted."))
        self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 5
0
class FileMinimalView(StandardView):
    """File for download in one line."""

    title = _(u'minimal')

    def getBUFile(self):
        acc = self.context.Schema()['file'].getAccessor(self.context)()
        return acc
Esempio n. 6
0
 def deleteObject(self):
     parent = self.context.aq_inner.aq_parent
     parent.manage_delObjects(self.context.getId())
     fti = self.context.portal_types[self.context.portal_type]
     title = self.context.translate(fti.title, domain='plone')
     message = _(u'${title} deleted.', mapping={u'title': title})
     self.context.plone_utils.addPortalMessage(message)
     self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 7
0
    def setDynamicView(self):
        layout = self.request['layout']

        manager = IDynamicViewManager(self.context)
        manager.setLayout(layout)

        self.context.plone_utils.addPortalMessage(_(u'View changed.'))
        self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 8
0
    def setDynamicSkin(self):
        skin = self.request['skin']

        manager = IDynamicViewManager(self.context)
        manager.setSkin(skin)

        self.context.plone_utils.addPortalMessage(_(u'Skin changed.'))
        self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 9
0
    def insertColumn(self):
        container = self.context
        desired_id = generateNewId(container)

        container.invokeFactory(id=desired_id, type_name='CollageColumn')

        self.context.plone_utils.addPortalMessage(
            _(u'msg_column_inserted', default="Column inserted."))
        self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 10
0
 def __call__(self):
     try:
         return self.index()
     except self.catch_exceptions:
         IStatusMessage(self.request).addStatusMessage(
             _(u"Unable to render layout: ${title}.", mapping={
                 'title': translate(self.title, context=self.request)
                 }), type="warning")
         return self.fallback()
Esempio n. 11
0
 def __call__(self):
     try:
         return self.index()
     except self.catch_exceptions:
         IStatusMessage(self.request).addStatusMessage(_(
             u"Unable to render layout: ${title}.",
             mapping={'title': translate(self.title,
                                         context=self.request)}),
                                                       type="warning")
         return self.fallback()
Esempio n. 12
0
    def insertRow(self):
        # create row
        desired_id = generateNewId(self.context)
        row_id = self.context.invokeFactory(id=desired_id, type_name='CollageRow')
        row = getattr(self.context, row_id, None)
        row.setTitle('')

        # create column
        desired_id = generateNewId(row)
        col_id = row.invokeFactory(id=desired_id, type_name='CollageColumn')
        col = getattr(row, col_id, None)
        col.setTitle('')

        self.context.plone_utils.addPortalMessage(_(u'msg_row_added', default=u"Row was added."))
        self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 13
0
    def insertRow(self):
        # create row
        desired_id = generateNewId(self.context)
        row_id = self.context.invokeFactory(
            id=desired_id, type_name='CollageRow')
        row = getattr(self.context, row_id, None)
        row.setTitle('')

        # create column
        desired_id = generateNewId(row)
        col_id = row.invokeFactory(id=desired_id, type_name='CollageColumn')
        col = getattr(row, col_id, None)
        col.setTitle('')

        self.context.plone_utils.addPortalMessage(
            _(u'msg_row_added', default=u"Row was added."))
        self.request.response.redirect(self.context.REQUEST['HTTP_REFERER'])
Esempio n. 14
0
class InheritTopicView(BaseTopicView):
    """Inherits view from topic's display setting."""

    title = _(u'Inherit')

    mapping = {
        'folder_listing': 'standard',
        'folder_summary_view': 'summary',
        'folder_tabular_view': 'tabular',
        'atct_album_view': 'album',
        'atct_topic_view': 'standard',
    }

    error_view_name = "error_collage-view-not-found"
    fallback_view_name = "fallback"

    def __call__(self):
        """Determine inherited view and attempt to find suitable
        collage view.

        If a view can't be determined, render fallback view. If the
        view does not exist, render an error message.
        """

        layout = self.context.getLayout()
        name = self.mapping.get(layout, self.fallback_view_name)
        spec = providedBy(self.context), ICollageBrowserLayer
        lookup = getSiteManager().adapters.lookup
        factory = lookup(spec, Interface, name=name)
        if factory is None:
            name = None
            factory = lookup(spec, Interface, name=self.error_view_name)
            if factory is None:
                raise ComponentLookupError(
                    "Layout not found: %s (and unable to render error view)." %
                    layout)
        view = factory(self.context, self.request)
        if name is None:
            view.notfoundlayoutname = layout

        view.__alias__ = self.__alias__
        return view()
Esempio n. 15
0
class LargeRightRowView(RowView):
    title = _(u'Large right')
Esempio n. 16
0
class LargeLeftRowView(RowView):
    title = _(u'Large left')
Esempio n. 17
0
from Products.ATContentTypes.content.base import ATCTContent
from Products.Archetypes import atapi
from Products.ATReferenceBrowserWidget.ATReferenceBrowserWidget import ReferenceBrowserWidget
from Products.Collage.utilities import CollageMessageFactory as _

CollageAliasSchema = ATCTContent.schema.copy() + atapi.Schema((
    atapi.ReferenceField(
        name='target',
        mutator='set_target',
        accessor='get_target',
        relationship='Collage_aliasedItem',
        multiValued = 0,
        allowed_types = (),
        keepReferencesOnCopy = True,
        widget=ReferenceBrowserWidget(
            label=_(u'label_alias_target', default="Selected target object"),
            startup_directory='/',
        ),
    ),
))

CollageAlias.schema = CollageAliasSchema

# Patching del ATContentypes/content/File.py Class ATFile
# Required per tal de poder veure flash en condicions
from Products.ATContentTypes.content.file import ATFile

inlineMimetypes= ('application/msword',
                      'application/x-msexcel', # ?
                      'application/vnd.ms-excel',
                      'application/vnd.ms-powerpoint',
Esempio n. 18
0
class AlbumTopicView(BaseTopicView):
    title = _(u'Album')
from zope.interface import implements

# CMFDynamicViewFTI imports
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.Collage.utilities import CollageMessageFactory as _

CollageRowSchema = atapi.BaseContent.schema.copy() + atapi.Schema(
    (
        atapi.StringField(
            name="title",
            accessor="Title",
            required=False,
            widget=atapi.StringWidget(
                label=_(u"label_optional_row_title", default="Title"),
                description=_(u"help_optional_row_title", default=u"You may optionally supply a title for this row."),
            ),
        ),
    )
)

CollageRowSchema = CollageRowSchema + CommonCollageSchema.copy()

# move description to main edit page
CollageRowSchema["description"].schemata = "default"

# never show row in navigation, also when its selected
CollageRowSchema["excludeFromNav"].default = True

# support show in navigation feature and at marshalling
Esempio n. 20
0
from zope.interface import implements

# CMFDynamicViewFTI imports
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.Collage.utilities import CollageMessageFactory as _

CollageRowSchema = atapi.BaseContent.schema.copy() + atapi.Schema((
    atapi.StringField(
        name='title',
        accessor='Title',
        required=False,
        searchable=True,
        widget=atapi.StringWidget(
            label=_(u'label_optional_row_title', default='Title'),
            description=_(u'help_optional_row_title', default=u"You may optionally supply a title for this row."),
        )
    ),
))

CollageRowSchema = CollageRowSchema + CommonCollageSchema.copy()

# move description to main edit page
CollageRowSchema['description'].schemata = 'default'

# never show row in navigation, also when its selected
CollageRowSchema['excludeFromNav'].default = True

# support show in navigation feature and at marshalling
finalizeATCTSchema(CollageRowSchema, folderish=True, moveDiscussion=False)
Esempio n. 21
0
class CollectionSummaryView(BaseView):
    title = _(u'Summary')
Esempio n. 22
0
class PortletDefaultSkin(object):
    title = _(u"default", default=u"Default")
Esempio n. 23
0
class FeaturedView(BaseView):
    title = _(u'Featured')
Esempio n. 24
0
class TextView(BaseView):
    title = _(u'Text')
Esempio n. 25
0
class TabularTopicView(BaseTopicView):
    title = _(u'Tabular')
Esempio n. 26
0
class SummaryTopicView(BaseTopicView):
    title = _(u'Summary')
Esempio n. 27
0
class StandardTopicView(BaseTopicView):
    title = _(u'Standard')
Esempio n. 28
0
class AutomaticRowView(RowView):
    title = _(u'Automatic')
Esempio n. 29
0
class ClickableView(BaseView):
    title = _(u'Clickable')
Esempio n. 30
0
class PortletNotificationSkin(object):
    title = _(u"notification_skin", default=u"Notification")
Esempio n. 31
0
class StandardView(BaseView):
    title = _(u'Standard')
Esempio n. 32
0
class PortletHelpSkin(object):
    title = _(u"help_skin", default=u"Help")
Esempio n. 33
0
class UnbatchedRowView(RowView):
    title = _(u'Unbatched')
Esempio n. 34
0
from Products.Collage.utilities import CollageMessageFactory as _
from zope.interface import implementer

try:
    from Products.LinguaPlone import public as atapi
except ImportError:
    from Products.Archetypes import atapi

CollageRowSchema = atapi.BaseContent.schema.copy() + atapi.Schema(
    (atapi.StringField(
        name='title',
        accessor='Title',
        required=False,
        searchable=True,
        widget=atapi.StringWidget(
            label=_(u'label_optional_row_title', default='Title'),
            description=_(
                u'help_optional_row_title',
                default=u"You may optionally supply a title for this row."),
        )), ))

CollageRowSchema = CollageRowSchema + CommonCollageSchema.copy()

# move description to main edit page
CollageRowSchema['description'].schemata = 'default'

# never show row in navigation, also when its selected
CollageRowSchema['excludeFromNav'].default = True

# support show in navigation feature and at marshalling
finalizeATCTSchema(CollageRowSchema, folderish=True, moveDiscussion=False)
Esempio n. 35
0
from zope.interface import implements

# CMFDynamicViewFTI imports
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.Collage.utilities import CollageMessageFactory as _

CollageColumnSchema = atapi.BaseContent.schema.copy() + atapi.Schema((
    atapi.StringField(
        name='title',
        accessor='Title',
        required=False,
        searchable=True,
        widget=atapi.StringWidget(
            label=_(u'label_optional_column_title', default=u"Title"),
            description=_(u'help_optional_column_title',
                          default=u"You may optionally supply a title for this column."),
        )
    ),
))

CollageColumnSchema = CollageColumnSchema + CommonCollageSchema.copy()

# move description to main edit page
CollageColumnSchema['description'].schemata = 'default'

# never show row in navigation, also when its selected
CollageColumnSchema['excludeFromNav'].default = True

# support show in navigation feature and at marshalling
# CMFDynamicViewFTI imports
from Products.CMFDynamicViewFTI.browserdefault import BrowserDefaultMixin

from Products.Collage.utilities import CollageMessageFactory as _

CollageAliasSchema = ATCTContent.schema.copy() + atapi.Schema(
    (
        atapi.ReferenceField(
            name="target",
            mutator="set_target",
            accessor="get_target",
            relationship="Collage_aliasedItem",
            multiValued=0,
            allowed_types=(),
            widget=ReferenceBrowserWidget(
                label=_(u"label_alias_target", default="Selected target object"), startup_directory="/"
            ),
        ),
    )
)

# we don't require any fields to be filled out
CollageAliasSchema["title"].required = False

# never show in navigation, also when its selected
CollageAliasSchema["excludeFromNav"].default = True

CollageAliasSchema["relatedItems"].widget.visible = {"edit": "invisible", "view": "invisible"}


class CollageAlias(BrowserDefaultMixin, LayoutContainer, ATCTContent):
Esempio n. 37
0
 (
     atapi.StringField(
         name="title",
         searchable=True,
         widget=atapi.StringWidget(label="Title", label_msgid="label_title", i18n_domain="plone"),
     ),
     atapi.TextField(
         name="description",
         searchable=True,
         widget=atapi.TextAreaWidget(label="Description", label_msgid="label_description", i18n_domain="plone"),
     ),
     atapi.BooleanField(
         "show_title",
         accessor="getShowTitle",
         widget=atapi.BooleanWidget(
             label=_(u"label_show_title", default=u"Show title"),
             description=_(u"help_show_title", default=u"Show title in page composition."),
         ),
         default=1,
         languageIndependent=True,
         schemata="settings",
     ),
     atapi.BooleanField(
         "show_description",
         accessor="getShowDescription",
         widget=atapi.BooleanWidget(
             label=_(u"label_show_description", default="Show description"),
             description=_(u"help_show_description", default=u"Show description in page composition."),
         ),
         default=1,
         languageIndependent=True,
Esempio n. 38
0
from Products.Collage.utilities import CollageMessageFactory as _
from zope.interface import implementer

try:
    from Products.LinguaPlone import public as atapi
except ImportError:
    from Products.Archetypes import atapi

CollageColumnSchema = atapi.BaseContent.schema.copy() + atapi.Schema(
    (atapi.StringField(
        name='title',
        accessor='Title',
        required=False,
        searchable=True,
        widget=atapi.StringWidget(
            label=_(u'label_optional_column_title', default=u"Title"),
            description=_(
                u'help_optional_column_title',
                default=u"You may optionally supply a title for this column."),
        )), ))

CollageColumnSchema = CollageColumnSchema + CommonCollageSchema.copy()

# move description to main edit page
CollageColumnSchema['description'].schemata = 'default'

# never show row in navigation, also when its selected
CollageColumnSchema['excludeFromNav'].default = True

# support show in navigation feature and at marshalling
finalizeATCTSchema(CollageColumnSchema, folderish=True, moveDiscussion=False)
Esempio n. 39
0
class PortletView(BaseView):
    title = _(u'Portlet')
    skinInterfaces = (IPortletSkin, )
        )
    ),

    atapi.TextField(
        name='description',
        searchable=True,
        widget=atapi.TextAreaWidget(
            label='Description',
            label_msgid='label_description',
            i18n_domain='plone',
        )
    ),
    atapi.BooleanField('show_title',
        accessor='getShowTitle',
        widget=atapi.BooleanWidget(
            label=_(u'label_show_title', default=u"Show title")),

        default=1),

    atapi.BooleanField('show_description',
        accessor='getShowDescription',
        widget=atapi.BooleanWidget(
            label=_(u'label_show_description', default='Show description')),
        default=1),


))

CollageSchema = CollageSchema + CommonCollageSchema.copy()

# move description to main edit page
Esempio n. 41
0
class CollectionStandardView(BaseView):
    title = _(u'Standard')