1 | ## Script (Python) "changeDisplayParams" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=REQUEST |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: changeDisplayParams.py 486 2006-09-06 10:09:39Z joachim $ |
---|
11 | """ |
---|
12 | Change the order/style of the item display within a folder. |
---|
13 | """ |
---|
14 | from Products.CMFCore.utils import getToolByName |
---|
15 | |
---|
16 | context_url = REQUEST.get('context_url', context.getContextUrl()) |
---|
17 | |
---|
18 | ti = getToolByName(context, 'portal_types').getTypeInfo(context.portal_type) |
---|
19 | |
---|
20 | # Retrieve display preference from session |
---|
21 | display_params = REQUEST.SESSION.get('cps_display_params', {}) |
---|
22 | |
---|
23 | form = REQUEST.form |
---|
24 | |
---|
25 | if form is not None: |
---|
26 | # Order and direction |
---|
27 | display_order = form.get('display_order') |
---|
28 | # "None" means use folder ordering |
---|
29 | if display_order == 'None' or not display_order: |
---|
30 | sort_by = None |
---|
31 | direction = None |
---|
32 | else: |
---|
33 | sort_by, direction = display_order.split('_') |
---|
34 | |
---|
35 | display_params['sort_by'] = sort_by |
---|
36 | display_params['direction'] = direction |
---|
37 | |
---|
38 | # Style |
---|
39 | format = form.get('display_style') |
---|
40 | if format: |
---|
41 | # XXX: |
---|
42 | # "None" means default here whereas None means "don't change" |
---|
43 | if format == 'None': |
---|
44 | format = None |
---|
45 | display_params['format'] = format |
---|
46 | |
---|
47 | # Update session |
---|
48 | REQUEST.SESSION['cps_display_params'] = display_params |
---|
49 | |
---|
50 | meth_id = ti.queryMethodID('view', 'folder_contents') |
---|
51 | redirection_url = context_url + '/' + meth_id |
---|
52 | REQUEST.RESPONSE.redirect(redirection_url) |
---|