87 and view.content_type == self.req.html_content_type()) |
87 and view.content_type == self.req.html_content_type()) |
88 if xhtml_wrap: |
88 if xhtml_wrap: |
89 view.w(u'<?xml version="1.0"?>\n' + STRICT_DOCTYPE) |
89 view.w(u'<?xml version="1.0"?>\n' + STRICT_DOCTYPE) |
90 view.w(u'<div xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">') |
90 view.w(u'<div xmlns="http://www.w3.org/1999/xhtml" xmlns:cubicweb="http://www.logilab.org/2008/cubicweb">') |
91 # have to replace our unicode stream using view's binary stream |
91 # have to replace our unicode stream using view's binary stream |
92 view.dispatch() |
92 view.render() |
93 if xhtml_wrap: |
93 if xhtml_wrap: |
94 view.w(u'</div>') |
94 view.w(u'</div>') |
95 self._stream = view._stream |
95 self._stream = view._stream |
96 |
96 |
97 |
97 |
113 w(u'<h1 class="vtitle">%s</h1>\n' % html_escape(vtitle)) |
113 w(u'<h1 class="vtitle">%s</h1>\n' % html_escape(vtitle)) |
114 # display entity type restriction component |
114 # display entity type restriction component |
115 etypefilter = self.vreg.select_component('etypenavigation', |
115 etypefilter = self.vreg.select_component('etypenavigation', |
116 self.req, self.rset) |
116 self.req, self.rset) |
117 if etypefilter and etypefilter.propval('visible'): |
117 if etypefilter and etypefilter.propval('visible'): |
118 etypefilter.dispatch(w=w) |
118 etypefilter.render(w=w) |
119 self.nav_html = UStringIO() |
119 self.nav_html = UStringIO() |
120 if view and view.need_navigation: |
120 if view and view.need_navigation: |
121 view.paginate(w=self.nav_html.write) |
121 view.paginate(w=self.nav_html.write) |
122 w(_(self.nav_html.getvalue())) |
122 w(_(self.nav_html.getvalue())) |
123 w(u'<div id="contentmain">\n') |
123 w(u'<div id="contentmain">\n') |
124 view.dispatch(w=w) |
124 view.render(w=w) |
125 w(u'</div>\n') # close id=contentmain |
125 w(u'</div>\n') # close id=contentmain |
126 w(_(self.nav_html.getvalue())) |
126 w(_(self.nav_html.getvalue())) |
127 w(u'</div>\n') # closes id=pageContent |
127 w(u'</div>\n') # closes id=pageContent |
128 self.template_footer(view) |
128 self.template_footer(view) |
129 |
129 |
152 w(u'<div id="page"><table width="100%" border="0" id="mainLayout"><tr>\n') |
152 w(u'<div id="page"><table width="100%" border="0" id="mainLayout"><tr>\n') |
153 self.nav_column(view, 'left') |
153 self.nav_column(view, 'left') |
154 w(u'<td id="contentcol">\n') |
154 w(u'<td id="contentcol">\n') |
155 rqlcomp = self.vreg.select_component('rqlinput', self.req, self.rset) |
155 rqlcomp = self.vreg.select_component('rqlinput', self.req, self.rset) |
156 if rqlcomp: |
156 if rqlcomp: |
157 rqlcomp.dispatch(w=self.w, view=view) |
157 rqlcomp.render(w=self.w, view=view) |
158 msgcomp = self.vreg.select_component('applmessages', self.req, self.rset) |
158 msgcomp = self.vreg.select_component('applmessages', self.req, self.rset) |
159 if msgcomp: |
159 if msgcomp: |
160 msgcomp.dispatch(w=self.w) |
160 msgcomp.render(w=self.w) |
161 self.content_header(view) |
161 self.content_header(view) |
162 |
162 |
163 def template_footer(self, view=None): |
163 def template_footer(self, view=None): |
164 self.content_footer(view) |
164 self.content_footer(view) |
165 self.w(u'</td>\n') |
165 self.w(u'</td>\n') |
172 boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, |
172 boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, |
173 view=view, context=context)) |
173 view=view, context=context)) |
174 if boxes: |
174 if boxes: |
175 self.w(u'<td class="navcol"><div class="navboxes">\n') |
175 self.w(u'<td class="navcol"><div class="navboxes">\n') |
176 for box in boxes: |
176 for box in boxes: |
177 box.dispatch(w=self.w, view=view) |
177 box.render(w=self.w, view=view) |
178 self.w(u'</div></td>\n') |
178 self.w(u'</div></td>\n') |
179 |
179 |
180 def content_header(self, view=None): |
180 def content_header(self, view=None): |
181 """by default, display informal messages in content header""" |
181 """by default, display informal messages in content header""" |
182 self.wview('contentheader', rset=self.rset, view=view) |
182 self.wview('contentheader', rset=self.rset, view=view) |
197 self.set_request_content_type() |
197 self.set_request_content_type() |
198 self.req.reset_headers() |
198 self.req.reset_headers() |
199 view = self.vreg.select_view('error', self.req, self.rset) |
199 view = self.vreg.select_view('error', self.req, self.rset) |
200 self.template_header(self.content_type, view, self.req._('an error occured'), |
200 self.template_header(self.content_type, view, self.req._('an error occured'), |
201 [NOINDEX, NOFOLLOW]) |
201 [NOINDEX, NOFOLLOW]) |
202 view.dispatch(w=self.w) |
202 view.render(w=self.w) |
203 self.template_footer(view) |
203 self.template_footer(view) |
204 |
204 |
205 def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
205 def template_header(self, content_type, view=None, page_title='', additional_headers=()): |
206 w = self.whead |
206 w = self.whead |
207 lang = self.req.lang |
207 lang = self.req.lang |
241 boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, |
241 boxes = list(self.vreg.possible_vobjects('boxes', self.req, self.rset, |
242 view=view, context='left')) |
242 view=view, context='left')) |
243 if boxes: |
243 if boxes: |
244 w(u'<div class="navboxes">\n') |
244 w(u'<div class="navboxes">\n') |
245 for box in boxes: |
245 for box in boxes: |
246 box.dispatch(w=w) |
246 box.render(w=w) |
247 self.w(u'</div>\n') |
247 self.w(u'</div>\n') |
248 w(u'</td>') |
248 w(u'</td>') |
249 w(u'<td id="contentcol" rowspan="2">') |
249 w(u'<td id="contentcol" rowspan="2">') |
250 w(u'<div id="pageContent">\n') |
250 w(u'<div id="pageContent">\n') |
251 vtitle = self.req.form.get('vtitle') |
251 vtitle = self.req.form.get('vtitle') |
253 w(u'<h1 class="vtitle">%s</h1>' % html_escape(vtitle)) |
253 w(u'<h1 class="vtitle">%s</h1>' % html_escape(vtitle)) |
254 |
254 |
255 def topleft_header(self): |
255 def topleft_header(self): |
256 self.w(u'<table id="header"><tr>\n') |
256 self.w(u'<table id="header"><tr>\n') |
257 self.w(u'<td>') |
257 self.w(u'<td>') |
258 self.vreg.select_component('logo', self.req, self.rset).dispatch(w=self.w) |
258 self.vreg.select_component('logo', self.req, self.rset).render(w=self.w) |
259 self.w(u'</td>\n') |
259 self.w(u'</td>\n') |
260 self.w(u'</tr></table>\n') |
260 self.w(u'</tr></table>\n') |
261 |
261 |
262 # page parts templates ######################################################## |
262 # page parts templates ######################################################## |
263 |
263 |
320 |
320 |
321 def main_header(self, view): |
321 def main_header(self, view): |
322 """build the top menu with authentification info and the rql box""" |
322 """build the top menu with authentification info and the rql box""" |
323 self.w(u'<table id="header"><tr>\n') |
323 self.w(u'<table id="header"><tr>\n') |
324 self.w(u'<td id="firstcolumn">') |
324 self.w(u'<td id="firstcolumn">') |
325 self.vreg.select_component('logo', self.req, self.rset).dispatch(w=self.w) |
325 self.vreg.select_component('logo', self.req, self.rset).render(w=self.w) |
326 self.w(u'</td>\n') |
326 self.w(u'</td>\n') |
327 # appliname and breadcrumbs |
327 # appliname and breadcrumbs |
328 self.w(u'<td id="headtext">') |
328 self.w(u'<td id="headtext">') |
329 comp = self.vreg.select_component('appliname', self.req, self.rset) |
329 comp = self.vreg.select_component('appliname', self.req, self.rset) |
330 if comp and comp.propval('visible'): |
330 if comp and comp.propval('visible'): |
331 comp.dispatch(w=self.w) |
331 comp.render(w=self.w) |
332 comp = self.vreg.select_component('breadcrumbs', self.req, self.rset, view=view) |
332 comp = self.vreg.select_component('breadcrumbs', self.req, self.rset, view=view) |
333 if comp and comp.propval('visible'): |
333 if comp and comp.propval('visible'): |
334 comp.dispatch(w=self.w, view=view) |
334 comp.render(w=self.w, view=view) |
335 self.w(u'</td>') |
335 self.w(u'</td>') |
336 # logged user and help |
336 # logged user and help |
337 self.w(u'<td>\n') |
337 self.w(u'<td>\n') |
338 comp = self.vreg.select_component('loggeduserlink', self.req, self.rset) |
338 comp = self.vreg.select_component('loggeduserlink', self.req, self.rset) |
339 comp.dispatch(w=self.w) |
339 comp.render(w=self.w) |
340 self.w(u'</td><td>') |
340 self.w(u'</td><td>') |
341 helpcomp = self.vreg.select_component('help', self.req, self.rset) |
341 helpcomp = self.vreg.select_component('help', self.req, self.rset) |
342 if helpcomp: # may not be available if Card is not defined in the schema |
342 if helpcomp: # may not be available if Card is not defined in the schema |
343 helpcomp.dispatch(w=self.w) |
343 helpcomp.render(w=self.w) |
344 self.w(u'</td>') |
344 self.w(u'</td>') |
345 # lastcolumn |
345 # lastcolumn |
346 self.w(u'<td id="lastcolumn">') |
346 self.w(u'<td id="lastcolumn">') |
347 self.w(u'</td>\n') |
347 self.w(u'</td>\n') |
348 self.w(u'</tr></table>\n') |
348 self.w(u'</tr></table>\n') |
397 self.req, self.rset, |
397 self.req, self.rset, |
398 view=view, context='navtop') |
398 view=view, context='navtop') |
399 if components: |
399 if components: |
400 self.w(u'<div id="contentheader">') |
400 self.w(u'<div id="contentheader">') |
401 for comp in components: |
401 for comp in components: |
402 comp.dispatch(w=self.w, view=view) |
402 comp.render(w=self.w, view=view) |
403 self.w(u'</div><div class="clear"></div>') |
403 self.w(u'</div><div class="clear"></div>') |
404 |
404 |
405 |
405 |
406 class HTMLContentFooter(View): |
406 class HTMLContentFooter(View): |
407 """default html page content footer: include selectable content navigation |
407 """default html page content footer: include selectable content navigation |
414 self.req, self.rset, |
414 self.req, self.rset, |
415 view=view, context='navbottom') |
415 view=view, context='navbottom') |
416 if components: |
416 if components: |
417 self.w(u'<div id="contentfooter">') |
417 self.w(u'<div id="contentfooter">') |
418 for comp in components: |
418 for comp in components: |
419 comp.dispatch(w=self.w, view=view) |
419 comp.render(w=self.w, view=view) |
420 self.w(u'</div>') |
420 self.w(u'</div>') |
421 |
421 |
422 |
422 |
423 class LogFormTemplate(View): |
423 class LogFormTemplate(View): |
424 id = 'logform' |
424 id = 'logform' |