version 1.28, 2004/04/04 17:48:22
|
version 1.63, 2004/05/07 14:34:07
|
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 ECHO_helpers import displayTypes |
#from pyPgSQL import libpq |
try: |
|
from psycopg import libpq |
|
except: |
|
try: |
|
from pyPgSQL import libpq |
|
except: |
|
print "ECHO_collection: Warning - No libpq imported!" |
|
|
import xml.dom.minidom |
import xml.dom.minidom |
|
|
import urllib |
import urllib |
import xml.dom.minidom |
import xml.dom.minidom |
from ECHO_graphicalOverview import javaHandler,javaScriptMain |
from ECHO_graphicalOverview import javaHandler,javaScriptMain |
|
import ECHO_helpers |
|
|
#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 173 class scientificInformation(Folder,Persi
|
Line 197 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" |
|
|
|
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) |
|
|
|
|
|
"""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 271 class ECHO_resource(Folder):
|
|
|
viewClassificationList=viewClassificationListMaster |
viewClassificationList=viewClassificationListMaster |
|
|
|
getSubCols = ECHO_helpers.getSubCols |
|
def getTitle(self): |
|
"""title""" |
|
return self.title.encode('utf-8') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
return self.label.encode('utf-8') |
|
|
|
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 222 class ECHO_resource(Folder):
|
Line 326 class ECHO_resource(Folder):
|
except: |
except: |
return [] |
return [] |
|
|
|
def getContentType(self): |
|
try: |
|
return self.contentType |
|
except: |
|
return "" |
|
|
def ECHO_resource_config(self): |
def ECHO_resource_config(self): |
"""Main configuration""" |
"""Main configuration""" |
Line 239 class ECHO_resource(Folder):
|
Line 348 class ECHO_resource(Folder):
|
def changeECHO_resource(self,metalink,link,title,label,description,contentType,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""" |
|
|
|
try: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
|
except: |
|
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 344 class ECHO_externalLink(Folder):
|
Line 454 class ECHO_externalLink(Folder):
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_externalLink' |
meta_type='ECHO_externalLink' |
|
|
|
def getTitle(self): |
|
"""title""" |
|
return self.title.encode('utf-8') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
return self.label.encode('utf-8') |
|
|
|
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): |
def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords): |
|
|
Line 378 class ECHO_externalLink(Folder):
|
Line 499 class ECHO_externalLink(Folder):
|
def changeECHO_externalLink(self,link,title,label,description,contentType,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""" |
|
try: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
|
except: |
|
coordsnew=[] |
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) |
|
|
Line 421 def manage_addECHO_externalLink(self,id,
|
Line 545 def manage_addECHO_externalLink(self,id,
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
class ECHO_link(ECHO_externalLink): |
|
"""external_link""" |
|
|
|
meta_type="ECHO_link" |
|
|
|
|
|
def content_html(self): |
|
"""template fuer content""" |
|
return content_html(self,'link') |
|
|
|
def manage_addECHO_linkForm(self): |
|
"""Form for external Links""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_linkForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
def manage_addECHO_link(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None): |
|
"""Add an external Link""" |
|
|
|
newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords) |
|
|
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_collection(Folder, Persistent, Implicit): |
class ECHO_collection(Folder, Persistent, Implicit): |
"""ECHO Collection""" |
"""ECHO Collection""" |
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_collection' |
meta_type='ECHO_collection' |
|
|
|
displayTypes=displayTypes |
|
|
|
def getTitle(self): |
|
"""title""" |
|
return self.title.encode('utf-8') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
return self.label.encode('utf-8') |
|
|
|
def createRessourcesFromXMLForm(self): |
|
"""form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/createRessourcesFromXMLForm.zpt').__of__(self) |
|
return pt() |
|
def createRessourcesFromXML(self,fileupload): |
|
"""read an XML file for generating resources""" |
|
dom=xml.dom.minidom.parse(fileupload) |
|
ret="<h2>Added</h2>" |
|
for resource in dom.getElementsByTagName('resource'): |
|
link=getText(resource.getElementsByTagName('link')[0].childNodes) |
|
label=getText(resource.getElementsByTagName('label')[0].childNodes) |
|
#splitted=link.split("?")[0].split("/") |
|
#id=splitted[len(splitted)-1].encode('ascii') |
|
id=re.sub(" ","_",label).encode('ascii') |
|
|
|
ret+="<p>"+label+"</p>" |
|
manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","","",link.encode('ascii'),"","") |
|
return ret |
def getImageTag(self): |
def getImageTag(self): |
"""GetTag""" |
"""GetTag""" |
try: |
try: |
Line 442 class ECHO_collection(Folder, Persistent
|
Line 620 class ECHO_collection(Folder, Persistent
|
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 451 class ECHO_collection(Folder, Persistent
|
Line 643 class ECHO_collection(Folder, Persistent
|
for entry in object.__dict__.keys(): |
for entry in object.__dict__.keys(): |
element=getattr(object,entry) |
element=getattr(object,entry) |
try: |
try: |
if element.meta_type=="ECHO_collection": |
if element.meta_type in ["ECHO_collection","ECHO_group"]: |
collections+="<element name=\""+element.title+"\" url=\""+element.absolute_url()+"\">" |
collections+="<element name=\""+quote(element.title)+"\" url=\""+element.absolute_url()+"\">" |
collections+=getCollection(element,depth)+"</element>\n" |
collections+=getCollection(element,depth)+"</element>\n" |
except: |
except: |
"""nothing""" |
"""nothing""" |
return collections |
return collections |
|
|
|
ret="""<?xml version="1.0" encoding="utf-8" ?>""" |
return "<collection>"+getCollection(self)+"</collection>" |
return ret+"<collection>"+getCollection(self)+"</collection>" |
|
|
def createJavaScript(self): |
def createJavaScript(self): |
"""CreateJava""" |
"""CreateJava""" |
Line 467 class ECHO_collection(Folder, Persistent
|
Line 659 class ECHO_collection(Folder, Persistent
|
|
|
dynamical="" |
dynamical="" |
for ob in self.getGraphicCoords(): |
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]) |
|
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 |
ret+=javaHandler%dynamical |
return ret |
return ret |
|
|
Line 499 class ECHO_collection(Folder, Persistent
|
Line 695 class ECHO_collection(Folder, Persistent
|
return ret |
return ret |
|
|
security.declarePublic('ECHO_rerenderLinksMD') |
security.declarePublic('ECHO_rerenderLinksMD') |
def ECHO_rerenderLinksMD(self): |
def ECHO_rerenderLinksMD(self,obj=None): |
"""Rerender all Links""" |
"""Rerender all Links""" |
|
if not obj: |
|
obj = self |
|
|
for entry in self.__dict__.keys(): |
entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection']) |
object=getattr(self,entry) |
|
|
|
|
|
try: |
|
|
|
if object.meta_type == 'ECHO_resource': |
for entry in entries: |
|
if entry[1].meta_type == 'ECHO_resource': |
|
entry[1].ECHO_getResourceMD(template="no") |
|
print "rerender",entry[1].getId() |
|
else: |
|
self.ECHO_rerenderLinksMD(entry[1]) |
|
|
object.ECHO_getResourceMD(template="no") |
|
|
|
except: |
|
"""nothing""" |
|
|
|
return "Rerenderd all links to resources in: "+self.title |
return "Rerenderd all links to resources in: "+self.title |
|
|
Line 530 class ECHO_collection(Folder, Persistent
|
Line 726 class ECHO_collection(Folder, Persistent
|
|
|
return [] |
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="",bgcolour=""): |
#print "CO",coords |
#print "CO",coords |
|
|
self.id = id |
self.id = id |
Line 546 class ECHO_collection(Folder, Persistent
|
Line 742 class ECHO_collection(Folder, Persistent
|
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 |
|
self.bgcolour=bgcolour |
|
|
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
|
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, |
|
|
) |
) |
|
|
Line 604 class ECHO_collection(Folder, Persistent
|
Line 804 class ECHO_collection(Folder, Persistent
|
security.declarePublic('changeECHO_collection') |
security.declarePublic('changeECHO_collection') |
|
|
|
|
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag=""): |
def getBgcolour(self): |
|
"""colour""" |
|
if hasattr(self,'bgcolour') and not (self.bgcolour==""): |
|
return self.bgcolour |
|
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=""): |
"""Änderung der Properties""" |
"""Änderung der Properties""" |
|
|
|
self.secondaryLink=secondaryLink |
|
self.secondaryLinkTitle=secondaryLinkTitle |
self.imageTag=imageTag |
self.imageTag=imageTag |
|
self.bgcolour=bgcolour |
|
|
|
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,contentType,responsible,credits,weight,coordsnew) |
|
try: |
|
self.coords=coordsnew[0:] # HACK fehler in setECHO_collection |
|
except: |
|
"""none""" |
|
|
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 853 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() |
|
elif hasattr(self,'main_index_template'): |
|
return self.main_index_template() |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_standard.zpt').__of__(self) |
pt.content_type="text/html" |
pt.contentType="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 663 class ECHO_collection(Folder, Persistent
|
Line 890 class ECHO_collection(Folder, Persistent
|
if len(coordtemp)>3: |
if len(coordtemp)>3: |
coord=coordtemp[0:4] |
coord=coordtemp[0:4] |
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]) |
ids.append([string.join(coord,", "),object.getId(),object.label,object,coordtemp]) |
elif hasattr(object,'title'): |
elif hasattr(object,'title'): |
if not object.title=="": |
if not object.title=="": |
ids.append([string.join(coord,", "),object.getId(),object.title,object]) |
ids.append([string.join(coord,", "),object.getId(),object.title,object,coordtemp]) |
else: |
else: |
ids.append([string.join(coord,", "),object.getId(),object.getId(),object]) |
ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp]) |
else: |
else: |
ids.append([string.join(coord,", "),object.getId(),object.getId(),object]) |
ids.append([string.join(coord,", "),object.getId(),object.getId(),object,coordtemp]) |
|
|
except: |
except: |
"""nothing""" |
"""nothing""" |
|
|
return ids |
return ids |
|
|
def getSubCols(self,sortfield="weight"): |
|
|
|
subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] |
|
ids=[] |
|
for entry in self.__dict__.keys(): |
|
object=getattr(self,entry) |
|
try: |
|
if object.meta_type in subColTypes: |
|
ids.append(object) |
|
|
|
except: |
|
"""nothing""" |
|
try: |
|
sortfield=self.sortfield |
|
except: |
|
"""nothing""" |
|
|
|
tmplist=[] |
|
for x in ids: |
|
if hasattr(x,sortfield): |
|
try: |
|
x=int(x) |
|
except: |
|
"""nothing""" |
|
tmp=getattr(x,sortfield) |
|
else: |
|
tmp=10000000 |
|
tmplist.append((tmp,x)) |
|
tmplist.sort() |
|
return [x for (key,x) in tmplist] |
|
|
|
|
|
|
getSubCols = ECHO_helpers.getSubCols |
|
|
|
|
|
|
Line 719 def manage_addECHO_collectionForm(self):
|
Line 918 def manage_addECHO_collectionForm(self):
|
return pt() |
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="",bgcolour=""): |
"""add a echo collection""" |
"""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,bgcolour="") |
|
|
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
class ECHO_group(ECHO_collection): |
|
"""ECHO Gruppe""" |
|
meta_type="ECHO_group" |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_group_config'}, |
|
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
|
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
|
) |
|
|
|
def index_html(self): |
|
"""standard page""" |
|
displayedObjects=self.ZopeFind(self,obj_metatypes=displayTypes) |
|
#if (len(displayedObjects)==1) and (displayedObjects[0][1].meta_type=="ECHO_collection"): # nur ein Object dann redirect auf dieses Object |
|
# return self.REQUEST.RESPONSE.redirect(displayedObjects[0][1].absolute_url()) |
|
|
|
if 'index.html' in self.__dict__.keys(): |
|
return getattr(self,'index.html')() |
|
|
|
elif 'overview' in self.__dict__.keys(): |
|
return self.showOverview() |
|
elif hasattr(self,'group_index_template'): |
|
return self.group_index_template() |
|
elif hasattr(self,'collection_index_template'): |
|
return self.collection_index_template() |
|
elif hasattr(self,'main_index_template'): |
|
return self.main_index_template() |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_group_config(self): |
|
"""Main configuration""" |
|
|
|
if not hasattr(self,'weight'): |
|
self.weight="" |
|
|
|
if not hasattr(self,'sortfield'): |
|
self.sortfield="weight" |
|
|
|
if not hasattr(self,'coords'): |
|
self.coords=[] |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_group.zpt').__of__(self) |
|
return pt() |
|
|
|
def changeECHO_group(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): |
|
"""Änderung der Properties""" |
|
|
|
self.secondaryLink=secondaryLink |
|
self.secondaryLinkTitle=secondaryLinkTitle |
|
self.imageTag=imageTag |
|
self.bgcolour=bgcolour |
|
self.logo=logo |
|
|
|
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.sortfield=sortfield |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def getLogo(self): |
|
"""logo ausgeben""" |
|
try: |
|
return self.logo |
|
except: |
|
return "ECHO_groups" |
|
|
|
def content_html(self): |
|
"""template fuer content""" |
|
return content_html(self,'group') |
|
|
|
|
|
|
|
def manage_addECHO_groupForm(self): |
|
"""Add group form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_groupForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
def manage_addECHO_group(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): |
|
"""add a echo group""" |
|
|
|
|
|
newObj=ECHO_group(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") |
|
|
|
setattr(newObj,'logo',logo) |
self._setObject(id,newObj) |
self._setObject(id,newObj) |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
class ECHO_root(Folder,Persistent,Implicit): |
class ECHO_root(Folder,Persistent,Implicit): |
"""ECHO Root Folder""" |
"""ECHO Root Folder""" |
meta_type="ECHO_root" |
meta_type="ECHO_root" |
|
|
|
|
|
def getImageTag(self): |
|
"""needed by main_template""" |
|
return "" |
|
secondaryLink="" #needed by main_template |
|
secondaryLinkTitle="" #needed by main_template |
|
|
|
def getBgcolour(self): |
|
"""hack""" |
|
return "#dddddd" |
|
|
def contentTypeSelector_HTML(self,selected=None): |
def contentTypeSelector_HTML(self,selected=None): |
"""give type selector""" |
"""give type selector""" |
if not selected: |
if not selected: |
Line 742 class ECHO_root(Folder,Persistent,Implic
|
Line 1056 class ECHO_root(Folder,Persistent,Implic
|
else: |
else: |
retStr="<option>\n" |
retStr="<option>\n" |
|
|
|
try: # erste version contentTypes exists |
|
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: |
try: |
try: |
for contentType in self.ZopeFind(self.contentTypes,obj_metatypes="ECHO_contentType"): |
for contentType in self.ZopeFind(self.standardMD,obj_metatypes=["OSAS_MetadataMapping"]): |
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: |
"""nothing""" |
"""nothing""" |
|
|
return retStr |
return retStr |
|
|
def patchContentType(self,obj=None): |
def patchContentType(self,obj=None): |
Line 759 class ECHO_root(Folder,Persistent,Implic
|
Line 1081 class ECHO_root(Folder,Persistent,Implic
|
if not obj: |
if not obj: |
obj = self |
obj = self |
|
|
entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection,ECHO_externalLink,ECHO_pageTemplate']) |
entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection','ECHO_externalLink','ECHO_pageTemplate']) |
|
|
for entry in entries: |
for entry in entries: |
|
setattr(entry[1],'contentType',entry[1].content_type) |
entry[1].contentType == entry[1].content_type |
#entry[1].contentType == entry[1].content_type |
|
|
if entry[1].meta_type == 'ECHO_collection': |
if entry[1].meta_type == 'ECHO_collection': |
entry[1].patchContentType(entry[1]) |
entry[1].patchContentType(entry[1]) |
|
|
|
|
return "Rerenderd all links to resources 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: |
|
if len(coordtemp)>3: |
|
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]): |
|
setattr(entry[1],'viewClassification','view point') |
|
else: |
|
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)""" |
Line 872 class ECHO_root(Folder,Persistent,Implic
|
Line 1226 class ECHO_root(Folder,Persistent,Implic
|
def getPartnersXML(self): |
def getPartnersXML(self): |
"""partner liste als xml""" |
"""partner liste als xml""" |
partners=self.getPartners() |
partners=self.getPartners() |
ret="<partners>" |
ret="""<?xml version="1.0" encoding="utf-8" ?> |
|
<partners>""" |
|
|
for partner in partners: |
for partner in partners: |
ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),partner.title) |
ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),unicode(partner.title,'utf-8','replace')) |
|
|
return ret+"\n</partners>" |
return ret+"\n</partners>" |
|
|
Line 923 class ECHO_partner(Image,Persistent):
|
Line 1279 class ECHO_partner(Image,Persistent):
|
|
|
meta_type="ECHO_partner" |
meta_type="ECHO_partner" |
|
|
def __init__(self, id, title,url, file, contentType='', precondition=''): |
def __init__(self, id, title,url, file, content_type='', precondition=''): |
self.__name__=id |
self.__name__=id |
self.title=title |
self.title=title |
self.url=url |
self.url=url |
self.precondition=precondition |
self.precondition=precondition |
|
|
data, size = self._read_data(file) |
data, size = self._read_data(file) |
contentType=self._get_contentType(file, data, id, contentType) |
content_type=self._get_content_type(file, data, id, content_type) |
self.update_data(data, contentType, size) |
self.update_data(data, content_type, size) |
|
|
manage_options = Image.manage_options+( |
manage_options = Image.manage_options+( |
{'label':'Partner Information','action':'ECHO_partner_config'}, |
{'label':'Partner Information','action':'ECHO_partner_config'}, |
Line 958 manage_addECHO_partnerForm=DTMLFile('dtm
|
Line 1314 manage_addECHO_partnerForm=DTMLFile('dtm
|
|
|
|
|
|
|
def manage_addECHO_partner(self, id, file,url, title='', precondition='', contentType='', |
def manage_addECHO_partner(self, id, file,url, title='', precondition='', content_type='', |
REQUEST=None): |
REQUEST=None): |
""" |
""" |
Add a new ECHO_partner object. |
Add a new ECHO_partner object. |
Line 969 def manage_addECHO_partner(self, id, fil
|
Line 1325 def manage_addECHO_partner(self, id, fil
|
|
|
id=str(id) |
id=str(id) |
title=str(title) |
title=str(title) |
contentType=str(contentType) |
content_type=str(content_type) |
precondition=str(precondition) |
precondition=str(precondition) |
|
|
id, title = OFS.Image.cookId(id, title, file) |
id, title = OFS.Image.cookId(id, title, file) |
Line 977 def manage_addECHO_partner(self, id, fil
|
Line 1333 def manage_addECHO_partner(self, id, fil
|
self=self.this() |
self=self.this() |
|
|
# First, we create the image without data: |
# First, we create the image without data: |
self._setObject(id, ECHO_partner(id,title,url,'',contentType, precondition)) |
self._setObject(id, ECHO_partner(id,title,url,'',content_type, precondition)) |
|
|
# Now we "upload" the data. By doing this in two steps, we |
# Now we "upload" the data. By doing this in two steps, we |
# can use a database trick to make the upload more efficient. |
# can use a database trick to make the upload more efficient. |
if file: |
if file: |
self._getOb(id).manage_upload(file) |
self._getOb(id).manage_upload(file) |
if contentType: |
if content_type: |
self._getOb(id).contentType=contentType |
self._getOb(id).content_type=content_type |
|
|
if REQUEST is not None: |
if REQUEST is not None: |
try: url=self.DestinationURL() |
try: url=self.DestinationURL() |