7 """ |
7 """ |
8 __docformat__ = "restructuredtext en" |
8 __docformat__ = "restructuredtext en" |
9 |
9 |
10 from simplejson import dumps |
10 from simplejson import dumps |
11 |
11 |
12 from logilab.mtconverter import html_escape |
12 from logilab.mtconverter import xml_escape |
13 |
13 |
14 from cubicweb.vregistry import objectify_selector |
14 from cubicweb.vregistry import objectify_selector |
15 from cubicweb.selectors import (non_final_entity, two_lines_rset, |
15 from cubicweb.selectors import (non_final_entity, two_lines_rset, |
16 match_context_prop, yes, relation_possible) |
16 match_context_prop, yes, relation_possible) |
17 from cubicweb.web.box import BoxTemplate |
17 from cubicweb.web.box import BoxTemplate |
83 if not widgets: |
83 if not widgets: |
84 return |
84 return |
85 self.displayBookmarkLink(rset) |
85 self.displayBookmarkLink(rset) |
86 w = self.w |
86 w = self.w |
87 w(u'<form method="post" id="%sForm" cubicweb:facetargs="%s" action="">' % ( |
87 w(u'<form method="post" id="%sForm" cubicweb:facetargs="%s" action="">' % ( |
88 divid, html_escape(dumps([divid, vid, paginate, self.facetargs()])))) |
88 divid, xml_escape(dumps([divid, vid, paginate, self.facetargs()])))) |
89 w(u'<fieldset>') |
89 w(u'<fieldset>') |
90 hiddens = {'facets': ','.join(wdg.facet.id for wdg in widgets), |
90 hiddens = {'facets': ','.join(wdg.facet.id for wdg in widgets), |
91 'baserql': baserql} |
91 'baserql': baserql} |
92 for param in ('subvid', 'vtitle'): |
92 for param in ('subvid', 'vtitle'): |
93 if param in req.form: |
93 if param in req.form: |
108 bk_title = self.req._('my custom search') |
108 bk_title = self.req._('my custom search') |
109 linkto = 'bookmarked_by:%s:subject' % self.req.user.eid |
109 linkto = 'bookmarked_by:%s:subject' % self.req.user.eid |
110 bk_add_url = self.build_url('add/Bookmark', path=bk_path, title=bk_title, __linkto=linkto) |
110 bk_add_url = self.build_url('add/Bookmark', path=bk_path, title=bk_title, __linkto=linkto) |
111 bk_base_url = self.build_url('add/Bookmark', title=bk_title, __linkto=linkto) |
111 bk_base_url = self.build_url('add/Bookmark', title=bk_title, __linkto=linkto) |
112 bk_link = u'<a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a>' % ( |
112 bk_link = u'<a cubicweb:target="%s" id="facetBkLink" href="%s">%s</a>' % ( |
113 html_escape(bk_base_url), |
113 xml_escape(bk_base_url), |
114 html_escape(bk_add_url), |
114 xml_escape(bk_add_url), |
115 self.req._('bookmark this search')) |
115 self.req._('bookmark this search')) |
116 self.w(self.bkLinkBox_template % bk_link) |
116 self.w(self.bkLinkBox_template % bk_link) |
117 |
117 |
118 def get_facets(self, rset, mainvar): |
118 def get_facets(self, rset, mainvar): |
119 return self.vreg.possible_vobjects('facets', self.req, rset, |
119 return self.vreg.possible_vobjects('facets', self.req, rset, |