+++ /dev/null
-##parameters=filter=''
-from ZTUtils import SimpleTreeMaker
-stm = SimpleTreeMaker()
-def replaceXMLEntities(text) :
- for c, ent in (('<', '<'), ('>', '>'), ('&', '&')) :
- text = text.replace(c, ent)
- return text
-
-from string import maketrans
-rmBadAttrChars = maketrans('<&"', ' ')
-
-filter = filter.split(',')
-
-root = context
-context.REQUEST.RESPONSE.setHeader('content-type', 'text/xml; charset=utf-8')
-print '<xml>'
-for ob in context.listNearestFolderContents(contentFilter={'portal_type':filter}) :
- 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 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),
- 'icon' : icon.absolute_url(),
- 'height' : icon.height,
- 'width' : icon.width,
- 'state' : state
- }
- print row
-
-
-print '</xml>'
-
-return printed
\ No newline at end of file