--- ECHO_content/ECHO_collection.py 2004/04/04 14:56:05 1.27
+++ ECHO_content/ECHO_collection.py 2004/04/06 15:21:33 1.33
@@ -11,6 +11,7 @@ class ECHO_externalLink contains informa
"""
import string
import re
+import os
import OFS.Image
from types import *
from OFS.Image import Image
@@ -22,8 +23,10 @@ from Globals import InitializeClass
from Globals import DTMLFile
from Products.PageTemplates.PageTemplateFile import PageTemplateFile
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 psycopg import libpq
#from pyPgSQL import libpq
import xml.dom.minidom
@@ -35,7 +38,21 @@ from ECHO_graphicalOverview import javaH
#List of different types for the graphical linking viewer
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):
"""Einzelfeld in Liste umwandeln"""
if type(field)==StringType:
@@ -173,6 +190,83 @@ class scientificInformation(Folder,Persi
def get_period(self):
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):
"""ECHO Ressource"""
@@ -180,6 +274,10 @@ class ECHO_resource(Folder):
viewClassificationList=viewClassificationListMaster
+ def content_html(self):
+ """template fuer content"""
+ return content_html(self,'resource')
+
def getViewClassification(self):
if hasattr(self,'viewClassification'):
return self.viewClassification
@@ -239,9 +337,10 @@ class ECHO_resource(Folder):
def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):
"""Änderung der Properties"""
-
- coordsnew=[ string.split(x,",") for x in coords]
-
+ try:
+ coordsnew=[ string.split(x,",") for x in coords]
+ except:
+ coordsnew=[]
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew)
@@ -344,7 +443,10 @@ class ECHO_externalLink(Folder):
security=ClassSecurityInfo()
meta_type='ECHO_externalLink'
-
+ def content_html(self):
+ """template fuer content"""
+ return content_html(self,'externalLink')
+
def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords):
self.id = id
@@ -441,7 +543,21 @@ class ECHO_collection(Folder, Persistent
return "done"
except:
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):
"""Tree as XML"""
@@ -530,7 +646,7 @@ class ECHO_collection(Folder, Persistent
return []
- def __init__(self,id,title,label,description,contentType,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
self.id = id
@@ -546,7 +662,9 @@ class ECHO_collection(Folder, Persistent
self.sortfield=sortfield
coordsnew=[ string.split(x,",") for x in coords]
self.coords=coordsnew
-
+ self.secondaryLinkTitle=secondaryLinkTitle
+ self.secondaryLink=secondaryLink
+
manage_options = Folder.manage_options+(
{'label':'Main Config','action':'ECHO_collection_config'},
@@ -604,15 +722,23 @@ class ECHO_collection(Folder, Persistent
security.declarePublic('changeECHO_collection')
- def changeECHO_collection(self,title,label,description,contentType,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"""
+ self.secondaryLink=secondaryLink
+ self.secondaryLinkTitle=secondaryLinkTitle
self.imageTag=imageTag
- coordsnew=[ string.split(x,",") for x in coords]
-
+ if 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)
+
+
- self.coords=coordsnew[0:]
self.sortfield=sortfield
if RESPONSE is not None:
@@ -634,14 +760,20 @@ class ECHO_collection(Folder, Persistent
if 'index.html' in self.__dict__.keys():
return getattr(self,'index.html')()
+
elif 'overview' in self.__dict__.keys():
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.contentType="text/html"
+ pt.content_type="text/html"
return pt()
+ def content_html(self):
+ """template fuer content"""
+ return content_html(self,'collection')
+
def getCredits(self):
"""Ausgabe der credits"""
if self.credits:
@@ -719,11 +851,11 @@ def manage_addECHO_collectionForm(self):
return pt()
-def manage_addECHO_collection(self,id,title,label,description,contentType,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"""
- newObj=ECHO_collection(id,title,label,description,contentType,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)
@@ -734,7 +866,24 @@ class ECHO_root(Folder,Persistent,Implic
"""ECHO Root Folder"""
meta_type="ECHO_root"
-
+
+ def contentTypeSelector_HTML(self,selected=None):
+ """give type selector"""
+ if not selected:
+ retStr="