|
|
| version 1.25, 2004/04/02 15:06:47 | version 1.32, 2004/04/05 15:38:19 |
|---|---|
| Line 11 class ECHO_externalLink contains informa | Line 11 class ECHO_externalLink contains informa |
| """ | """ |
| import string | import string |
| import re | import re |
| import os | |
| import OFS.Image | import OFS.Image |
| from types import * | from types import * |
| from OFS.Image import Image | from OFS.Image import Image |
| Line 22 from Globals import InitializeClass | Line 23 from Globals import InitializeClass |
| from Globals import DTMLFile | from Globals import DTMLFile |
| from Products.PageTemplates.PageTemplateFile import PageTemplateFile | from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
| from Products.PageTemplates.PageTemplate import PageTemplate | from Products.PageTemplates.PageTemplate import PageTemplate |
| from Globals import Persistent | from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
| from Globals import Persistent, package_home | |
| from Acquisition import Implicit | from Acquisition import Implicit |
| #from psycopg import libpq | #from psycopg import libpq |
| #from pyPgSQL import libpq | #from pyPgSQL import libpq |
| import xml.dom.minidom | import xml.dom.minidom |
| Line 35 from ECHO_graphicalOverview import javaH | Line 38 from ECHO_graphicalOverview import javaH |
| #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'] |
| def content_html(self,type): | |
| """template fuer content""" | |
| #templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) | |
| # | |
| #if templates: | |
| # return templates[0][1]() | |
| try: | |
| obj=getattr(self,type+"_template") | |
| return obj() | |
| except: | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_%s_template_standard.zpt'%type).__of__(self) | |
| pt.content_type="text/html" | |
| return pt() | |
| def toList(field): | def toList(field): |
| """Einzelfeld in Liste umwandeln""" | """Einzelfeld in Liste umwandeln""" |
| Line 96 def readMetadata(url): | Line 113 def readMetadata(url): |
| return metadict,"" | return metadict,"" |
| def setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coordstrs,viewClassification=""): | def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs,viewClassification=""): |
| """Allegemeine Informationen zu einer ECHO Collection""" | """Allegemeine Informationen zu einer ECHO Collection""" |
| Line 105 def setECHO_collectionInformation(self,t | Line 122 def setECHO_collectionInformation(self,t |
| self.label = label | self.label = label |
| self.title=title | self.title=title |
| self.description=description | self.description=description |
| self.content_type=content_type | self.contentType=contentType |
| self.responsible=responsible | self.responsible=responsible |
| self.credits=toList(credits) | self.credits=toList(credits) |
| self.weight=weight | self.weight=weight |
| Line 173 class scientificInformation(Folder,Persi | Line 190 class scientificInformation(Folder,Persi |
| def get_period(self): | def get_period(self): |
| return self.period | return self.period |
| class ECHO_layoutTemplate(ZopePageTemplate): | |
| """Create a layout Template for different purposes""" | |
| meta_type="ECHO_layoutTemplate" | |
| #manage_options=ZopePageTemplate.manage_options+( | |
| # {'label':'Set back to Standard','action':'changeECHO_layoutTemplateToStandardForm'}, | |
| # ) | |
| def __init__(self, id, text=None, content_type=None,EchoType=None): | |
| self.id = str(id) | |
| self.ZBindings_edit(self._default_bindings) | |
| if text is None: | |
| self._default_content_fn = os.path.join(package_home(globals()), | |
| 'zpt/ECHO_%s_template_standard.zpt'%EchoType) | |
| text = open(self._default_content_fn).read() | |
| self.pt_edit(text, content_type) | |
| ## def changeECHO_layoutTemplateToStandardForm(self): | |
| ## """change form""" | |
| ## pt=PageTemplateFile('Products/ECHO_content/zpt/changeECHO_pageTemplateWeightForm.zpt').__of__(self) | |
| ## return pt() | |
| """change form""" | |
| def manage_addECHO_layoutTemplateForm(self): | |
| """Form for adding""" | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_layoutTemplate.zpt').__of__(self) | |
| return pt() | |
| from urllib import quote | |
| def manage_addECHO_layoutTemplate(self, EchoType,title=None,REQUEST=None): | |
| "Add a Page Template with optional file content." | |
| if type(EchoType)==StringType: | |
| EchoTypes=[EchoType] | |
| else: | |
| EchoTypes=EchoType | |
| for singleType in EchoTypes: | |
| id = str(singleType)+"_template" | |
| if REQUEST is None: | |
| self._setObject(id, ECHO_layoutTemplate(id, text,EchoType=singleType)) | |
| ob = getattr(self, id) | |
| if title: | |
| ob.pt_setTitle(title) | |
| return ob | |
| else: | |
| file = REQUEST.form.get('file') | |
| headers = getattr(file, 'headers', None) | |
| if headers is None or not file.filename: | |
| zpt = ECHO_layoutTemplate(id,EchoType=singleType) | |
| else: | |
| zpt = ECHO_layoutTemplate(id, file, headers.get('content_type')) | |
| self._setObject(id, zpt) | |
| ob = getattr(self, id) | |
| if title: | |
| ob.pt_setTitle(title) | |
| try: | |
| u = self.DestinationURL() | |
| except AttributeError: | |
| u = REQUEST['URL1'] | |
| REQUEST.RESPONSE.redirect(u+'/manage_main') | |
| return '' | |
| class ECHO_resource(Folder): | class ECHO_resource(Folder): |
| """ECHO Ressource""" | """ECHO Ressource""" |
| Line 180 class ECHO_resource(Folder): | Line 274 class ECHO_resource(Folder): |
| viewClassificationList=viewClassificationListMaster | viewClassificationList=viewClassificationListMaster |
| def content_html(self): | |
| """template fuer content""" | |
| return content_html(self,'resource') | |
| def getViewClassification(self): | def getViewClassification(self): |
| if hasattr(self,'viewClassification'): | if hasattr(self,'viewClassification'): |
| return self.viewClassification | return self.viewClassification |
| Line 193 class ECHO_resource(Folder): | Line 291 class ECHO_resource(Folder): |
| else: | else: |
| return [] | return [] |
| def __init__(self,id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords): | def __init__(self,id,link,metalink,title,label,description,contentType,responsible,credits,weight,coords): |
| self.id = id | self.id = id |
| """Festlegen der ID""" | """Festlegen der ID""" |
| Line 205 class ECHO_resource(Folder): | Line 303 class ECHO_resource(Folder): |
| self.weight=weight | self.weight=weight |
| self.credits=toList(credits) | self.credits=toList(credits) |
| self.description=description | self.description=description |
| self.content_type=content_type | self.contentType=contentType |
| self.responsible=responsible | self.responsible=responsible |
| if coords: | if coords: |
| Line 236 class ECHO_resource(Folder): | Line 334 class ECHO_resource(Folder): |
| 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,contentType,responsible,weight,viewClassification="",coords=None,credits=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,contentType,responsible,credits,weight,coordsnew) |
| self.coords=coordsnew[0:] | self.coords=coordsnew[0:] |
| self.link=link | self.link=link |
| Line 328 def manage_addECHO_resourceForm(self): | Line 426 def manage_addECHO_resourceForm(self): |
| def manage_addECHO_resource(self,id,title,label,description,content_type,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): | def manage_addECHO_resource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
| """addaresource""" | """addaresource""" |
| newObj=ECHO_resource(id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords) | newObj=ECHO_resource(id,link,metalink,title,label,description,contentType,responsible,credits,weight,coords) |
| self._setObject(id,newObj) | self._setObject(id,newObj) |
| Line 344 class ECHO_externalLink(Folder): | Line 442 class ECHO_externalLink(Folder): |
| security=ClassSecurityInfo() | security=ClassSecurityInfo() |
| meta_type='ECHO_externalLink' | meta_type='ECHO_externalLink' |
| def content_html(self): | |
| """template fuer content""" | |
| return content_html(self,'externalLink') | |
| def __init__(self,id,link,title,label,description,content_type,responsible,credits,weight,coords): | def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords): |
| self.id = id | self.id = id |
| """Festlegen der ID""" | """Festlegen der ID""" |
| Line 356 class ECHO_externalLink(Folder): | Line 457 class ECHO_externalLink(Folder): |
| self.title=title | self.title=title |
| self.weight=weight | self.weight=weight |
| self.description=description | self.description=description |
| self.content_type=content_type | self.contentType=contentType |
| self.responsible=responsible | self.responsible=responsible |
| coordsnew=[ string.split(x,",") for x in coords] | coordsnew=[ string.split(x,",") for x in coords] |
| self.coords=coordsnew | self.coords=coordsnew |
| Line 375 class ECHO_externalLink(Folder): | Line 476 class ECHO_externalLink(Folder): |
| return pt() | return pt() |
| 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,contentType,responsible,weight,coords=None,credits=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,coords) | setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) |
| self.coords=coordsnew[0:] | self.coords=coordsnew[0:] |
| self.link=link | self.link=link |
| Line 410 def manage_addECHO_externalLinkForm(self | Line 511 def manage_addECHO_externalLinkForm(self |
| return pt() | return pt() |
| def manage_addECHO_externalLink(self,id,title,label,description,content_type,responsible,link,weight,coords=None,credits=None,RESPONSE=None): | def manage_addECHO_externalLink(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None): |
| """Add an external Link""" | """Add an external Link""" |
| newObj=ECHO_externalLink(id,link,title,label,description,content_type,responsible,credits,weight,coords) | newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords) |
| self._setObject(id,newObj) | self._setObject(id,newObj) |
| Line 434 class ECHO_collection(Folder, Persistent | Line 535 class ECHO_collection(Folder, Persistent |
| except: | except: |
| return "" | return "" |
| def addResource(self,id,title,label,description,content_type,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): | def addResource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
| """SSS""" | """SSS""" |
| try: | try: |
| manage_addECHO_resource(self,id,title,label,description,content_type,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) | manage_addECHO_resource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
| return "done" | return "done" |
| except: | except: |
| return None | return None |
| def getSecondaryLink(self): | |
| """secondary link""" | |
| try: | |
| return self.secondaryLink | |
| except: | |
| return "" | |
| def getSecondaryLinkTitle(self): | |
| """secondary link""" | |
| try: | |
| return self.secondaryLinkTitle | |
| except: | |
| return "" | |
| def getCollectionTreeXML(self): | def getCollectionTreeXML(self): |
| """Tree as XML""" | """Tree as XML""" |
| Line 530 class ECHO_collection(Folder, Persistent | Line 645 class ECHO_collection(Folder, Persistent |
| return [] | return [] |
| def __init__(self,id,title,label,description,content_type,responsible,credits,weight,sortfield,coords,imageTag=""): | def __init__(self,id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle,secondaryLink,imageTag=""): |
| #print "CO",coords | #print "CO",coords |
| self.id = id | self.id = id |
| Line 539 class ECHO_collection(Folder, Persistent | Line 654 class ECHO_collection(Folder, Persistent |
| self.label = label | self.label = label |
| self.title=title | self.title=title |
| self.description=description | self.description=description |
| self.content_type=content_type | self.contentType=contentType |
| self.responsible=responsible | self.responsible=responsible |
| self.imageTag=imageTag | self.imageTag=imageTag |
| self.weight=weight | self.weight=weight |
| self.sortfield=sortfield | self.sortfield=sortfield |
| coordsnew=[ string.split(x,",") for x in coords] | coordsnew=[ string.split(x,",") for x in coords] |
| self.coords=coordsnew | self.coords=coordsnew |
| self.secondaryLinkTitle=secondaryLinkTitle | |
| self.secondaryLink=secondaryLink | |
| manage_options = Folder.manage_options+( | manage_options = Folder.manage_options+( |
| Line 604 class ECHO_collection(Folder, Persistent | Line 721 class ECHO_collection(Folder, Persistent |
| security.declarePublic('changeECHO_collection') | security.declarePublic('changeECHO_collection') |
| def changeECHO_collection(self,title,label,description,content_type,responsible,weight,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag=""): | def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag=""): |
| """Änderung der Properties""" | """Änderung der Properties""" |
| self.secondaryLink=secondaryLink | |
| self.secondaryLinkTitle=secondaryLinkTitle | |
| self.imageTag=imageTag | self.imageTag=imageTag |
| if coords: | |
| coordsnew=[ string.split(x,",") for x in coords] | coordsnew=[ string.split(x,",") for x in coords] |
| self.coords=coordsnew[0:] | |
| else: | |
| coordsnew=None | |
| self.coords=None | |
| setECHO_collectionInformation(self,title,label,description,contentType,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 634 class ECHO_collection(Folder, Persistent | Line 759 class ECHO_collection(Folder, Persistent |
| if 'index.html' in self.__dict__.keys(): | if 'index.html' in self.__dict__.keys(): |
| return getattr(self,'index.html')() | return getattr(self,'index.html')() |
| elif 'overview' in self.__dict__.keys(): | elif 'overview' in self.__dict__.keys(): |
| return self.showOverview() | return self.showOverview() |
| elif hasattr(self,'collection_index_template'): | |
| return self.collection_index_template() | |
| pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_standard.zpt').__of__(self) | pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_standard.zpt').__of__(self) |
| pt.content_type="text/html" | pt.content_type="text/html" |
| return pt() | return pt() |
| def content_html(self): | |
| """template fuer content""" | |
| return content_html(self,'collection') | |
| def getCredits(self): | def getCredits(self): |
| """Ausgabe der credits""" | """Ausgabe der credits""" |
| if self.credits: | if self.credits: |
| Line 719 def manage_addECHO_collectionForm(self): | Line 850 def manage_addECHO_collectionForm(self): |
| return pt() | return pt() |
| def manage_addECHO_collection(self,id,title,label,description,content_type,responsible,weight,sortfield,coords="",credits=None,RESPONSE=None,imageTag=""): | def manage_addECHO_collection(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag=""): |
| """add a echo collection""" | """add a echo collection""" |
| newObj=ECHO_collection(id,title,label,description,content_type,responsible,credits,weight,sortfield,coords,imageTag) | newObj=ECHO_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag) |
| self._setObject(id,newObj) | self._setObject(id,newObj) |
| Line 735 class ECHO_root(Folder,Persistent,Implic | Line 866 class ECHO_root(Folder,Persistent,Implic |
| meta_type="ECHO_root" | meta_type="ECHO_root" |
| def contentTypeSelector_HTML(self,selected=None): | |
| """give type selector""" | |
| if not selected: | |
| retStr="<option selected>\n" | |
| else: | |
| retStr="<option>\n" | |
| try: | |
| for contentType in self.ZopeFind(self.contentTypes,obj_metatypes="ECHO_contentType"): | |
| 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""" | |
| return retStr | |
| def patchContentType(self,obj=None): | |
| """austauschen content_type with contentType (patch bei umstieg von alter Version)""" | |
| if not obj: | |
| obj = self | |
| entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection','ECHO_externalLink','ECHO_pageTemplate']) | |
| for entry in entries: | |
| setattr(entry[1],'contentType',entry[1].content_type) | |
| #entry[1].contentType == entry[1].content_type | |
| if entry[1].meta_type == 'ECHO_collection': | |
| entry[1].patchContentType(entry[1]) | |
| return "Rerenderd all links to resources 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)""" |
| Line 827 class ECHO_root(Folder,Persistent,Implic | Line 993 class ECHO_root(Folder,Persistent,Implic |
| def getPartners(self): | def getPartners(self): |
| """Get list of Partners. Presently only from a subfolder partners""" | """Get list of Partners. Presently only from a subfolder partners""" |
| partnerTypes=['ECHO_partner'] | |
| ids=[] | |
| try: | |
| for entry in self.partners.__dict__.keys(): | |
| object=getattr(self.partners,entry) | |
| try: | return [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] |
| if object.meta_type in partnerTypes: | |
| ids.append(object) | |
| except: | |
| """nothing""" | |
| except: | |
| ids=[] # no partners | |
| return ids | |
| def getPartnersXML(self): | |
| """partner liste als xml""" | |
| partners=self.getPartners() | |
| ret="<partners>" | |
| for partner in partners: | |
| ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),partner.title) | |
| return ret+"\n</partners>" | |
| def getCollectionTree(self): | def getCollectionTree(self): |
| """get the collection tree (list of triples (parent,child, depth)""" | """get the collection tree (list of triples (parent,child, depth)""" |