IHM pour définir le tri par défaut. Fonctionne sans js (pour l'instant).
[Portfolio.git] / skins / imagelist.xml.py
1 ## Script (Python) "imagelist.xml"
2 ##bind container=container
3 ##bind context=context
4 ##bind namespace=
5 ##bind script=script
6 ##bind subpath=traverse_subpath
7 ##parameters=all=False, size=600, duration=4
8 ##title=
9 ##
10 from ZTUtils import Batch
11 from ZTUtils import LazyFilter
12 from Products.CMFCore.utils import getToolByName
13 from Products.CMFDefault.utils import toUnicode
14
15 ptool = getToolByName(script, 'portal_properties')
16 stool = getToolByName(script, 'portal_syndication')
17 mtool = getToolByName(script, 'portal_membership')
18
19 req = context.REQUEST
20 req.other['disable_cookie_login__'] = 1
21
22 options = {}
23
24 options['channel_info'] = { 'base': stool.getHTML4UpdateBase(None),
25 'description': context.Description(),
26 'frequency': stool.getUpdateFrequency(None),
27 'period': stool.getUpdatePeriod(None),
28 'title': context.title_or_id(),
29 'url': context.absolute_url(),
30 'author': mtool.getMemberFullNameById(context.Creator(), nameBefore=0),
31 'size': '%s_%s' % (size, size),
32 'duration': duration}
33
34 key, reverse = context.getDefaultSorting()
35 items = stool.getSyndicatableContent(context)
36 items = sequence.sort( items, ((key, 'cmp', reverse and 'desc' or 'asc'),) )
37 items = LazyFilter(items, skip='View')
38 b_size = stool.getMaxItems(None)
39 if all is False:
40 batch_obj = Batch(items, b_size, 0, orphan=0)
41 elif all is True :
42 batch_obj = items
43 else :
44 raise ValueError, "all must be a boolean value."
45 items = []
46 for item in batch_obj:
47 items.append( { 'date': item.modified().rfc822(),
48 'description': item.Description(),
49 'listCreators': item.listCreators(),
50 'listSubjects': item.Subject(),
51 'publisher': item.Publisher(),
52 'rights': item.Rights(),
53 'title': item.title_or_id(),
54 'url': item.absolute_url(),
55 'length': item.get_size(),
56 'image' : '%s/apic' % item.absolute_url() } )
57 options['listItemInfos'] = tuple(items)
58
59 options = toUnicode( options, ptool.getProperty('default_charset', None) )
60 return context.imagelist_template(**options)