Commit 9e19887b authored by Yoshinori Okuji's avatar Yoshinori Okuji

Fix invalid html tags.

Add an id for the domain tree table.
Give a possibility to use ERP5-style accessors in ListBox.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@6998 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent 9d4bbeb9
...@@ -37,7 +37,7 @@ from Products.Formulator.Errors import FormValidationError, ValidationError ...@@ -37,7 +37,7 @@ from Products.Formulator.Errors import FormValidationError, ValidationError
from Products.Formulator.MethodField import BoundMethod from Products.Formulator.MethodField import BoundMethod
from Selection import Selection, DomainSelection from Selection import Selection, DomainSelection
from DateTime import DateTime from DateTime import DateTime
from Products.ERP5Type.Utils import getPath from Products.ERP5Type.Utils import getPath, convertToUpperCase
from Products.ERP5Type.Document import newTempBase from Products.ERP5Type.Document import newTempBase
from Products.CMFCore.utils import getToolByName from Products.CMFCore.utils import getToolByName
from copy import copy from copy import copy
...@@ -152,26 +152,26 @@ def makeTreeBody(form = None, root_dict = None, domain_path = '', ...@@ -152,26 +152,26 @@ def makeTreeBody(form = None, root_dict = None, domain_path = '',
else: else:
oblist = root.objectValues() oblist = root.objectValues()
for o in oblist: for o in oblist:
tree_body += '<TR>' + '<TD WIDTH="16" NOWRAP>' * depth tree_body += '<tr>' + '<td width="16" nowrap>' * depth
relative_url = o.getRelativeUrl() relative_url = o.getRelativeUrl()
if base_category is not None and not relative_url.startswith(base_category + '/'): if base_category is not None and not relative_url.startswith(base_category + '/'):
url = '%s/%s' % (base_category, relative_url) url = '%s/%s' % (base_category, relative_url)
else: else:
url = relative_url url = relative_url
if url in unfolded_list: if url in unfolded_list:
tree_body += """<TD NOWRAP VALIGN="TOP" ALIGN="LEFT" COLSPAN="%s"> tree_body += """<td nowrap valign="top" align="left" colspan="%s">
<a href="portal_selections/foldDomain?domain_url=%s&form_id=%s&list_selection_name=%s&domain_depth:int=%s" title="%s" >- <b>%s</b></a> <a href="portal_selections/foldDomain?domain_url=%s&form_id=%s&list_selection_name=%s&domain_depth:int=%s" title="%s" >- <b>%s</b></a>
</TD>""" % (total_depth - depth + 1, url, form_id, selection_name, depth, unicode(o.getTranslatedTitle(), 'utf8'), o.id) </td>""" % (total_depth - depth + 1, url, form_id, selection_name, depth, unicode(o.getTranslatedTitle(), 'utf8'), o.id)
new_root_dict = root_dict.copy() new_root_dict = root_dict.copy()
new_root_dict[None] = new_root_dict[base_category] = o new_root_dict[None] = new_root_dict[base_category] = o
tree_body += makeTreeBody(form = form, root_dict = new_root_dict, domain_path = domain_path, tree_body += makeTreeBody(form = form, root_dict = new_root_dict, domain_path = domain_path,
depth = depth + 1, total_depth = total_depth, unfolded_list = unfolded_list, depth = depth + 1, total_depth = total_depth, unfolded_list = unfolded_list,
selection_name = selection_name, base_category = base_category) selection_name = selection_name, base_category = base_category)
else: else:
tree_body += """<TD NOWRAP VALIGN="TOP" ALIGN="LEFT" COLSPAN="%s"> tree_body += """<td nowrap valign="top" align="left" colspan="%s">
<a href="portal_selections/unfoldDomain?domain_url=%s&form_id=%s&list_selection_name=%s&domain_depth:int=%s" title="%s">+ %s</a> <a href="portal_selections/unfoldDomain?domain_url=%s&form_id=%s&list_selection_name=%s&domain_depth:int=%s" title="%s">+ %s</a>
</TD>""" % (total_depth - depth + 1, url, form_id, selection_name, depth, unicode(o.getTranslatedTitle(), 'utf8'), o.id) </td>""" % (total_depth - depth + 1, url, form_id, selection_name, depth, unicode(o.getTranslatedTitle(), 'utf8'), o.id)
#tree_body += '</TD>' * depth + '</TR>' tree_body += '</td>' * depth + '</tr>'
return tree_body return tree_body
...@@ -2026,20 +2026,20 @@ onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')"> ...@@ -2026,20 +2026,20 @@ onChange="submitAction(this.form,'%s/portal_selections/setDomainRoot')">
select_tree_body = '' select_tree_body = ''
select_tree_html = """<!-- Select Tree --> select_tree_html = """<!-- Select Tree -->
%s %s
<table cellpadding="0" border="0"> <table id="%s_domain_tree_table" cellpadding="0" border="0">
%s %s
</table> </table>
""" % (select_tree_header, select_tree_body ) """ % (select_tree_header, field.id, select_tree_body )
return """<!-- Table Wrapping for Select Tree --> return """<!-- Table Wrapping for Select Tree -->
<table border="0" cellpadding="0" cellspacing="0" width="100%"> <table border="0" cellpadding="0" cellspacing="0" width="100%%">
<tr><td valign="top">""" + """ <tr><td valign="top">
%s %s
</td><td valign="top"> </td><td valign="top">
%s %s
<!-- End of Table Wrapping for Select Tree --> <!-- End of Table Wrapping for Select Tree -->
</td></tr> </td></tr>
</table>""" % (select_tree_html,list_html) </table>""" % (select_tree_html, list_html)
#render_end = DateTime() #render_end = DateTime()
#result = (render_end-render_start) * 86400 #result = (render_end-render_start) * 86400
#LOG('Listbox render end call', 0, result) #LOG('Listbox render end call', 0, result)
...@@ -2235,7 +2235,13 @@ class ListBox(ZMIField): ...@@ -2235,7 +2235,13 @@ class ListBox(ZMIField):
if id == 'default' and kw.get('render_format') in ('list', ): if id == 'default' and kw.get('render_format') in ('list', ):
return self.widget.render(self, self.generate_field_key() , None , kw.get('REQUEST'), render_format=kw.get('render_format')) return self.widget.render(self, self.generate_field_key() , None , kw.get('REQUEST'), render_format=kw.get('render_format'))
else: else:
return ZMIField.get_value(self, id, **kw) # Try an ERP5-style accessor, if available.
method_id = 'get' + convertToUpperCase(id)
method = getattr(self.widget, method_id, None)
if method is not None:
return method(**kw)
else:
return ZMIField.get_value(self, id, **kw)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment