X-Git-Url: https://svn.cri.ensmp.fr/git/MosaicDocument.git/blobdiff_plain/1aed5a5073041e18e085d5f03b320efa7e9a0f71..4eff9af578856f91276dbd2ab353f9bdb5e190b3:/skins/xml_nav_tree.py?ds=sidebyside diff --git a/skins/xml_nav_tree.py b/skins/xml_nav_tree.py index 30013fb..79c069c 100644 --- a/skins/xml_nav_tree.py +++ b/skins/xml_nav_tree.py @@ -1,5 +1,6 @@ -##parameters=filter='' - +##parameters=root_name='',expansion='',filter='' +from ZTUtils import SimpleTreeMaker +stm = SimpleTreeMaker() def replaceXMLEntities(text) : for c, ent in (('<', '<'), ('>', '>'), ('&', '&')) : text = text.replace(c, ent) @@ -10,16 +11,18 @@ rmBadAttrChars = maketrans('<&"', ' ') filter = filter.split(',') -root = context +childs = list(context.listNearestFolderContents(contentFilter={'portal_type':filter})) +childs.sort(lambda x, y : cmp(y.title_or_id().lower(), x.title_or_id().lower())) + context.REQUEST.RESPONSE.setHeader('content-type', 'text/xml; charset=utf-8') print '' -for ob in context.listNearestFolderContents(contentFilter={'portal_type':filter}) : +for ob in childs : icon = context.restrictedTraverse(ob.getIcon()) state = 0 if not getattr(ob, 'isPortalContent', False) : state = ob.listNearestFolderContents(contentFilter={'portal_type':filter}) and "-1" or "0" - row = '%(title)s' % { - 'id' : ob.getId(), + row = '%(title)s' % { + 'name' : stm.node(ob).id, 'url' : ob.absolute_url(), 'title' : ' '+replaceXMLEntities(ob.title_or_id()), 'description' : ob.Description().translate(rmBadAttrChars), @@ -32,5 +35,5 @@ for ob in context.listNearestFolderContents(contentFilter={'portal_type':filter} print '' - +context.REQUEST.RESPONSE.setCookie('%s-state' % root_name, expansion, path='/') return printed \ No newline at end of file