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 |
33 |
34 def call(self, view=None, first_separator=True): |
34 def call(self, view=None, first_separator=True): |
35 entity = self.rset.get_entity(0, 0) |
35 entity = self.cw_rset.get_entity(0, 0) |
36 path = entity.breadcrumbs(view) |
36 path = entity.breadcrumbs(view) |
37 if path: |
37 if path: |
38 self.w(u'<span id="breadcrumbs" class="pathbar">') |
38 self.w(u'<span id="breadcrumbs" class="pathbar">') |
39 if first_separator: |
39 if first_separator: |
40 self.w(self.separator) |
40 self.w(self.separator) |
42 self.w(u'</span>') |
42 self.w(u'</span>') |
43 |
43 |
44 def render_breadcrumbs(self, contextentity, path): |
44 def render_breadcrumbs(self, contextentity, path): |
45 root = path.pop(0) |
45 root = path.pop(0) |
46 if isinstance(root, Entity): |
46 if isinstance(root, Entity): |
47 self.w(u'<a href="%s">%s</a>' % (self.req.build_url(root.id), |
47 self.w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.id), |
48 root.dc_type('plural'))) |
48 root.dc_type('plural'))) |
49 self.w(self.separator) |
49 self.w(self.separator) |
50 self.wpath_part(root, contextentity, not path) |
50 self.wpath_part(root, contextentity, not path) |
51 for i, parent in enumerate(path): |
51 for i, parent in enumerate(path): |
52 self.w(self.separator) |
52 self.w(self.separator) |
59 self.w(xml_escape(part.view('breadcrumbtext'))) |
59 self.w(xml_escape(part.view('breadcrumbtext'))) |
60 else: |
60 else: |
61 self.w(part.view('breadcrumbs')) |
61 self.w(part.view('breadcrumbs')) |
62 elif isinstance(part, tuple): |
62 elif isinstance(part, tuple): |
63 url, title = part |
63 url, title = part |
64 textsize = self.req.property_value('navigation.short-line-size') |
64 textsize = self._cw.property_value('navigation.short-line-size') |
65 self.w(u'<a href="%s">%s</a>' % ( |
65 self.w(u'<a href="%s">%s</a>' % ( |
66 xml_escape(url), xml_escape(uilib.cut(title, textsize)))) |
66 xml_escape(url), xml_escape(uilib.cut(title, textsize)))) |
67 else: |
67 else: |
68 textsize = self.req.property_value('navigation.short-line-size') |
68 textsize = self._cw.property_value('navigation.short-line-size') |
69 self.w(uilib.cut(unicode(part), textsize)) |
69 self.w(uilib.cut(unicode(part), textsize)) |
70 |
70 |
71 |
71 |
72 class BreadCrumbETypeVComponent(BreadCrumbEntityVComponent): |
72 class BreadCrumbETypeVComponent(BreadCrumbEntityVComponent): |
73 __select__ = two_lines_rset() & one_etype_rset() & implements(IBreadCrumbs) |
73 __select__ = two_lines_rset() & one_etype_rset() & implements(IBreadCrumbs) |
74 |
74 |
75 def render_breadcrumbs(self, contextentity, path): |
75 def render_breadcrumbs(self, contextentity, path): |
76 # XXX hack: only display etype name or first non entity path part |
76 # XXX hack: only display etype name or first non entity path part |
77 root = path.pop(0) |
77 root = path.pop(0) |
78 if isinstance(root, Entity): |
78 if isinstance(root, Entity): |
79 self.w(u'<a href="%s">%s</a>' % (self.req.build_url(root.id), |
79 self.w(u'<a href="%s">%s</a>' % (self._cw.build_url(root.id), |
80 root.dc_type('plural'))) |
80 root.dc_type('plural'))) |
81 else: |
81 else: |
82 self.wpath_part(root, contextentity, not path) |
82 self.wpath_part(root, contextentity, not path) |
83 |
83 |
84 |
84 |
87 |
87 |
88 def call(self, view=None, first_separator=True): |
88 def call(self, view=None, first_separator=True): |
89 self.w(u'<span id="breadcrumbs" class="pathbar">') |
89 self.w(u'<span id="breadcrumbs" class="pathbar">') |
90 if first_separator: |
90 if first_separator: |
91 self.w(self.separator) |
91 self.w(self.separator) |
92 self.w(self.req._('search')) |
92 self.w(self._cw._('search')) |
93 self.w(u'</span>') |
93 self.w(u'</span>') |
94 |
94 |
95 |
95 |
96 class BreadCrumbView(EntityView): |
96 class BreadCrumbView(EntityView): |
97 __regid__ = 'breadcrumbs' |
97 __regid__ = 'breadcrumbs' |
98 |
98 |
99 def cell_call(self, row, col): |
99 def cell_call(self, row, col): |
100 entity = self.rset.get_entity(row, col) |
100 entity = self.cw_rset.get_entity(row, col) |
101 desc = xml_escape(uilib.cut(entity.dc_description(), 50)) |
101 desc = xml_escape(uilib.cut(entity.dc_description(), 50)) |
102 # XXX remember camember : tags.a autoescapes ! |
102 # XXX remember camember : tags.a autoescapes ! |
103 self.w(tags.a(entity.view('breadcrumbtext'), |
103 self.w(tags.a(entity.view('breadcrumbtext'), |
104 href=entity.absolute_url(), title=desc)) |
104 href=entity.absolute_url(), title=desc)) |
105 |
105 |
106 |
106 |
107 class BreadCrumbTextView(EntityView): |
107 class BreadCrumbTextView(EntityView): |
108 __regid__ = 'breadcrumbtext' |
108 __regid__ = 'breadcrumbtext' |
109 |
109 |
110 def cell_call(self, row, col): |
110 def cell_call(self, row, col): |
111 entity = self.rset.get_entity(row, col) |
111 entity = self.cw_rset.get_entity(row, col) |
112 textsize = self.req.property_value('navigation.short-line-size') |
112 textsize = self._cw.property_value('navigation.short-line-size') |
113 self.w(uilib.cut(entity.dc_title(), textsize)) |
113 self.w(uilib.cut(entity.dc_title(), textsize)) |