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)
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]
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]
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'])
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
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'])
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'])
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'])
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'])
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()
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()
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'])
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'])
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()
class LargeRightRowView(RowView): title = _(u'Large right')
class LargeLeftRowView(RowView): title = _(u'Large left')
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',
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
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)
class CollectionSummaryView(BaseView): title = _(u'Summary')
class PortletDefaultSkin(object): title = _(u"default", default=u"Default")
class FeaturedView(BaseView): title = _(u'Featured')
class TextView(BaseView): title = _(u'Text')
class TabularTopicView(BaseTopicView): title = _(u'Tabular')
class SummaryTopicView(BaseTopicView): title = _(u'Summary')
class StandardTopicView(BaseTopicView): title = _(u'Standard')
class AutomaticRowView(RowView): title = _(u'Automatic')
class ClickableView(BaseView): title = _(u'Clickable')
class PortletNotificationSkin(object): title = _(u"notification_skin", default=u"Notification")
class StandardView(BaseView): title = _(u'Standard')
class PortletHelpSkin(object): title = _(u"help_skin", default=u"Help")
class UnbatchedRowView(RowView): title = _(u'Unbatched')
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)
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):
( 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,
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)
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
class CollectionStandardView(BaseView): title = _(u'Standard')