diff --git a/CHANGES.rst b/CHANGES.rst index cab0cfe..26ab697 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -10,7 +10,7 @@ Breaking changes: New features: -- *add item here* +- option to override thumb /icon behavior individually for portlet (suppress thumbs, thumb size, suppress icons) https://github.com/plone/Products.CMFPlone/issues/1734 (PLIP) [fgrcon] Bug fixes: diff --git a/plone/portlet/collection/collection.pt b/plone/portlet/collection/collection.pt index 42d29f8..d5ec26e 100644 --- a/plone/portlet/collection/collection.pt +++ b/plone/portlet/collection/collection.pt @@ -23,15 +23,17 @@ item_wf_state obj/review_state; item_wf_state_class python:'state-' + plone_view.normalizeString(item_wf_state); item_type obj/portal_type; - item_type_class python:'contenttype-' + plone_view.normalizeString(item_type);" + supress_icon view/data/no_icons; + supress_thumb view/data/no_thumbs; + item_type_class python:('contenttype-' + plone_view.normalizeString(item_type)) if not supress_icon else ''" tal:attributes="class python:oddrow and 'portletItem even' or 'portletItem odd'"> diff --git a/plone/portlet/collection/collection.py b/plone/portlet/collection/collection.py index 78813ff..6e5a8ef 100644 --- a/plone/portlet/collection/collection.py +++ b/plone/portlet/collection/collection.py @@ -8,7 +8,9 @@ from plone.memoize.instance import memoize from plone.portlet.collection import PloneMessageFactory as _ from plone.portlets.interfaces import IPortletDataProvider +from plone.registry.interfaces import IRegistry from Products.CMFCore.utils import getToolByName +from Products.CMFPlone.interfaces.controlpanel import ISiteSchema from Products.Five.browser.pagetemplatefile import ViewPageTemplateFile from zExceptions import NotFound from zope import schema @@ -83,6 +85,27 @@ class ICollectionPortlet(IPortletDataProvider): required=True, default=True) + no_icons = schema.Bool( + title=_(u"Suppress Icons "), + description=_( + u"If enabled, the portlet will not show document type icons"), + required=True, + default=False) + + ov_thumbsize = schema.TextLine( + title=_(u"Override thumb size "), + description=_(u"
"), + required=False, + default=u'') + + no_thumbs = schema.Bool( + title=_(u"Suppress thumbs "), + description=_( + u"If enabled, the portlet will not show thumbs"), + required=True, + default=False) @implementer(ICollectionPortlet) class Assignment(base.Assignment): @@ -91,20 +114,22 @@ class Assignment(base.Assignment): This is what is actually managed through the portlets UI and associated with columns. """ - header = u"" limit = None random = False show_more = True show_dates = False exclude_context = False - + no_icons = False + no_thumbs = False + ov_thumbsize = '' # bbb target_collection = None def __init__(self, header=u"", uid=None, limit=None, random=False, show_more=True, show_dates=False, - exclude_context=True): + exclude_context=True, no_icons = False, no_thumbs = False, + ov_thumbsize = ''): self.header = header self.uid = uid self.limit = limit @@ -112,6 +137,9 @@ def __init__(self, header=u"", uid=None, limit=None, self.show_more = show_more self.show_dates = show_dates self.exclude_context = exclude_context + self.no_icons = no_icons + self.no_thumbs = no_thumbs + self.ov_thumbsize = ov_thumbsize @property def title(self): @@ -135,7 +163,6 @@ def _uid(self): class Renderer(base.Renderer): - _template = ViewPageTemplateFile('collection.pt') render = _template @@ -224,6 +251,21 @@ def include_empty_footer(self): """ return True + @memoize + def thumb_size(self): + ''' use overrride value or read thumb_size from registry + image sizes must fit to value in allowed image sizes + none will suppress thumb! + ''' + if self.data.ov_thumbsize > ' ': + return self.data.ov_thumbsize + registry = getUtility(IRegistry) + settings = registry.forInterface( + ISiteSchema, prefix="plone", check=False) + if settings.no_thumbs_portlet: + return 'none' + thumb_size_portlet = settings.thumb_size_portlet + return thumb_size_portlet class AddForm(formhelper.AddForm): schema = ICollectionPortlet