def collectionListItem(iter, divClassName = u"thumbDiv", imgClass=u"thumbImage", tagName=u"li"):
    thumbViewScript = u"http://localhost:8803/thumb?path="
    #print iter
    res = ""
    for i in iter:
        res +=u'<%s class="%s">'%(tagName, divClassName+ " ui-widget-content")
        t = tagSys.getTagSysObj()
        tList = t.getTags(i)
        tagStr = u""
        '''
        for k in tList:
            tagStr += k.decode('utf8')
        '''
        tagStr = u','.join(tList)
        '''
        res += '<div class="elementTag" path=%s>'%urllib.quote(i)
        res += ','.join(tList)
        res += 'default'
        res += '</div>'
        '''
        if tagStr == u"":
            tagStr = u"input tag"
        #quote can not support unicode, see http://bugs.python.org/issue1712522
        encoded = urllib.quote(encodingTools.translateToPageEncoding(i))
        res += u'<img class="%s" src="%s%s" path="%s"/><p class="tagEditor">%s</p>'%(imgClass, 
            thumbViewScript, encoded, i, tagStr)#first encode the str, so the browser can decode the string to local encoding
        res +=u'<div class="placeholder"></div>'
        res += u'</%s>\n'%tagName
    return res
Beispiel #2
0
def containerListJson(treeItemToPopulate, start, cnt, isTree = False, req = None, checkedItems = []):
    #print 'list in dirlist:',treeItemToPopulate.listNamedChildren(start, cnt, isTree)
    #en = libs.platform.services.getEncodingService()
    r=[]
    dbSys = req.getDbSys()
    t = tagSys.getTagSysObj(dbSys)
    try:
        d = treeItemToPopulate.listNamedChildren(start, cnt, isTree)
        ncl("list children: ", start, cnt)
        for f in d:
            #print f, r
            itemId = f
            #not needed if jstree support ":"
            itemId = stringTools.jsIdEncoding(f)
            #print 'before get is container'
            encoded = urllib.quote(encodingTools.translateToPageEncoding(f))
            item = {}
            if itemId in checkedItems:
                item["class"] = "jstree-checked"
            else:
                item = {}
            item["attr"] = {"id":itemId}
            item["data"] = d[f]
            item["fullPath"] = f
            item["utf8FullPath"] = encoded
            if treeItemToPopulate.isChildContainer(f):
                #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i))
                item["children"] = []
                item["state"] = "closed"
            if not isTree:
                #print f
                #print 'getting tree --------------------------', f
                try:
                    tList = t.getTags(f)
                except:
                    tList = []
                item["tags"] = tList
            r.append(item)
            #break
    except IOError, e:#Exception,e:
        item = {}
        item["data"] = str(e)
        r.append(item)
Beispiel #3
0
def containerListJson(treeItemToPopulate, start, cnt, isTree = False, req = None, checkedItems = []):
    #print 'list in dirlist:',treeItemToPopulate.listNamedChildren()
    #en = libs.platform.services.getEncodingService()
    r=[]
    try:
        d = treeItemToPopulate.listNamedChildren(start, cnt, isTree)
        for f in d:
            #print f, r
            itemId = f
            #not needed if jstree support ":"
            itemId = stringTools.jsIdEncoding(f)
            ff=treeItemToPopulate.getChildAbsPath(f)
            #print 'before get is container'
            encoded = urllib.quote(encodingTools.translateToPageEncoding(f))
            if itemId in checkedItems:
                item["class"] = "jstree-checked"
            else:
                item = {}
            item["attr"] = {"id":itemId}
            item["data"] = d[f]
            item["fullPath"] = f
            item["utf8FullPath"] = encoded
            if treeItemToPopulate.isContainer(ff):
                #r.append(u'<li id="%s" class="%s">%s</li>' % (itemId,itemClassWithCheckState,i))
                item["children"] = []
                item["state"] = "closed"
            if not isTree:
                t = tagSys.getTagSysObj(req.getDbSys())
                tList = t.getTags(f)
                item["tags"] = tList
            r.append(item)
            #break
    except IOError:#Exception,e:
        r.append(u'<li id="%s" class="jstree-closed">Could not load directory: %s</a></li>' % str(e))
    #print json.dumps(r, indent = 4)
    return json.dumps(r, indent = 4)