version 1.31, 2004/12/02 20:11:49
|
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 221 class ECHO_basis:
|
Line 226 class ECHO_basis:
|
"""generate img-tag for map""" |
"""generate img-tag for map""" |
bt = BrowserCheck(self) |
bt = BrowserCheck(self) |
tag = "" |
tag = "" |
#src = self.REQUEST['URL1'] + "/overview" |
|
src = self.getOverview().absolute_url() |
src = self.getOverview().absolute_url() |
if bt.isN4: |
if bt.isN4: |
|
# N4 needs ilayer to create an id |
tag += '<ilayer id="overview" visibility="show"><img src="%s"></ilayer>'%src |
tag += '<ilayer id="overview" visibility="show"><img src="%s"></ilayer>'%src |
else: |
else: |
|
# img with id |
tag += '<img id="overview" src="%s" />'%src |
tag += '<img id="overview" src="%s" />'%src |
return tag |
return tag |
|
|
Line 242 class ECHO_basis:
|
Line 248 class ECHO_basis:
|
text = ob.getLabel() |
text = ob.getLabel() |
if text is None: |
if text is None: |
text = "link" |
text = "link" |
|
tiptext = ob.getText() |
tag = "" |
tag = "" |
if bt.isN4: |
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 += '<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>" |
tag += ">" + text + "</a></ilayer>" |
else: |
else: |
|
# a-element |
tag = '<a id="a.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank"'%(id,id,id,link) |
tag = '<a id="a.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank"'%(id,id,id,link) |
if ob.text: |
if tiptext: |
tag += ' title="%s"'%ob.text |
tag += ' title="%s"'%tiptext |
tag += ">" + text + "</a>" |
tag += ">" + text + "</a>" |
return tag |
return tag |
|
|
Line 262 class ECHO_basis:
|
Line 271 class ECHO_basis:
|
tag = "" |
tag = "" |
|
|
if bt.isN4: |
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) |
tag += '<layer id="i.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)">'%(id,id,id) |
if ob.isTypeArrow(): |
if ob.isTypeArrow(): |
rot = ob.angle |
rot = ob.angle |
Line 273 class ECHO_basis:
|
Line 283 class ECHO_basis:
|
tag += ' /></a>' |
tag += ' /></a>' |
tag += '</layer>' |
tag += '</layer>' |
else: |
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) |
tag = '<a id="b.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank">'%(id,id,id,link) |
if ob.isTypeArrow(): |
if ob.isTypeArrow(): |
rot = ob.angle |
rot = ob.angle |
if bt.isIEWin and bt.versIE > 5: |
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) |
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: |
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) |
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: |
else: |
if bt.isIEWin: |
if bt.isIE: |
tag += '<div id="i.%s" style="position:absolute; top:-100px; left:-100px;background:url(area_img)"'%(id) |
# 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: |
else: |
|
# div for area |
tag += '<div id="i.%s" style="position:absolute; top:-100px; left:-100px;"'%(id) |
tag += '<div id="i.%s" style="position:absolute; top:-100px; left:-100px;"'%(id) |
if tiptext: |
if tiptext: |
tag += ' title="%s"'%tiptext |
tag += ' title="%s"'%tiptext |
Line 297 class ECHO_basis:
|
Line 315 class ECHO_basis:
|
|
|
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 375 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 394 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 567 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) |