20 _ = unicode |
20 _ = unicode |
21 |
21 |
22 class EntityVComponent(Component): |
22 class EntityVComponent(Component): |
23 """abstract base class for additinal components displayed in content |
23 """abstract base class for additinal components displayed in content |
24 headers and footer according to: |
24 headers and footer according to: |
25 |
25 |
26 * the displayed entity's type |
26 * the displayed entity's type |
27 * a context (currently 'header' or 'footer') |
27 * a context (currently 'header' or 'footer') |
28 |
28 |
29 it should be configured using .accepts, .etype, .rtype, .target and |
29 it should be configured using .accepts, .etype, .rtype, .target and |
30 .context class attributes |
30 .context class attributes |
31 """ |
31 """ |
32 |
32 |
33 __registry__ = 'contentnavigation' |
33 __registry__ = 'contentnavigation' |
34 __select__ = one_line_rset() & primary_view() & match_context_prop() |
34 __select__ = one_line_rset() & primary_view() & match_context_prop() |
35 registered = accepts_compat(has_relation_compat(condition_compat(View.registered))) |
35 registered = accepts_compat(has_relation_compat(condition_compat(View.registered))) |
36 |
36 |
37 property_defs = { |
37 property_defs = { |
38 _('visible'): dict(type='Boolean', default=True, |
38 _('visible'): dict(type='Boolean', default=True, |
39 help=_('display the box or not')), |
39 help=_('display the box or not')), |
40 _('order'): dict(type='Int', default=99, |
40 _('order'): dict(type='Int', default=99, |
41 help=_('display order of the component')), |
41 help=_('display order of the component')), |
42 _('context'): dict(type='String', default='header', |
42 _('context'): dict(type='String', default='header', |
43 vocabulary=(_('navtop'), _('navbottom'), |
43 vocabulary=(_('navtop'), _('navbottom'), |
44 _('navcontenttop'), _('navcontentbottom')), |
44 _('navcontenttop'), _('navcontentbottom')), |
45 #vocabulary=(_('header'), _('incontext'), _('footer')), |
45 #vocabulary=(_('header'), _('incontext'), _('footer')), |
46 help=_('context where this component should be displayed')), |
46 help=_('context where this component should be displayed')), |
47 _('htmlclass'):dict(type='String', default='mainRelated', |
47 _('htmlclass'):dict(type='String', default='mainRelated', |
48 help=_('html class of the component')), |
48 help=_('html class of the component')), |
49 } |
49 } |
50 |
50 |
51 context = 'navcontentbottom' # 'footer' | 'header' | 'incontext' |
51 context = 'navcontentbottom' # 'footer' | 'header' | 'incontext' |
52 |
52 |
53 def call(self, view=None): |
53 def call(self, view=None): |
54 return self.cell_call(0, 0, view) |
54 return self.cell_call(0, 0, view) |
55 |
55 |
56 def cell_call(self, row, col, view=None): |
56 def cell_call(self, row, col, view=None): |
57 raise NotImplementedError() |
57 raise NotImplementedError() |
58 |
58 |
59 |
59 |
60 class NavigationComponent(Component): |
60 class NavigationComponent(Component): |
61 """abstract base class for navigation components""" |
61 """abstract base class for navigation components""" |
62 id = 'navigation' |
62 id = 'navigation' |
63 __select__ = paginated_rset() |
63 __select__ = paginated_rset() |
64 |
64 |
65 page_size_property = 'navigation.page-size' |
65 page_size_property = 'navigation.page-size' |
66 start_param = '__start' |
66 start_param = '__start' |
67 stop_param = '__stop' |
67 stop_param = '__stop' |
68 page_link_templ = u'<span class="slice"><a href="%s" title="%s">%s</a></span>' |
68 page_link_templ = u'<span class="slice"><a href="%s" title="%s">%s</a></span>' |
69 selected_page_link_templ = u'<span class="selectedSlice"><a href="%s" title="%s">%s</a></span>' |
69 selected_page_link_templ = u'<span class="selectedSlice"><a href="%s" title="%s">%s</a></span>' |
70 previous_page_link_templ = next_page_link_templ = page_link_templ |
70 previous_page_link_templ = next_page_link_templ = page_link_templ |
71 no_previous_page_link = no_next_page_link = u'' |
71 no_previous_page_link = no_next_page_link = u'' |
72 |
72 |
73 def __init__(self, req, rset, **kwargs): |
73 def __init__(self, req, rset, **kwargs): |
74 super(NavigationComponent, self).__init__(req, rset, **kwargs) |
74 super(NavigationComponent, self).__init__(req, rset, **kwargs) |
75 self.starting_from = 0 |
75 self.starting_from = 0 |
76 self.total = rset.rowcount |
76 self.total = rset.rowcount |
77 |
77 |
88 self._page_size = page_size |
88 self._page_size = page_size |
89 return page_size |
89 return page_size |
90 |
90 |
91 def set_page_size(self, page_size): |
91 def set_page_size(self, page_size): |
92 self._page_size = page_size |
92 self._page_size = page_size |
93 |
93 |
94 page_size = property(get_page_size, set_page_size) |
94 page_size = property(get_page_size, set_page_size) |
95 |
95 |
96 def page_boundaries(self): |
96 def page_boundaries(self): |
97 try: |
97 try: |
98 stop = int(self.req.form[self.stop_param]) + 1 |
98 stop = int(self.req.form[self.stop_param]) + 1 |
99 start = int(self.req.form[self.start_param]) |
99 start = int(self.req.form[self.start_param]) |
100 except KeyError: |
100 except KeyError: |
101 start, stop = 0, self.page_size |
101 start, stop = 0, self.page_size |
102 self.starting_from = start |
102 self.starting_from = start |
103 return start, stop |
103 return start, stop |
104 |
104 |
105 def clean_params(self, params): |
105 def clean_params(self, params): |
106 if self.start_param in params: |
106 if self.start_param in params: |
107 del params[self.start_param] |
107 del params[self.start_param] |
108 if self.stop_param in params: |
108 if self.stop_param in params: |
109 del params[self.stop_param] |
109 del params[self.stop_param] |