Diff for /ECHO_content/ECHO_collection.py between versions 1.61 and 1.66

version 1.61, 2004/05/07 13:01:56 version 1.66, 2004/05/07 15:07:22
Line 76  def getText(nodelist): Line 76  def getText(nodelist):
     return rc      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):  def readMetadata(url):
     """Methoden zum Auslesen der Metadateninformation zu einer Resource      """Methoden zum Auslesen der Metadateninformation zu einer Resource
     Vorerst noch Typ bib"""      Vorerst noch Typ bib"""
Line 354  class ECHO_resource(Folder): Line 376  class ECHO_resource(Folder):
         coordsnew=[]              coordsnew=[]    
                   
         setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew)          setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew)
       self.viewClassification=viewClassification
         self.coords=coordsnew[0:]          self.coords=coordsnew[0:]
         self.link=link          self.link=link
         self.metalink=metalink          self.metalink=metalink
Line 655  class ECHO_collection(Folder, Persistent Line 677  class ECHO_collection(Folder, Persistent
           
     def createJavaScript(self):      def createJavaScript(self):
         """CreateJava"""          """CreateJava"""
         ret=javaScriptMain          #ret=javaScriptMain
           ret=""
   
         dynamical=""          dynamical="\n"
         for ob in self.getGraphicCoords():          for ob in self.getGraphicCoords():
         if ob[4][4] == "":            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:          else:
             dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4])              dynamical+="""addArea('%s', 'overview', %s, 'arrow');\n"""%(ob[1],ob[0])
         dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0])          #dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4])
         ret+=javaHandler%dynamical          #dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0])
       #ret+=javaHandler%dynamical
           ret+=dynamical
         return ret          return ret
           
     security.declarePublic('getCreditObject')      security.declarePublic('getCreditObject')
Line 876  class ECHO_collection(Folder, Persistent Line 902  class ECHO_collection(Folder, Persistent
         else:          else:
             return []              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):      def getGraphicCoords(self):
         """Give list of coordinates"""          """Give list of coordinates"""
         subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource']          subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource']
         ids=[]          ids=[]
         for entry in self.__dict__.keys():          for entrySearch in self.ZopeFind(self,obj_metatypes=subcolTypes):
             object=getattr(self,entry)              object=entrySearch[1]
             try:              if hasattr(object,'coords'):
                 if object.meta_type in subColTypes:  
                     for coordtemp in object.coords:                      for coordtemp in object.coords:
                         if len(coordtemp)>3:                          if len(coordtemp)>3:
                             coord=coordtemp[0:4]                              coord=coordtemp[0:4]
                           label=""
                             if hasattr(object,'label') and not object.label=="":                              if hasattr(object,'label') and not object.label=="":
                                 ids.append([string.join(coord,", "),object.getId(),object.label,object,coordtemp])                              label=object.label
                             elif hasattr(object,'title'):                          elif hasattr(object,'title') and not object.title=="":
                                 if not object.title=="":                              label=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:                              else:
                                 ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp])                              label=object.getId()
                                               ids.append([string.join(coord,", "),object.getId(),label,object,coordtemp,object.getViewClassification()])
             except:  
                 """nothing"""  
   
         return ids          return ids
           
   
Line 1056  class ECHO_root(Folder,Persistent,Implic Line 1090  class ECHO_root(Folder,Persistent,Implic
         else:          else:
             retStr="<option>\n"              retStr="<option>\n"
                           
         try:          try: # erste version contentTypes exists
             for contentType in self.ZopeFind(self.contentTypes,obj_metatypes=["ECHO_contentType"]):              for contentType in self.ZopeFind(self.contentTypes,obj_metatypes=["ECHO_contentType"]):
                 if selected and (contentType[0]==selected):                  if selected and (contentType[0]==selected):
                     retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0])                      retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0])
                 else:                                  else:                
                     retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0])                      retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0])
         except:          except:
           try:
               for contentType in self.ZopeFind(self.standardMD,obj_metatypes=["OSAS_MetadataMapping"]):
                   if selected and (contentType[0]==selected):
                       retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0])
                   else:                
                       retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0])
           except:
             """nothing"""              """nothing"""
                   
         return retStr          return retStr
                           
     def patchContentType(self,obj=None):      def patchContentType(self,obj=None):
Line 1085  class ECHO_root(Folder,Persistent,Implic Line 1127  class ECHO_root(Folder,Persistent,Implic
                                   
         return "changed all contenttypes in: "+self.title          return "changed all contenttypes in: "+self.title
           
   
       def patchViewClassification(self,obj=None):
           """setze viewClassification heuristisch"""
   
       def checkIfArrow(obj):
           if hasattr(obj,'coords'):
               for coordtemp in obj.coords:
                   print obj.title,len(coordtemp)
                   if (len(coordtemp)>4) and not (coordtemp[4]==''):
                       return 4
               return None
           return None
       
           if not obj:
               obj = self
               
           entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection','ECHO_group'])
   
           for entry in entries:
           
           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
   
                   if entry[1].meta_type in ['ECHO_collection','ECHO_group']:
                       entry[1].patchViewClassification(entry[1])    
   
                   
           return "changed all contenttypes in: "+self.title
   
     def ECHO_newViewerLink(self,obj=None):      def ECHO_newViewerLink(self,obj=None):
         """change links (:86 faellt weg)"""          """change links (:86 faellt weg)"""
   

Removed from v.1.61  
changed lines
  Added in v.1.66


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>