1 ##parameters=root_name='',expansion='',filter=''
2 from ZTUtils
import SimpleTreeMaker
3 stm
= SimpleTreeMaker()
4 def replaceXMLEntities(text
) :
5 for c
, ent
in (('<', '<'), ('>', '>'), ('&', '&')) :
6 text
= text
.replace(c
, ent
)
9 from string
import maketrans
10 rmBadAttrChars
= maketrans('<&"', ' ')
12 filter = filter.split(',')
14 childs
= list(context
.listNearestFolderContents(contentFilter
={'portal_type':filter}))
15 childs
.sort(lambda x
, y
: cmp(y
.title_or_id().lower(), x
.title_or_id().lower()))
17 context
.REQUEST
.RESPONSE
.setHeader('content-type', 'text/xml; charset=utf-8')
20 icon
= context
.restrictedTraverse(ob
.getIcon())
22 if not getattr(ob
, 'isPortalContent', False) :
23 state
= ob
.listNearestFolderContents(contentFilter
={'portal_type':filter}) and "-1" or "0"
24 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>' % {
25 'name' : stm
.node(ob
).id,
26 'url' : ob
.absolute_url(),
27 'title' : ' '+replaceXMLEntities(ob
.title_or_id()),
28 'description' : ob
.Description().translate(rmBadAttrChars
),
29 'icon' : icon
.absolute_url(),
30 'height' : icon
.height
,
38 context
.REQUEST
.RESPONSE
.setCookie('%s-state' % root_name
, expansion
, path
='/')