version 1.50, 2004/04/28 15:29:55
|
version 1.66, 2004/05/07 15:07:22
|
Line 26 from Products.PageTemplates.PageTemplate
|
Line 26 from Products.PageTemplates.PageTemplate
|
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Globals import Persistent, package_home |
from Globals import Persistent, package_home |
from Acquisition import Implicit |
from Acquisition import Implicit |
|
from ECHO_helpers import displayTypes |
try: |
try: |
from psycopg import libpq |
from psycopg import libpq |
except: |
except: |
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 545 def manage_addECHO_externalLink(self,id,
|
Line 567 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): |
def getTitle(self): |
"""title""" |
"""title""" |
return self.title.encode('utf-8') |
return self.title.encode('utf-8') |
Line 616 class ECHO_collection(Folder, Persistent
|
Line 666 class ECHO_collection(Folder, Persistent
|
element=getattr(object,entry) |
element=getattr(object,entry) |
try: |
try: |
if element.meta_type in ["ECHO_collection","ECHO_group"]: |
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""" |
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 830 class ECHO_collection(Folder, Persistent
|
Line 884 class ECHO_collection(Folder, Persistent
|
return self.showOverview() |
return self.showOverview() |
elif hasattr(self,'collection_index_template'): |
elif hasattr(self,'collection_index_template'): |
return 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_content_standard.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
return pt() |
|
|
Line 846 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 908 class ECHO_group(ECHO_collection):
|
Line 972 class ECHO_group(ECHO_collection):
|
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'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): |
def ECHO_group_config(self): |
"""Main configuration""" |
"""Main configuration""" |
|
|
Line 1003 class ECHO_root(Folder,Persistent,Implic
|
Line 1090 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 1032 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)""" |
|
|
Line 1133 class ECHO_root(Folder,Persistent,Implic
|
Line 1263 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>" |
|
|