equal
deleted
inserted
replaced
23 mt = entity.download_content_type() |
23 mt = entity.download_content_type() |
24 if not (mt and mt.startswith('image/')): |
24 if not (mt and mt.startswith('image/')): |
25 return 0 |
25 return 0 |
26 return 1 |
26 return 1 |
27 |
27 |
28 def download_box(w, entity, title=None, label=None): |
28 def download_box(w, entity, title=None, label=None, footer=u''): |
29 req = entity._cw |
29 req = entity._cw |
30 w(u'<div class="sideBox">') |
30 w(u'<div class="sideBox">') |
31 if title is None: |
31 if title is None: |
32 title = req._('download') |
32 title = req._('download') |
33 w(u'<div class="sideBoxTitle downloadBoxTitle"><span>%s</span></div>' |
33 w(u'<div class="sideBoxTitle downloadBoxTitle"><span>%s</span></div>' |
35 w(u'<div class="sideBox downloadBox"><div class="sideBoxBody">') |
35 w(u'<div class="sideBox downloadBox"><div class="sideBoxBody">') |
36 w(u'<a href="%s"><img src="%s" alt="%s"/> %s</a>' |
36 w(u'<a href="%s"><img src="%s" alt="%s"/> %s</a>' |
37 % (xml_escape(entity.download_url()), |
37 % (xml_escape(entity.download_url()), |
38 req.external_resource('DOWNLOAD_ICON'), |
38 req.external_resource('DOWNLOAD_ICON'), |
39 _('download icon'), xml_escape(label or entity.dc_title()))) |
39 _('download icon'), xml_escape(label or entity.dc_title()))) |
40 w(u'</div>') |
40 w(u'%s</div>' % footer) |
41 w(u'</div>\n</div>\n') |
41 w(u'</div></div>\n') |
42 |
42 |
43 |
43 |
44 class DownloadBox(EntityBoxTemplate): |
44 class DownloadBox(EntityBoxTemplate): |
45 __regid__ = 'download_box' |
45 __regid__ = 'download_box' |
46 # no download box for images |
46 # no download box for images |
111 if ENGINE.has_input(contenttype): |
111 if ENGINE.has_input(contenttype): |
112 self.w(entity.printable_value('data')) |
112 self.w(entity.printable_value('data')) |
113 except TransformError: |
113 except TransformError: |
114 pass |
114 pass |
115 except Exception, ex: |
115 except Exception, ex: |
116 msg = self._cw._("can't display data, unexpected error: %s") % ex |
116 msg = self._cw._("can't display data, unexpected error: %s") \ |
|
117 % xml_escape(str(ex)) |
117 self.w('<div class="error">%s</div>' % msg) |
118 self.w('<div class="error">%s</div>' % msg) |
118 self.w(u'</div>') |
119 self.w(u'</div>') |
119 |
120 |
120 |
121 |
121 class IDownloadableLineView(baseviews.OneLineView): |
122 class IDownloadableLineView(baseviews.OneLineView): |