source: WAeUP_SRP/trunk/skins/waeup_academics/academicsDisplayParams.py @ 8794

Last change on this file since 8794 was 486, checked in by joachim, 18 years ago

svn -R propset svn:keywords "Id" .
added layout_application_/edit/create/view
and cleaned that up.

  • Property svn:keywords set to Id
File size: 1.8 KB
Line 
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
14from Products.CPSUtil.session import sessionGet
15
16cps_pref = sessionGet(context.REQUEST, 'cps_display_params', {})
17def_params = context.getAcademicsDisplayParams()
18
19params = def_params
20
21if format:
22    params['format'] = format
23else:
24    params['format'] = cps_pref.get('format') or def_params['format']
25
26if sort_by:
27    params['sort_by'] = sort_by
28else:
29    params['sort_by'] = cps_pref.get('sort_by') or def_params['sort_by']
30
31if direction:
32    params['direction'] = direction
33else:
34    params['direction'] = cps_pref.get('direction') or def_params['direction']
35
36
37if nav_action:
38    params['nav_action'] = nav_action
39
40if columns:
41    params['columns'] = columns
42else:
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
59if items_per_page:
60    params['items_per_page'] = items_per_page
61params['items_per_page'] = min(nb_items, params['items_per_page'])
62
63if filter is not None:
64    params['filter'] = filter
65else:
66    params['filter'] = def_params['filter']
67
68if detail_tab_columns:
69    params['detail_tab_columns'] = detail_tab_columns
70else:
71    params['detail_tab_columns'] = def_params['detail_tab_columns']
72
73return params
Note: See TracBrowser for help on using the repository browser.