def begin_foldable_container(self, treename, id, isopen, title, indent = True, first = False): self.folding_indent = indent # try to get persisted state of tree tree_state = weblib.get_tree_states(treename) if id in tree_state: isopen = tree_state[id] == "on" img_num = isopen and "90" or "00" onclick = ' onclick="toggle_foldable_container(\'%s\', \'%s\')"' % (treename, id) onclick += ' onmouseover="this.style.cursor=\'pointer\';" ' onclick += ' onmouseout="this.style.cursor=\'auto\';" ' if indent == "nform": self.write('<tr class=heading><td id="nform.%s.%s" %s colspan=2>' % (treename, id, onclick)) self.write('%s</td></tr>' % title) else: self.write('<img align=absbottom class="treeangle" id="treeimg.%s.%s" ' 'src="images/tree_%s.png" %s>' % (treename, id, img_num, onclick)) if title.startswith('<'): # custom HTML code self.write(title) if indent != "form": self.write("<br>") else: self.write('<b class="treeangle title" class=treeangle %s>%s</b><br>' % (onclick, title)) indent_style = "padding-left: %dpx; " % (indent == True and 15 or 0) if indent == "form": self.write("</td></tr></table>") indent_style += "margin: 0; " self.write('<ul class="treeangle %s" style="%s" id="tree.%s.%s">' % (isopen and "open" or "closed", indent_style, treename, id)) # give caller information about current toggling state (needed for nform) return isopen
def render_list(ids, links): states = weblib.get_tree_states('customlinks') n = 0 for entry in links: n += 1 try: if type(entry[1]) == type(True): idss = ids + [str(n)] is_open = entry[1] id = '/'.join(idss) html.begin_foldable_container("customlinks", id, isopen=entry[1], title=entry[0]) render_list(idss, entry[2]) html.end_foldable_container() elif type(entry[1]) == str: frame = len(entry) > 3 and entry[3] or "main" if len(entry) > 2 and entry[2]: html.write('<img src="images/%s">' % entry[2]) else: html.write('<img src="images/link_link.gif">') simplelink(entry[0], entry[1], frame) else: html.write(_("Second part of tuple must be list or string, not %s\n") % str(entry[1])) except Exception, e: html.write(_("invalid entry %s: %s<br>\n") % (entry, e))