-##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)
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 '<xml>'
-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 = '<row id="%(id)s" url="%(url)s" icon="%(icon)s" height="%(height)d" width="%(width)d" state="%(state)s" description="%(description)s">%(title)s</row>' % {
- 'id' : ob.getId(),
+ row = '<row name="%(name)s" url="%(url)s" icon="%(icon)s" height="%(height)d" width="%(width)d" state="%(state)s" description="%(description)s">%(title)s</row>' % {
+ 'name' : stm.node(ob).id,
'url' : ob.absolute_url(),
'title' : ' '+replaceXMLEntities(ob.title_or_id()),
'description' : ob.Description().translate(rmBadAttrChars),
print '</xml>'
-
+context.REQUEST.RESPONSE.setCookie('%s-state' % root_name, expansion, path='/')
return printed
\ No newline at end of file