--- ECHO_content/ECHO_collection.py 2004/04/14 23:45:58 1.39 +++ ECHO_content/ECHO_collection.py 2004/04/16 15:42:52 1.45 @@ -34,6 +34,7 @@ import xml.dom.minidom import urllib import xml.dom.minidom from ECHO_graphicalOverview import javaHandler,javaScriptMain +import ECHO_helpers #List of different types for the graphical linking viewer viewClassificationListMaster=['view point','area'] @@ -264,6 +265,8 @@ class ECHO_resource(Folder): viewClassificationList=viewClassificationListMaster + getSubCols = ECHO_helpers.getSubCols + def content_html(self): """template fuer content""" return content_html(self,'resource') @@ -522,6 +525,24 @@ class ECHO_collection(Folder, Persistent security=ClassSecurityInfo() meta_type='ECHO_collection' + def createRessourcesFromXMLForm(self): + """form""" + pt=PageTemplateFile('Products/ECHO_content/zpt/createRessourcesFromXMLForm.zpt').__of__(self) + return pt() + def createRessourcesFromXML(self,fileupload): + """read an XML file for generating resources""" + dom=xml.dom.minidom.parse(fileupload) + ret="

Added

" + for resource in dom.getElementsByTagName('resource'): + link=getText(resource.getElementsByTagName('link')[0].childNodes) + label=getText(resource.getElementsByTagName('label')[0].childNodes) + #splitted=link.split("?")[0].split("/") + #id=splitted[len(splitted)-1].encode('ascii') + id=re.sub(" ","_",label).encode('ascii') + + ret+="

"+label+"

" + manage_addECHO_resource(self,id,label,label,"","","",link,"","") + return ret def getImageTag(self): """GetTag""" try: @@ -560,7 +581,7 @@ class ECHO_collection(Folder, Persistent for entry in object.__dict__.keys(): element=getattr(object,entry) try: - if element.meta_type=="ECHO_collection": + if element.meta_type in ["ECHO_collection","ECHO_group"]: collections+="" collections+=getCollection(element,depth)+"\n" except: @@ -664,6 +685,7 @@ class ECHO_collection(Folder, Persistent {'label':'Main Config','action':'ECHO_collection_config'}, {'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, {'label':'Graphics','action':'ECHO_graphicEntry'}, + {'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, ) @@ -739,9 +761,11 @@ class ECHO_collection(Folder, Persistent self.coords=None setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) - - - + try: + self.coords=coordsnew[0:] # HACK fehler in setECHO_collection + except: + """none""" + self.sortfield=sortfield if RESPONSE is not None: @@ -812,39 +836,11 @@ class ECHO_collection(Folder, Persistent return ids - def getSubCols(self,sortfield="weight"): - subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] - ids=[] - for entry in self.__dict__.keys(): - object=getattr(self,entry) - try: - if object.meta_type in subColTypes: - ids.append(object) - - except: - """nothing""" - try: - sortfield=self.sortfield - except: - """nothing""" - - tmplist=[] - for x in ids: - if hasattr(x,sortfield): - try: - x=int(x) - except: - """nothing""" - tmp=getattr(x,sortfield) - else: - tmp=10000000 - tmplist.append((tmp,x)) - tmplist.sort() - return [x for (key,x) in tmplist] + + + getSubCols = ECHO_helpers.getSubCols - - @@ -889,14 +885,15 @@ class ECHO_group(ECHO_collection): pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_group.zpt').__of__(self) return pt() - def changeECHO_group(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour=""): + def changeECHO_group(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): """Änderung der Properties""" self.secondaryLink=secondaryLink self.secondaryLinkTitle=secondaryLinkTitle self.imageTag=imageTag self.bgcolour=bgcolour - + self.logo=logo + if coords: coordsnew=[ string.split(x,",") for x in coords] self.coords=coordsnew[0:] @@ -912,7 +909,14 @@ class ECHO_group(ECHO_collection): if RESPONSE is not None: RESPONSE.redirect('manage_main') - + + def getLogo(self): + """logo ausgeben""" + try: + return self.logo + except: + return "ECHO_groups" + def content_html(self): """template fuer content""" return content_html(self,'group') @@ -925,14 +929,15 @@ def manage_addECHO_groupForm(self): return pt() -def manage_addECHO_group(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): +def manage_addECHO_group(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): """add a echo group""" newObj=ECHO_group(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") + setattr(newObj,'logo',logo) self._setObject(id,newObj) - + if RESPONSE is not None: RESPONSE.redirect('manage_main')