1 | ## Script (Python) "getDisplayParams" |
---|
2 | ##bind container=container |
---|
3 | ##bind context=context |
---|
4 | ##bind namespace= |
---|
5 | ##bind script=script |
---|
6 | ##bind subpath=traverse_subpath |
---|
7 | ##parameters=format=None, sort_by=None, direction=None, columns=None, items_per_page=None, nav_action=None, nb_items=None, filter=None, detail_tab_columns=None |
---|
8 | ##title= |
---|
9 | ## |
---|
10 | # $Id: academicsDisplayParams.py 486 2006-09-06 10:09:39Z joachim $ |
---|
11 | """Return params for display_content macro |
---|
12 | """ |
---|
13 | |
---|
14 | from Products.CPSUtil.session import sessionGet |
---|
15 | |
---|
16 | cps_pref = sessionGet(context.REQUEST, 'cps_display_params', {}) |
---|
17 | def_params = context.getAcademicsDisplayParams() |
---|
18 | |
---|
19 | params = def_params |
---|
20 | |
---|
21 | if format: |
---|
22 | params['format'] = format |
---|
23 | else: |
---|
24 | params['format'] = cps_pref.get('format') or def_params['format'] |
---|
25 | |
---|
26 | if sort_by: |
---|
27 | params['sort_by'] = sort_by |
---|
28 | else: |
---|
29 | params['sort_by'] = cps_pref.get('sort_by') or def_params['sort_by'] |
---|
30 | |
---|
31 | if direction: |
---|
32 | params['direction'] = direction |
---|
33 | else: |
---|
34 | params['direction'] = cps_pref.get('direction') or def_params['direction'] |
---|
35 | |
---|
36 | |
---|
37 | if nav_action: |
---|
38 | params['nav_action'] = nav_action |
---|
39 | |
---|
40 | if columns: |
---|
41 | params['columns'] = columns |
---|
42 | else: |
---|
43 | fmt = params['format'] |
---|
44 | if fmt == 'icon': |
---|
45 | col = 4 |
---|
46 | params['items_per_page'] = 12 |
---|
47 | elif fmt == 'compact': |
---|
48 | col = 2 |
---|
49 | elif fmt == 'detail': |
---|
50 | col = 1 |
---|
51 | elif fmt == 'detail_tab': |
---|
52 | col = 1 |
---|
53 | elif fmt == 'one_column': |
---|
54 | col = 1 |
---|
55 | else: |
---|
56 | col = 1 |
---|
57 | params['columns'] = col |
---|
58 | |
---|
59 | if items_per_page: |
---|
60 | params['items_per_page'] = items_per_page |
---|
61 | params['items_per_page'] = min(nb_items, params['items_per_page']) |
---|
62 | |
---|
63 | if filter is not None: |
---|
64 | params['filter'] = filter |
---|
65 | else: |
---|
66 | params['filter'] = def_params['filter'] |
---|
67 | |
---|
68 | if detail_tab_columns: |
---|
69 | params['detail_tab_columns'] = detail_tab_columns |
---|
70 | else: |
---|
71 | params['detail_tab_columns'] = def_params['detail_tab_columns'] |
---|
72 | |
---|
73 | return params |
---|