28 help=_('display the component or not')), |
28 help=_('display the component or not')), |
29 } |
29 } |
30 title = _('contentnavigation_breadcrumbs') |
30 title = _('contentnavigation_breadcrumbs') |
31 help = _('contentnavigation_breadcrumbs_description') |
31 help = _('contentnavigation_breadcrumbs_description') |
32 separator = u' > ' |
32 separator = u' > ' |
|
33 link_template = u'<a href="%s">%s</a>' |
33 |
34 |
34 def call(self, view=None, first_separator=True): |
35 def call(self, view=None, first_separator=True): |
35 entity = self.cw_rset.get_entity(0, 0) |
36 entity = self.cw_rset.get_entity(0, 0) |
36 path = entity.breadcrumbs(view) |
37 path = entity.breadcrumbs(view) |
37 if path: |
38 if path: |
38 self.w(u'<span id="breadcrumbs" class="pathbar">') |
39 self.open_breadcrumbs() |
39 if first_separator: |
40 if first_separator: |
40 self.w(self.separator) |
41 self.w(self.separator) |
41 self.render_breadcrumbs(entity, path) |
42 self.render_breadcrumbs(entity, path) |
42 self.w(u'</span>') |
43 self.close_breadcrumbs() |
|
44 |
|
45 def open_breadcrumbs(self): |
|
46 self.w(u'<span id="breadcrumbs" class="pathbar">') |
|
47 |
|
48 def close_breadcrumbs(self): |
|
49 self.w(u'</span>') |
43 |
50 |
44 def render_breadcrumbs(self, contextentity, path): |
51 def render_breadcrumbs(self, contextentity, path): |
45 root = path.pop(0) |
52 root = path.pop(0) |
46 if isinstance(root, Entity): |
53 if isinstance(root, Entity): |
47 self.w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.__regid__), |
54 self.w(self.link_template % (self._cw.build_url(root.__regid__), |
48 root.dc_type('plural'))) |
55 root.dc_type('plural'))) |
49 self.w(self.separator) |
56 self.w(self.separator) |
50 self.wpath_part(root, contextentity, not path) |
57 self.wpath_part(root, contextentity, not path) |
51 for i, parent in enumerate(path): |
58 for i, parent in enumerate(path): |
52 self.w(self.separator) |
59 self.w(self.separator) |
53 self.w(u"\n") |
60 self.w(u"\n") |
60 else: |
67 else: |
61 self.w(part.view('breadcrumbs')) |
68 self.w(part.view('breadcrumbs')) |
62 elif isinstance(part, tuple): |
69 elif isinstance(part, tuple): |
63 url, title = part |
70 url, title = part |
64 textsize = self._cw.property_value('navigation.short-line-size') |
71 textsize = self._cw.property_value('navigation.short-line-size') |
65 self.w(u'<a href="%s">%s</a>' % ( |
72 self.w(self.link_template % ( |
66 xml_escape(url), xml_escape(uilib.cut(title, textsize)))) |
73 xml_escape(url), xml_escape(uilib.cut(title, textsize)))) |
67 else: |
74 else: |
68 textsize = self._cw.property_value('navigation.short-line-size') |
75 textsize = self._cw.property_value('navigation.short-line-size') |
69 self.w(uilib.cut(unicode(part), textsize)) |
76 self.w(uilib.cut(unicode(part), textsize)) |
70 |
77 |