Diff for /ECHO_content/ECHO_collection.py between versions 1.13 and 1.23

version 1.13, 2004/02/09 11:45:46 version 1.23, 2004/03/30 19:12:22
Line 10  class ECHO_externalLink contains informa Line 10  class ECHO_externalLink contains informa
   
 """  """
 import string  import string
   import re
 import OFS.Image  import OFS.Image
 from types import *  from types import *
 from OFS.Image import Image  from OFS.Image import Image
Line 23  from Products.PageTemplates.PageTemplate Line 24  from Products.PageTemplates.PageTemplate
 from Products.PageTemplates.PageTemplate import PageTemplate  from Products.PageTemplates.PageTemplate import PageTemplate
 from Globals import Persistent  from Globals import Persistent
 from Acquisition import Implicit  from Acquisition import Implicit
 from pyPgSQL import libpq  #from psycopg import libpq
   #from pyPgSQL import libpq
   import xml.dom.minidom
   
 import urllib  import urllib
 import xml.dom.minidom  import xml.dom.minidom
   from ECHO_graphicalOverview import javaHandler,javaScriptMain
   
 #List of different types for the graphical linking viewer  #List of different types for the graphical linking viewer
 viewClassificationListMaster=['view point','area']  viewClassificationListMaster=['view point','area']
Line 228  class ECHO_resource(Folder): Line 231  class ECHO_resource(Folder):
         if not hasattr(self,'coords'):          if not hasattr(self,'coords'):
             self.coords=[]              self.coords=[]
   
           print "vorher",self.coords
         pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self)          pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self)
         return pt()          return pt()
           
   
     def changeECHO_resource(self,metalink,link,title,label,description,content_type,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):      def changeECHO_resource(self,metalink,link,title,label,description,content_type,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):
   
   
         """Änderung der Properties"""          """Änderung der Properties"""
                   
   
         setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords,viewClassification)          coordsnew=[ string.split(x,",") for x in coords]
   
                   
           setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coordsnew)
   
           self.coords=coordsnew[0:]
         self.link=link          self.link=link
         self.metalink=metalink          self.metalink=metalink
                   
Line 254  class ECHO_resource(Folder): Line 259  class ECHO_resource(Folder):
         {'label':'Graphics','action':'ECHO_graphicEntry'},          {'label':'Graphics','action':'ECHO_graphicEntry'},
         )          )
   
       def getOverview(self):
           """overview graphics"""
           
           return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1]
   
     def ECHO_graphicEntry(self):      def ECHO_graphicEntry(self):
         """DO nothing"""          """DO nothing"""
         if 'overview' in self.aq_parent.__dict__.keys():          overview = self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])
           if overview: 
             pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)              pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)
             return pt()              return pt()
         else:          else:
Line 367  class ECHO_externalLink(Folder): Line 378  class ECHO_externalLink(Folder):
     def changeECHO_externalLink(self,link,title,label,description,content_type,responsible,weight,coords=None,credits=None,RESPONSE=None):      def changeECHO_externalLink(self,link,title,label,description,content_type,responsible,weight,coords=None,credits=None,RESPONSE=None):
   
         """Änderung der Properties"""          """Änderung der Properties"""
                   coordsnew=[ string.split(x,",") for x in coords]
   
         setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords)          setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords)
   
                   self.coords=coordsnew[0:]
         self.link=link          self.link=link
         if RESPONSE is not None:          if RESPONSE is not None:
             RESPONSE.redirect('manage_main')              RESPONSE.redirect('manage_main')
Line 381  class ECHO_externalLink(Folder): Line 392  class ECHO_externalLink(Folder):
         {'label':'Main Config','action':'ECHO_externalLink_config'},          {'label':'Main Config','action':'ECHO_externalLink_config'},
         )          )
           
       def getCredits(self):
           """Ausgabe der credits"""
           if self.credits:
               return self.credits
           else:
               return []
           
     def index_html(self):      def index_html(self):
         """standard page"""          """standard page"""
                   
Line 408  class ECHO_collection(Folder, Persistent Line 426  class ECHO_collection(Folder, Persistent
     security=ClassSecurityInfo()      security=ClassSecurityInfo()
     meta_type='ECHO_collection'      meta_type='ECHO_collection'
   
       def createJavaScript(self):
           """CreateJava"""
           ret=javaScriptMain
   
           dynamical=""
           for ob in self.getGraphicCoords():
               dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0])
           ret+=javaHandler%dynamical
           return ret
           
     security.declarePublic('getCreditObject')      security.declarePublic('getCreditObject')
     def getCreditObject(self,name):      def getCreditObject(self,name):
         """credit id to credititem"""          """credit id to credititem"""
           try:
         return getattr(self.partners,name)          return getattr(self.partners,name)
           except:
               return ""
           
     security.declarePublic('ECHO_generateNavBar')      security.declarePublic('ECHO_generateNavBar')
     def ECHO_generateNavBar(self):      def ECHO_generateNavBar(self):
Line 453  class ECHO_collection(Folder, Persistent Line 482  class ECHO_collection(Folder, Persistent
                                   
         return "Rerenderd all links to resources in: "+self.title          return "Rerenderd all links to resources in: "+self.title
           
       security.declarePublic('ECHO_newViewerLink')
       
   
     def getCoords(self):      def getCoords(self):
         try:          try:
Line 489  class ECHO_collection(Folder, Persistent Line 520  class ECHO_collection(Folder, Persistent
   
         )          )
   
       def getOverview(self):
           """overview graphics"""
           
           return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1]
       
       
     def ECHO_graphicEntry(self):      def ECHO_graphicEntry(self):
         """DO nothing"""          """DO nothing"""
         if 'overview' in self.aq_parent.__dict__.keys():          overview = self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])
           
       
           if overview:
             pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)              pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)
             return pt()              return pt()
         else:          else:
Line 532  class ECHO_collection(Folder, Persistent Line 572  class ECHO_collection(Folder, Persistent
     def changeECHO_collection(self,title,label,description,content_type,responsible,weight,credits=None,sortfield="weight",coords=None,RESPONSE=None):      def changeECHO_collection(self,title,label,description,content_type,responsible,weight,credits=None,sortfield="weight",coords=None,RESPONSE=None):
         """Änderung der Properties"""          """Änderung der Properties"""
   
           
         coordsnew=[ string.split(x,",") for x in coords]          coordsnew=[ string.split(x,",") for x in coords]
   
         setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coordsnew)          setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coordsnew)
   
           self.coords=coordsnew[0:]
         self.sortfield=sortfield          self.sortfield=sortfield
   
         if RESPONSE is not None:          if RESPONSE is not None:
Line 543  class ECHO_collection(Folder, Persistent Line 585  class ECHO_collection(Folder, Persistent
                           
     security.declarePublic('index_html')      security.declarePublic('index_html')
   
     showOverview=DTMLFile('ECHO_content_overview',globals())  
       def showOverview(self):
           """overview"""
           if 'ECHO_overview.html' in self.__dict__.keys():
               return getattr(self,'ECHO_overview.html')()
           pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_overview.zpt').__of__(self)
           return pt()
           
           
     def index_html(self):      def index_html(self):
Line 566  class ECHO_collection(Folder, Persistent Line 614  class ECHO_collection(Folder, Persistent
         else:          else:
             return []              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']
Line 577  class ECHO_collection(Folder, Persistent Line 627  class ECHO_collection(Folder, Persistent
                     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]
                             if hasattr(object,'title'):                              if hasattr(object,'label') and not object.label=="":
                                   ids.append([string.join(coord,", "),object.getId(),object.label,object])
                               elif hasattr(object,'title'):
                                 if not object.title=="":                                  if not object.title=="":
                                     ids.append([string.join(coord,", "),object.getId(),object.title])                                      ids.append([string.join(coord,", "),object.getId(),object.title,object])
                                 else:                                  else:
                                     ids.append([string.join(coord,", "),object.getId(),object.getId()])                                      ids.append([string.join(coord,", "),object.getId(),object.getId(),object])
                             else:                              else:
                                 ids.append([string.join(coord,", "),object.getId(),object.getId()])                                  ids.append([string.join(coord,", "),object.getId(),object.getId(),object])
                                           
             except:              except:
                 """nothing"""                  """nothing"""
Line 647  class ECHO_root(Folder,Persistent,Implic Line 699  class ECHO_root(Folder,Persistent,Implic
     """ECHO Root Folder"""      """ECHO Root Folder"""
     meta_type="ECHO_root"      meta_type="ECHO_root"
   
       
   
       def ECHO_newViewerLink(self,obj=None):
           """change links (:86 faellt weg)"""
   
           if not obj:
               obj = self
               
           entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection'])
   
           for entry in entries:
                   
                   if entry[1].meta_type == 'ECHO_resource':
                       
                       entry[1].link=re.sub('\:86','',entry[1].link)
   
                   else:
                       
                       entry[1].ECHO_newViewerLink(entry[1])
                   
           return "Rerenderd all links to resources in: "+self.title
   
     def __init__(self,id,title):      def __init__(self,id,title):
         """init"""          """init"""
         self.id = id          self.id = id
         self.title=title          self.title=title
   
       def deleteSpace(self,str):
           """delete space at the end of a line"""
           if str[len(str)-1]==" ":
               return str[0:len(str)-1]
           else:
               return str
           
       
   
       # zusaetliche methoden fuer das vlp muessen in ein eigenes produkt
   
       def formatAscii(self,str,url=None):
           """ersetze ascii umbrueche durch <br>"""
           #url=None
           if url:
               
               retStr=""
               words=str.split("\n")
               
               for word in words:
                   strUrl=url%word
                   print "str",strUrl
                   retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word)
               str=retStr
           if str:
               return re.sub(r"[\n]","<br/>",str)
           else:
               return ""
           
       def link2html(self,str):
           """link2html fuer VLP muss hier noch raus"""
           if str:
               print str
               str=re.sub("\&","&amp;",str)
               dom=xml.dom.minidom.parseString("<?xml version='1.0' ?><txt>"+str+"</txt>")
               links=dom.getElementsByTagName("link")
               
               print "link",links
               for link in links:
                   link.tagName="a"
                   ref=link.getAttribute("ref")
                   if self.checkRef(ref):
                       link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref)
   
               return dom.toxml('utf-8')
           return ""
   
   
       def checkRef(self,ref):
           dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''}
           res=None
           for db in dbs.keys():
               #print ref,"select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db])
   
               res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db])))
           return res
                                       
       #Ende Methode fuer vlp
   
     def PgQuoteString(self,string):      def PgQuoteString(self,string):
         """Quote string"""          """Quote string"""
         print "PG",string          #print "PG",string
         return libpq.PgQuoteString(string)          return libpq.PgQuoteString(string)
                   
     def getPartners(self):      def getPartners(self):

Removed from v.1.13  
changed lines
  Added in v.1.23


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