version 1.30, 2004/12/02 15:44:26
|
version 1.37, 2005/01/31 11:15:50
|
Line 4 import socket
|
Line 4 import socket
|
import urllib |
import urllib |
import string |
import string |
import xml.dom.minidom |
import xml.dom.minidom |
from types import * |
import types |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from OFS.SimpleItem import SimpleItem |
from OFS.SimpleItem import SimpleItem |
from Globals import package_home |
from Globals import package_home |
Line 37 class ECHO_basis:
|
Line 37 class ECHO_basis:
|
"""showrdf""" |
"""showrdf""" |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
ret="""<?xml version="1.0" encoding="utf-8"?>\n<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ECHONAVIGATION="http://www.echo.eu/rdf#">\n""" |
ret="""<?xml version="1.0" encoding="utf-8"?>\n<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ECHONAVIGATION="http://www.echo.eu/rdf#">\n""" |
ret+=self.getRDF(urn="echo:colllectionroot")+"\n" |
|
|
ret+=self.getRDF(urn="echo:collectionroot")+"\n" |
|
|
|
|
ret+="""</RDF:RDF>""" |
ret+="""</RDF:RDF>""" |
return ret |
return ret |
Line 95 class ECHO_basis:
|
Line 97 class ECHO_basis:
|
|
|
def getTitle(self): |
def getTitle(self): |
"""title""" |
"""title""" |
|
return self.decode(self.title) |
try: |
try: |
return self.title.encode('utf-8','ignore') |
return self.title.encode('utf-8','ignore') |
except: |
except: |
Line 103 class ECHO_basis:
|
Line 106 class ECHO_basis:
|
|
|
def getLabel(self): |
def getLabel(self): |
"""title""" |
"""title""" |
|
|
|
return self.decode(self.label) |
try: |
try: |
return self.label.encode('utf-8','ignore') |
return self.label.encode('utf-8','ignore') |
except: |
except: |
Line 128 class ECHO_basis:
|
Line 133 class ECHO_basis:
|
|
|
manage_options=({'label':'change ECHO Navigation Entries','action':'changeECHOEntriesForm'},) |
manage_options=({'label':'change ECHO Navigation Entries','action':'changeECHOEntriesForm'},) |
|
|
|
|
|
def hasOverview(self): |
|
"""returns if there is an overview graphics""" |
|
return hasattr(self, 'overview') |
|
|
|
def hasParentOverview(self): |
|
"""returns if the parent has an overview graphics""" |
|
return hasattr(self.aq_parent, 'overview') |
|
|
|
def getOverview(self): |
|
"""map overview graphics""" |
|
#return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1] |
|
if self.hasOverview(): |
|
return getattr(self, 'overview') |
|
return None |
|
|
def getMapAreas(self): |
def getMapAreas(self): |
"""returns the list of MapAreas""" |
"""returns the list of MapAreas""" |
# get all contained MapAreas |
# get all contained MapAreas |
Line 142 class ECHO_basis:
|
Line 163 class ECHO_basis:
|
newarea.id = "a%02d"%len(areas) |
newarea.id = "a%02d"%len(areas) |
self._setObject(newarea.id, newarea) |
self._setObject(newarea.id, newarea) |
|
|
|
def ECHO_graphicEntry(self): |
|
"""change map coordinates""" |
|
if self.hasParentOverview(): |
|
pt=zptFile(self, 'zpt/ECHO_draw.zpt') |
|
return pt() |
|
else: |
|
return "NO OVERVIEW GRAPHICS" |
|
|
def ECHO_addCoords(self,RESPONSE=None): |
def ECHO_addCoords(self,RESPONSE=None): |
"""change or add MapArea""" |
"""change or add MapArea""" |
#return self.REQUEST |
#return self.REQUEST |
Line 178 class ECHO_basis:
|
Line 207 class ECHO_basis:
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('ECHO_graphicEntry') |
RESPONSE.redirect('ECHO_graphicEntry') |
|
|
|
def createJSAreas(self, areas): |
|
"""create area calls for JavaScript""" |
|
dynamical="\n" |
|
for ob in areas: |
|
if ob.isTypeArrow(): |
|
dynamical+="""addArea('%s', 'overview', %s, 'arrow');\n"""%(ob.getFullId(),ob.getCoordString()) |
|
else: |
|
dynamical+="""addArea('%s', 'overview', %s, 'area');\n"""%(ob.getFullId(),ob.getCoordString()) |
|
return dynamical |
|
|
|
def createMapHead(self): |
|
"""create javascript include and script tags for head""" |
|
pt=zptFile(self, 'zpt/ECHO_content_map_frag_js') |
|
return pt() |
|
|
|
def createMapImg(self): |
|
"""generate img-tag for map""" |
|
bt = BrowserCheck(self) |
|
tag = "" |
|
src = self.getOverview().absolute_url() |
|
if bt.isN4: |
|
# N4 needs ilayer to create an id |
|
tag += '<ilayer id="overview" visibility="show"><img src="%s"></ilayer>'%src |
|
else: |
|
# img with id |
|
tag += '<img id="overview" src="%s" />'%src |
|
return tag |
|
|
|
def createParentMapImg(self): |
|
"""generate img-tag for map of parent""" |
|
return self.aq_parent.createMapImg() |
|
|
|
def createMapLink(self, ob, text=None): |
|
"""generate map link""" |
|
bt = BrowserCheck(self) |
|
id = ob.getFullId() |
|
link = ob.getLinkId() |
|
if text is None: |
|
text = ob.getLabel() |
|
if text is None: |
|
text = "link" |
|
tiptext = ob.getText() |
|
tag = "" |
|
if bt.isN4: |
|
# N4 needs layer for highlighting |
|
tag += '<ilayer id="a.%s"><a onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank"'%(id,id,id,link) |
|
tag += ">" + text + "</a></ilayer>" |
|
else: |
|
# a-element |
|
tag = '<a id="a.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank"'%(id,id,id,link) |
|
if tiptext: |
|
tag += ' title="%s"'%tiptext |
|
tag += ">" + text + "</a>" |
|
return tag |
|
|
|
def createMapAux(self, ob, arrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil"): |
|
"""generate map link image, text and other stuff""" |
|
bt = BrowserCheck(self) |
|
id = ob.getFullId() |
|
link = ob.getLinkId() |
|
tiptext = ob.getText() |
|
tag = "" |
|
|
|
if bt.isN4: |
|
# N4 needs layer and img elements |
|
tag += '<layer id="i.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)">'%(id,id,id) |
|
if ob.isTypeArrow(): |
|
rot = ob.angle |
|
tag += '<a href="%s"><img border="0" src="%s&rot=%s" /></a>'%(link,arrowsrc,rot) |
|
else: |
|
tag += '<a href="%s"><img border="0" width="1000" height="1000" src="trans_img"'%(link) |
|
if tiptext: |
|
tag += ' alt="%s"'%tiptext |
|
tag += ' /></a>' |
|
tag += '</layer>' |
|
else: |
|
# create a-element |
|
tag = '<a id="b.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank">'%(id,id,id,link) |
|
if ob.isTypeArrow(): |
|
rot = ob.angle |
|
if bt.isIEWin and bt.versIE > 5: |
|
# IE/Win 5.5 has "feature" for PNG transparency |
|
tag += '<span id="i.%s" style="position:absolute; top:-100px; left:-100px; border-style:none; border-width=1px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'%s&rot=%s\');"><img style="visibility:hidden" src="%s&rot=%s" /></span>'%(id,arrowsrc,rot,arrowsrc,rot) |
|
else: |
|
# arrow image |
|
tag += '<img id="i.%s" src="%s&rot=%s" border="1" style="position:absolute; top:-100px; left:-100px; border-style:none;" />'%(id,arrowsrc,rot) |
|
else: |
|
if bt.isIE: |
|
# IE needs transparent img for area |
|
tag += '<img id="i.%s" border="0" style="position:absolute; top:-100px; left:-100px;" src="trans_img"'%(id) |
|
if tiptext: |
|
tag += ' title="%s"'%tiptext |
|
tag += " />" |
|
else: |
|
# div for area |
|
tag += '<div id="i.%s" style="position:absolute; top:-100px; left:-100px;"'%(id) |
|
if tiptext: |
|
tag += ' title="%s"'%tiptext |
|
tag += '> </div>' |
|
tag += '</a>' |
|
return tag |
|
|
|
|
#ende der echo erweiterungen |
#ende der echo erweiterungen |
|
|
|
|
def toList(field): |
def toList(field): |
"""Einzelfeld in Liste umwandeln""" |
"""Einzelfeld in Liste umwandeln""" |
if type(field)==StringType: |
if type(field)==types.StringType: |
return [field] |
return [field] |
else: |
else: |
return field |
return field |
Line 262 def getSubCols(self,sortfield="weight",s
|
Line 393 def getSubCols(self,sortfield="weight",s
|
def sortfnc(sortfield,x,y): |
def sortfnc(sortfield,x,y): |
xa=x[1].getMDValue(sortfield) |
xa=x[1].getMDValue(sortfield) |
ya=y[1].getMDValue(sortfield) |
ya=y[1].getMDValue(sortfield) |
print xa,ya |
#print xa,ya |
return cmp(xa,ya) |
return cmp(xa,ya) |
|
|
sortWithMD = lambda sortfield : (lambda x,y : sortfnc(sortfield,x,y)) |
sortWithMD = lambda sortfield : (lambda x,y : sortfnc(sortfield,x,y)) |
Line 281 def getSubCols(self,sortfield="weight",s
|
Line 412 def getSubCols(self,sortfield="weight",s
|
"""nothing""" |
"""nothing""" |
|
|
tmplist=[] |
tmplist=[] |
|
|
for x in ids: |
for x in ids: |
if hasattr(x,sortfield): |
if hasattr(x,sortfield): |
try: |
try: |
|
tmp=int(getattr(x,sortfield)) |
x=int(x) |
|
except: |
except: |
"""nothing""" |
|
tmp=getattr(x,sortfield) |
tmp=getattr(x,sortfield) |
|
|
else: |
else: |
tmp=10000000 |
tmp=10000000 |
|
|
tmplist.append((tmp,x)) |
tmplist.append((tmp,x)) |
|
|
if not sortFieldMD: |
if not sortFieldMD: |
Line 454 def checkDiffs(self,metadict):
|
Line 586 def checkDiffs(self,metadict):
|
return diffs |
return diffs |
|
|
|
|
def zptFile(self, path): |
def zptFile(self, path, orphaned=False): |
"""returns a page template file from the product""" |
"""returns a page template file from the product""" |
|
if orphaned: |
|
# unusual case |
|
pt=PageTemplateFile(os.path.join(package_home(globals()), path)) |
|
else: |
pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self) |
return pt |
return pt |
|
|
|
|
def sendFile(self, filename, type): |
def findObjectPath(startobject, filename): |
"""sends an object or a local file (in the product) as response""" |
"""returns the object with the name filename starting at startobject""" |
|
if startobject is None: |
|
return None |
paths = filename.split('/') |
paths = filename.split('/') |
object = self |
object = startobject |
# look for an object called filename |
|
for path in paths: |
for path in paths: |
if hasattr(object, path): |
if hasattr(object, path): |
object = getattr(object, path) |
object = getattr(object, path) |
else: |
else: |
object = None |
object = None |
break |
break |
|
return object |
|
|
|
|
|
def zptObjectOrFile(self, filename, localdir='zpt', orphaned=False): |
|
"""returns a page template instance or a file from the product""" |
|
# look for an object called path |
|
pt = findObjectPath(self, filename) |
|
# the object should also not be a python function |
|
if (pt is None) or isinstance(pt, types.FunctionType): |
|
# get a ZPT file |
|
pt = zptFile(self, localdir+'/'+filename, orphaned=orphaned) |
|
return pt |
|
|
|
|
|
def sendFile(self, filename, type): |
|
"""sends an object or a local file (in the product) as response""" |
|
# look for an object called filename |
|
object = findObjectPath(self, filename) |
if object: |
if object: |
# if the object exists then send it |
# if the object exists then send it |
return object.index_html(self.REQUEST.REQUEST, self.REQUEST.RESPONSE) |
return object.index_html(self.REQUEST.REQUEST, self.REQUEST.RESPONSE) |