--- ECHO_content/ECHO_collection.py 2004/05/07 14:34:07 1.63 +++ ECHO_content/ECHO_collection.py 2004/05/07 16:52:04 1.69 @@ -76,6 +76,28 @@ def getText(nodelist): return rc +def sendFile(self, filename, type): + """sends an object or a local file (in the product) as response""" + paths = filename.split('/') + object = self + # look for an object called filename + for path in paths: + if hasattr(object, path): + object = getattr(object, path) + else: + object = None + break + if object: + # if the object exists then send it + object() + else: + # send a local file with the given content-type + fn = os.path.join(package_home(globals()), filename) + self.REQUEST.RESPONSE.setHeader("Content-Type", type) + self.REQUEST.RESPONSE.write(file(fn).read()) + return + + def readMetadata(url): """Methoden zum Auslesen der Metadateninformation zu einer Resource Vorerst noch Typ bib""" @@ -576,9 +598,15 @@ class ECHO_collection(Folder, Persistent """ECHO Collection""" security=ClassSecurityInfo() meta_type='ECHO_collection' - + viewClassificationList=viewClassificationListMaster displayTypes=displayTypes - + + def getViewClassification(self): + if hasattr(self,'viewClassification'): + return self.viewClassification + else: + return "" + def getTitle(self): """title""" return self.title.encode('utf-8') @@ -655,16 +683,20 @@ class ECHO_collection(Folder, Persistent def createJavaScript(self): """CreateJava""" - ret=javaScriptMain + #ret=javaScriptMain + ret="" - dynamical="" + dynamical="\n" for ob in self.getGraphicCoords(): if ob[4][4] == "": - dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) + #dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) + dynamical+="""addArea('%s', 'overview', %s, 'area');\n"""%(ob[1],ob[0]) else: - dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4]) - dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0]) - ret+=javaHandler%dynamical + dynamical+="""addArea('%s', 'overview', %s, 'arrow');\n"""%(ob[1],ob[0]) + #dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4]) + #dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0]) + #ret+=javaHandler%dynamical + ret+=dynamical return ret security.declarePublic('getCreditObject') @@ -811,13 +843,14 @@ class ECHO_collection(Folder, Persistent else: return "#dddddd" - def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour=""): + def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None): """Änderung der Properties""" self.secondaryLink=secondaryLink self.secondaryLinkTitle=secondaryLinkTitle self.imageTag=imageTag self.bgcolour=bgcolour + self.viewClassification=viewClassification if coords: coordsnew=[ string.split(x,",") for x in coords] @@ -876,32 +909,40 @@ class ECHO_collection(Folder, Persistent else: return [] + def area_img(self): + """area image""" + sendFile(self, 'images/red.gif', 'image/gif') + return + + def hl_lib_js(self): + """javascript""" + sendFile(self, 'js/hl_lib.js', 'text/plain') + return + + def js_lib_js(self): + """javascript""" + sendFile(self, 'js/js_lib.js', 'text/plain') + return def getGraphicCoords(self): """Give list of coordinates""" - subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] + subColTypes=['ECHO_collection','ECHO_resource'] ids=[] - for entry in self.__dict__.keys(): - object=getattr(self,entry) - try: - if object.meta_type in subColTypes: - for coordtemp in object.coords: - if len(coordtemp)>3: - coord=coordtemp[0:4] - if hasattr(object,'label') and not object.label=="": - ids.append([string.join(coord,", "),object.getId(),object.label,object,coordtemp]) - elif hasattr(object,'title'): - if not object.title=="": - ids.append([string.join(coord,", "),object.getId(),object.title,object,coordtemp]) - else: - ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp]) - else: - ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp]) - - except: - """nothing""" - + for entrySearch in self.ZopeFind(self,obj_metatypes=subColTypes): + object=entrySearch[1] + if hasattr(object,'coords'): + for coordtemp in object.coords: + if len(coordtemp)>3: + coord=coordtemp[0:4] + label="" + if hasattr(object,'label') and not object.label=="": + label=object.label + elif hasattr(object,'title') and not object.title=="": + label=object.title + else: + label=object.getId() + ids.append([string.join(coord,", "),object.getId(),label,object,coordtemp,object.viewClassification]) return ids @@ -1100,7 +1141,8 @@ class ECHO_root(Folder,Persistent,Implic def checkIfArrow(obj): if hasattr(obj,'coords'): for coordtemp in obj.coords: - if len(coordtemp)>3: + print obj.title,len(coordtemp) + if (len(coordtemp)>4) and not (coordtemp[4]==''): return 4 return None return None @@ -1112,9 +1154,11 @@ class ECHO_root(Folder,Persistent,Implic for entry in entries: - if checkIfArrow(entry[1]): + if checkIfArrow(entry[1]): + print "VP" setattr(entry[1],'viewClassification','view point') else: + print "area" setattr(entry[1],'viewClassification','area') #entry[1].contentType == entry[1].content_type