version 1.85, 2007/08/15 11:05:43
|
version 1.103.2.4, 2012/01/19 19:03:28
|
Line 11 from OFS.SimpleItem import SimpleItem
|
Line 11 from OFS.SimpleItem import SimpleItem
|
from Globals import package_home |
from Globals import package_home |
import Globals |
import Globals |
from AccessControl import ClassSecurityInfo |
from AccessControl import ClassSecurityInfo |
|
from Acquisition import aq_parent,aq_chain,aq_base |
import os.path |
import os.path |
from OFS.Folder import Folder |
from OFS.Folder import Folder |
import ECHO_collection |
import ECHO_collection |
import base64 |
import base64 |
import bz2 |
import bz2 |
import xmlrpclib |
import xmlrpclib |
|
import sys |
import logging |
import logging |
|
#import amara |
|
|
#erstzt logging |
#erstzt logging |
def logger(txt,method,txt2): |
def logger(txt,method,txt2): |
"""logging""" |
"""logging""" |
logging.info(txt+ txt2) |
logging.info(txt+ txt2) |
|
|
displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','ECHO_movie'] |
displayTypes = ['ZSQLExtendFolder','ZSQLBibliography','ECHO_group','ECHO_collection','ECHO_resource','ECHO_link','ECHO_sqlElement','ECHO_pageTemplate','ECHO_externalLink','ImageCollectionIFrame','VLP_resource','VLP_essay','ECHO_ZCatalogElement','ImageCollection','versionedFileFolder','extVersionedFileFolder','ECHO_movie'] |
|
|
|
def normalizeCt(str): |
|
"""normalizes content_type""" |
|
#str= str.replace(" ","_") |
|
return str.replace("-"," ").lower() |
|
|
#decode and compress for xmlrpc communication with OSAS_server |
#decode and compress for xmlrpc communication with OSAS_server |
|
|
Line 66 def content_html(self,type):
|
Line 72 def content_html(self,type):
|
# return templates[0][1]() |
# return templates[0][1]() |
|
|
if hasattr(self,type+"_template"): |
if hasattr(self,type+"_template"): |
logging.info("type: %s"%type) |
|
obj=getattr(self,type+"_template") |
obj=getattr(self,type+"_template") |
return obj() |
return obj() |
else: |
else: |
Line 84 class ECHO_basis:
|
Line 90 class ECHO_basis:
|
management_page_charset="utf-8" |
management_page_charset="utf-8" |
isVisible = True |
isVisible = True |
|
|
|
# Managment for the PID |
|
def setPID(self,pid): |
|
"""set the pid""" |
|
logging.debug(self.getId()+" PID set to "+pid) |
|
self.pid=pid |
|
return True |
|
|
|
def getPID(self): |
|
"""get the pid""" |
|
|
|
pid =getattr(self,'pid',None) |
|
|
|
if pid == self.getParentPID(): |
|
return None |
|
else: |
|
return pid |
|
|
|
|
|
def getParentPID(self): |
|
"""get the PID of the parent""" |
|
parent = self.aq_parent |
|
|
|
pidF = getattr(parent,'getPID',None) |
|
|
|
if pidF is None: |
|
return None |
|
|
|
else: |
|
return pidF() |
|
|
def unicodify(self, s): |
def unicodify(self, s): |
"""return unicode object for string (utf-8 or latin1) or unicode object s""" |
"""return unicode object for string (utf-8 or latin1) or unicode object s""" |
return unicodify(s) |
return unicodify(s) |
|
|
|
# compatibility of old decode method |
|
decode = unicodify |
|
|
|
|
def utf8ify(self, s): |
def utf8ify(self, s): |
"""return utf-8 encoded string object for string or unicode object s""" |
"""return utf-8 encoded string object for string or unicode object s""" |
return utf8ify(s) |
return utf8ify(s) |
|
|
|
def getBrowserType(self): |
|
"""returns browserType object""" |
|
return browserType(self) |
|
|
def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): |
def manage_addECHO_locale(self,lang,title,label,text=None,content_type=None,RESPONSE=None): |
return ECHO_collection.manage_addECHO_locale(self,lang,title,label) |
return ECHO_collection.manage_addECHO_locale(self,lang,title,label) |
Line 106 class ECHO_basis:
|
Line 147 class ECHO_basis:
|
def showRDF(self): |
def showRDF(self): |
"""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#" |
|
xmlns:MPIWG="http://www.mpiwg-berlin.mpg.de/ns/mpiwg">\n""" |
|
|
ret+=self.getRDF(urn="echo:collectionroot")+"\n" |
ret+=self.getRDF(urn="echo:collectionroot")+"\n" |
|
|
|
|
ret+="""</RDF:RDF>""" |
ret+="""</rdf:rdf>""" |
return ret |
return ret |
|
|
|
|
def RDF(self): |
def RDF(self): |
"""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=self.absolute_url())+"\n" |
ret+=self.getRDF(urn=self.absolute_url())+"\n" |
|
|
|
|
ret+="""</RDF:RDF>""" |
ret+="""</rdf:rdf>""" |
return ret |
return ret |
|
|
|
|
Line 133 class ECHO_basis:
|
Line 175 class ECHO_basis:
|
urn=self.absolute_url() |
urn=self.absolute_url() |
ret="" |
ret="" |
|
|
rettemp="""<RDF:Seq RDF:about="%s">\n"""%urn |
rettemp="""<rdf:Seq rdf:about="%s">\n"""%urn |
flag=0 |
flag=0 |
|
|
li="""<RDF:li RDF:resource="%s" />\n""" |
li="""<rdf:li rdf:resource="%s" />\n""" |
if not ('<error>' in self.getFullTextXML(noredirect='Yes')): |
if not ('<error>' in self.getFullTextXML(noredirect='Yes')): |
nurn=self.absolute_url()+'/getFullTextXML' |
nurn=self.absolute_url()+'/getFullTextXML' |
rettemp+=li%nurn |
rettemp+=li%nurn |
Line 152 class ECHO_basis:
|
Line 194 class ECHO_basis:
|
rettemp+=li%nurn |
rettemp+=li%nurn |
flag=1 |
flag=1 |
|
|
rettemp+="</RDF:Seq>" |
rettemp+="</rdf:Seq>" |
|
|
if flag==1: |
if flag==1: |
ret+=rettemp |
ret+=rettemp |
Line 169 class ECHO_basis:
|
Line 211 class ECHO_basis:
|
nurn=self.absolute_url()+'/showMetaDataXML' |
nurn=self.absolute_url()+'/showMetaDataXML' |
ret+=getRDFDescription(self,self.absolute_url()+'/showMetaDataXML',urn=nurn,nameDef="Metadata",typeName="ECHO_metaData") |
ret+=getRDFDescription(self,self.absolute_url()+'/showMetaDataXML',urn=nurn,nameDef="Metadata",typeName="ECHO_metaData") |
|
|
return ret |
|
|
|
|
return ret |
def content_html_XMLRpc(self): |
def content_html_XMLRpc(self): |
"""xml_rpc_version""" |
"""xml_rpc_version""" |
return encodeRPC(self.content_html()) |
return encodeRPC(self.content_html()) |
Line 204 class ECHO_basis:
|
Line 246 class ECHO_basis:
|
return self.isVisible |
return self.isVisible |
return True |
return True |
|
|
|
def getDescription(self): |
|
"""get content of description field""" |
|
|
|
|
|
return self.unicodify(getattr(self,'description','')); |
|
|
def getTitle(self): |
def getTitle(self): |
"""title""" |
"""title""" |
if hasattr(self,'getLanguage'): |
if hasattr(self,'getLanguage'): |
Line 280 class ECHO_basis:
|
Line 328 class ECHO_basis:
|
def getOverview(self): |
def getOverview(self): |
"""map overview graphics""" |
"""map overview graphics""" |
#return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1] |
#return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1] |
if self.hasOverview(): |
return getattr(self, 'overview', None) |
return getattr(self, 'overview') |
|
return None |
|
|
|
def getMapAreas(self): |
def getMapAreas(self): |
"""returns the list of MapAreas""" |
"""returns the list of MapAreas""" |
Line 397 class ECHO_basis:
|
Line 443 class ECHO_basis:
|
|
|
def createMapImg(self): |
def createMapImg(self): |
"""generate img-tag for map""" |
"""generate img-tag for map""" |
bt = BrowserCheck(self) |
bt = browserType(self) |
tag = "" |
tag = "" |
src = self.getOverview().absolute_url() |
src = self.getOverview().absolute_url() |
if bt.isN4: |
if bt['isN4']: |
# N4 needs ilayer to create an id |
# 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: |
Line 414 class ECHO_basis:
|
Line 460 class ECHO_basis:
|
|
|
def createMapLink(self, ob, text=None, target="_blank"): |
def createMapLink(self, ob, text=None, target="_blank"): |
"""generate map link""" |
"""generate map link""" |
bt = BrowserCheck(self) |
bt = browserType(self) |
id = ob.getFullId() |
id = ob.getFullId() |
link = ob.getLinkId() |
url = ob.getTargetUrl() |
|
if url == "": |
|
# ECHOResource with empty link -> no link |
|
href = 'href="#" onclick="return false;"' |
|
else: |
|
href = 'href="%s"'%ob.getLinkId() |
|
|
|
if target is None: |
|
targetattr = "" |
|
else: |
|
targetattr = 'target="%s"'%target |
|
|
if text is None: |
if text is None: |
text = ob.getLabel() |
text = ob.getLabel() |
|
|
if text is None: |
if text is None: |
text = "link" |
text = "link" |
|
|
tiptext = ob.getTip() |
tiptext = ob.getTip() |
tag = "" |
tag = "" |
if bt.isN4: |
if bt['isN4']: |
# N4 needs layer for highlighting |
# N4 needs layer for highlighting |
tag += '<ilayer id="a.%s"><a class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="%s"'%(id,id,id,link,target) |
tag += '<ilayer id="a.%s"><a class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" %s %s'%(id,id,id,href,targetattr) |
tag += ">" + text + "</a></ilayer>" |
tag += ">" + text + "</a></ilayer>" |
else: |
else: |
# a-element |
# a-element |
tag = '<a id="a.%s" class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="%s"'%(id,id,id,link,target) |
tag = '<a id="a.%s" class="maplink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" %s %s'%(id,id,id,href,targetattr) |
if tiptext: |
if tiptext: |
tag += ' title="%s"'%tiptext |
tag += ' title="%s"'%tiptext |
tag += ">" + text + "</a>" |
tag += ">" + text + "</a>" |
Line 437 class ECHO_basis:
|
Line 496 class ECHO_basis:
|
|
|
def createMapAux(self, ob, arrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil", circlesrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/kreis", target="_blank",backLink=None,alternativArrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil_blau"): |
def createMapAux(self, ob, arrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil", circlesrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/kreis", target="_blank",backLink=None,alternativArrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil_blau"): |
"""generate map link image, text and other stuff""" |
"""generate map link image, text and other stuff""" |
bt = BrowserCheck(self) |
bt = browserType(self) |
id = ob.getFullId() |
id = ob.getFullId() |
link = ob.getLinkId() |
link = ob.getLinkId() |
|
url = ob.getTargetUrl() |
|
if url == "": |
|
# ECHOResource with empty link -> no link |
|
href = 'href="#" onclick="return false;"' |
|
else: |
|
href = 'href="%s"'%ob.getLinkId() |
|
|
|
if target is None: |
|
targetattr = "" |
|
else: |
|
targetattr = 'target="%s"'%target |
tiptext = ob.getTip() |
tiptext = ob.getTip() |
tag = "" |
tag = "" |
|
|
if bt.isN4: |
if bt['isN4']: |
# |
# |
# N4 needs layer and img elements |
# N4 needs layer and img elements |
# |
# |
Line 465 class ECHO_basis:
|
Line 535 class ECHO_basis:
|
|
|
if float(rot) < 0: |
if float(rot) < 0: |
marksrc = circlesrc |
marksrc = circlesrc |
tag += '<a href="%s"><img border="0" src="%s&rot=%s" /></a>'%(link,marksrc,rot) |
tag += '<a %s><img border="0" src="%s&rot=%s" /></a>'%(href,marksrc,rot) |
elif ob.isTypeText(): |
elif ob.isTypeText(): |
# N4 - Text |
# N4 - Text |
tag += '<div id="t.%s" class="maptext"'%(id) |
tag += '<div id="t.%s" class="maptext"'%(id) |
Line 474 class ECHO_basis:
|
Line 544 class ECHO_basis:
|
tag += '</div>' |
tag += '</div>' |
else: |
else: |
# N4 - Area |
# N4 - Area |
tag += '<a href="%s"><img border="0" width="1000" height="1000" src="trans_img"'%(link) |
tag += '<a %s><img border="0" width="1000" height="1000" src="trans_img"'%(href) |
if tiptext: |
if tiptext: |
tag += ' alt="%s"'%tiptext |
tag += ' alt="%s"'%tiptext |
tag += ' /></a>' |
tag += ' /></a>' |
Line 483 class ECHO_basis:
|
Line 553 class ECHO_basis:
|
# |
# |
# (more or less) DOM capable browser |
# (more or less) DOM capable browser |
# |
# |
tag = '<a id="b.%s" class="mapmarklink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="%s">'%(id,id,id,link,target) |
tag = '<a id="b.%s" class="mapmarklink" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" %s %s>'%(id,id,id,href,targetattr) |
if ob.isTypeArrow(): |
if ob.isTypeArrow(): |
# DOM - Arrow |
# DOM - Arrow |
rot = ob.angle |
rot = ob.angle |
Line 506 class ECHO_basis:
|
Line 576 class ECHO_basis:
|
|
|
if float(rot) < 0: |
if float(rot) < 0: |
marksrc = circlesrc |
marksrc = circlesrc |
if bt.isIEWin and bt.versIE > 5: |
if bt['isIEWin'] and bt['versIE'] > 5: |
# IE/Win 5.5 has "feature" for PNG transparency |
# 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,marksrc,rot,marksrc,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,marksrc,rot,marksrc,rot) |
else: |
else: |
Line 521 class ECHO_basis:
|
Line 591 class ECHO_basis:
|
tag += '</div></div>' |
tag += '</div></div>' |
else: |
else: |
# DOM - Area |
# DOM - Area |
if bt.isIE: |
if bt['isIE']: |
# IE needs transparent img for area |
# IE needs transparent img for area |
tag += '<img id="i.%s" border="0" style="position:absolute; top:-100px; left:-100px;" src="trans_img"'%(id) |
tag += '<img id="i.%s" border="0" style="position:absolute; top:-100px; left:-100px;" src="trans_img"'%(id) |
if tiptext: |
if tiptext: |
Line 586 def readFieldFromXML(meta_url,parent,fie
|
Line 656 def readFieldFromXML(meta_url,parent,fie
|
|
|
return getText(field[0].childNodes) |
return getText(field[0].childNodes) |
|
|
|
def readFieldFromXML_xpath(meta_url,xpath): |
|
"""xpath auf meta_url""" |
|
#logging.debug("try to parse:"+meta_url) |
|
#logging.debug("Xtry to parse xpath:"+xpath) |
|
doc = amara.parse(meta_url) |
|
#logging.debug("have:"+doc.xml()) |
|
node= doc.xml_xpath(xpath) |
|
if node is None: |
|
return None |
|
|
|
return unicode(node[0]) |
|
|
def urlopen(url): |
def urlopen(url): |
"""urlopen mit timeout""" |
"""urlopen mit timeout""" |
Line 615 def checkOnlyOneInGroup(object):
|
Line 695 def checkOnlyOneInGroup(object):
|
else: return object |
else: return object |
|
|
|
|
|
|
|
def getCrumb(self): |
|
"""returns breadcrumb for this object""" |
|
# ignore this object if title is empty |
|
if not self.title: |
|
return None |
|
|
|
crumb = {'obj': self, |
|
'url': self.absolute_url(), |
|
'label': self.getLabel()} |
|
return crumb |
|
|
|
# roots of the ECHO hierarchy |
|
rootMetaTypes = ['ECHO_root', 'ECHO_main', 'ECHO_nav'] |
|
|
|
def getHierCrumbs(self): |
|
"""returns a list of hierarchical breadcrumbs from self to the ECHO_root""" |
|
crumbs = [] |
|
# walk the acquisition chain |
|
for obj in aq_chain(self): |
|
#logging.debug("getHiercrumbs: obj=%s"%(obj)) |
|
# test if the object really has a getCrumb method |
|
if hasattr(aq_base(obj), 'getCrumb'): |
|
crumb = obj.getCrumb() |
|
#logging.debug("getHiercrumbs: got %s from %s"%(crumb,obj)) |
|
if crumb is not None: |
|
crumbs.insert(0, crumb) |
|
|
|
if obj.meta_type in rootMetaTypes: |
|
# stop when we reach the ECHO root |
|
return crumbs |
|
|
|
return crumbs |
|
|
|
|
def getSubCols(self, sortfield=None, |
def getSubCols(self, sortfield=None, |
subColTypes=displayTypes, |
subColTypes=displayTypes, |
sortFieldMD=None, |
sortFieldMD=None, |
Line 625 def getSubCols(self, sortfield=None,
|
Line 740 def getSubCols(self, sortfield=None,
|
isVisible=True): |
isVisible=True): |
|
|
def sort(x,y): |
def sort(x,y): |
|
try: |
|
if type(x[0])==type(y[0]): |
return cmp(x[0],y[0]) |
return cmp(x[0],y[0]) |
|
else: |
|
if type(x[0])==types.StringType: |
|
tmpX=unicodify(x[0]) |
|
tmpY=y[0] |
|
else: |
|
tmpY=unicodify(y[0]) |
|
tmpX=x[0] |
|
return cmp(tmpX,tmpY) |
|
|
|
except: |
|
logging.error("Error at ECHO_helpers.sort:AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA") |
|
logging.error(" : %s %s"%sys.exc_info()[0:2]) |
|
logging.error("Error at ECHO_helpers.sort:"+repr(x)+"--"+repr(type(x[0]))) |
|
logging.error("Error at ECHO_helpers.sort:"+repr(y)+"--"+repr(type(y[0]))) |
|
logging.error("Error at ECHO_helpers.sort:BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB") |
|
return 0 |
def sortfnc(sortfield,x,y): |
def sortfnc(sortfield,x,y): |
try: |
try: |
xa=x[1].getMDValue(sortfield,generic=generic) |
xa=x[1].getMDValue(sortfield,generic=generic) |
Line 704 def ECHO_rerenderLinksMD(self,obj=None,t
|
Line 836 def ECHO_rerenderLinksMD(self,obj=None,t
|
if entry[1].meta_type == 'ECHO_resource': |
if entry[1].meta_type == 'ECHO_resource': |
try: |
try: |
entry[1].ECHO_getResourceMD(template="no",overwrite="yes") |
entry[1].ECHO_getResourceMD(template="no",overwrite="yes") |
|
logging.debug("ECHO_rerenderLinksMD: gotMD") |
if "title" in types: |
if "title" in types: |
entry[1].generate_title() |
entry[1].generate_title() |
|
logging.debug("ECHO_rerenderLinksMD: generatedTitle") |
if "label" in types: |
if "label" in types: |
entry[1].generate_label() |
entry[1].generate_label() |
ret+="OK:"+entry[0]+"-- "+entry[1].getTitle().decode('utf-8')+"-- "+entry[1].getTitle().decode('utf-8')+"<br>" |
logging.debug("ECHO_rerenderLinksMD: generatedLabel") |
|
ret+="OK:"+entry[0]+"-- "+self.unicodify(entry[1].getTitle())+"-- "+self.unicodify(entry[1].getTitle())+"<br>" |
except: |
except: |
ret+="Error:"+entry[0]+"<br>" |
|
|
|
|
ret+="Error:"+entry[0]+"<br>" |
|
logging.debug("ECHO_rerenderLinksMD: error") |
|
logging.debug("%s %s"%(sys.exc_info()[0],sys.exc_info()[1])) |
|
|
|
|
|
|
return "<html><body>"+ret+"Rerenderd all links to resources in: "+self.title+"</html></body>" |
return "<html><body>"+ret+"Rerenderd all links to resources in: "+self.title+"</html></body>" |
|
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
|
"""copy metadata from the storage to ECHO""" |
|
ret="" |
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
if RESPONSE is not None: |
|
RESPONSE.setHeader("Content-Type", type) |
|
RESPONSE.write("<html><body>\n") |
|
|
|
for resource in resources: |
|
x=str(resource[1].copyIndex_meta2echo_resource())+"<br>" |
|
if RESPONSE is not None: |
|
RESPONSE.write(x+"\n") |
|
|
|
ret+=x |
def getRDFDescription(self,linkURL,urn=None,nameDef=None,typeName=None,ap=""): |
|
"""rdf""" |
|
|
if RESPONSE is not None: |
ret="" |
#RESPONSE.redirect('./manage_main') |
about="""<rdf:Description rdf:about="%s">""" |
RESPONSE.write( "</html></body>") |
name="""<echonavigation:name>%s</echonavigation:name>""" |
|
link="""<echonavigation:link xlink:href="%s">%s</echonavigation:link>""" |
|
clickable="""<echonavigation:linkClickable>%s</echonavigation:linkClickable>""" |
|
#link="""<echonavigation:link rdf:about="%s"/>""" |
|
type="""<echonavigation:type>%s</echonavigation:type>""" |
|
|
return ret |
#xlink="""<echonavigation:xlink xlink:href="%s"/>""" |
|
|
def getRDFDescription(self,linkURL,urn=None,nameDef=None,typeName=None): |
if ap=="": |
"""rdf""" |
ap2="" |
|
else: |
|
ap2 = """<mpiwg:archive-path>%s</mpiwg:archive-path>"""%ap |
|
|
ret="" |
|
about="""<RDF:Description RDF:about="%s">""" |
|
name="""<ECHONAVIGATION:name>%s</ECHONAVIGATION:name>""" |
|
link="""<ECHONAVIGATION:link xlink:href="%s">%s</ECHONAVIGATION:link>""" |
|
clickable="""<ECHONAVIGATION:linkClickable>%s</ECHONAVIGATION:linkClickable>""" |
|
#link="""<ECHONAVIGATION:link RDF:about="%s"/>""" |
|
type="""<ECHONAVIGATION:type>%s</ECHONAVIGATION:type>""" |
|
#xlink="""<ECHONAVIGATION:xlink xlink:href="%s"/>""" |
|
if not urn: |
if not urn: |
#urn="urn:"+re.sub('/',':',self.absolute_url()) |
#urn="urn:"+re.sub('/',':',self.absolute_url()) |
urn=self.absolute_url() |
urn=self.absolute_url() |
Line 775 def getRDFDescription(self,linkURL,urn=N
|
Line 900 def getRDFDescription(self,linkURL,urn=N
|
else: |
else: |
type2=type%typeName |
type2=type%typeName |
|
|
#ret=about2+"\n"+name2+"\n"+link2+"\n"+type2+"\n"+clickable2+"\n</RDF:Description>" |
|
ret=about2+"\n"+name2+"\n"+type2+"\n"+clickable2+"\n</RDF:Description>" |
|
|
#ret=about2+"\n"+name2+"\n"+link2+"\n"+type2+"\n"+clickable2+"\n</rdf:Description>" |
|
try: |
|
ret=about2+"\n"+name2+"\n"+type2+"\n"+clickable2+"\n"+ap2+"\n</rdf:Description>" |
|
except: |
|
ret=self.unicodify(about2)+"\n"+self.unicodify(name2)+"\n"+self.unicodify(type2)+"\n"+self.unicodify(clickable2)+"\n"+self.unicodify(ap2)+"\n</rdf:Description>" |
|
|
return ret |
return ret |
|
|
def getCopyrightsFromForm(self,argv): |
def getCopyrightsFromForm(self,argv): |
Line 902 def sendFile(self, filename, type):
|
Line 1033 def sendFile(self, filename, type):
|
return |
return |
|
|
|
|
class BrowserCheck: |
def browserType(zope): |
"""check the browsers request to find out the browser type""" |
"""check the browsers request to find out the browser type""" |
|
bt = {} |
def __init__(self, zope): |
ua = zope.REQUEST.get_header("HTTP_USER_AGENT") |
"""initialisiere""" |
bt['ua'] = ua |
self.ua = zope.REQUEST.get_header("HTTP_USER_AGENT") |
bt['isN4'] = False |
self.isN4 = False |
bt['isIE'] = False |
self.isIE = False |
if string.find(ua, 'MSIE') > -1: |
if string.find(self.ua, 'MSIE') > -1: |
bt['isIE'] = True |
self.isIE = True |
else: |
else: |
bt['isN4'] = string.find(ua, 'Mozilla/4.') > -1 |
self.isN4 = string.find(self.ua, 'Mozilla/4.') > -1 |
try: |
try: |
nav = ua[string.find(ua, '('):] |
self.nav = self.ua[string.find(self.ua, '('):] |
bt['nav'] = nav |
ie = string.split(self.nav, "; ")[1] |
ie = string.split(nav, "; ")[1] |
if string.find(ie, "MSIE") > -1: |
if string.find(ie, "MSIE") > -1: |
self.versIE = string.split(ie, " ")[1] |
bt['versIE'] = string.split(ie, " ")[1] |
except: pass |
except: pass |
self.isMac = string.find(self.ua, 'Macintosh') > -1 |
|
self.isWin = string.find(self.ua, 'Windows') > -1 |
bt['isMac'] = string.find(ua, 'Macintosh') > -1 |
self.isIEWin = self.isIE and self.isWin |
bt['isWin'] = string.find(ua, 'Windows') > -1 |
self.isIEMac = self.isIE and self.isMac |
bt['isIEWin'] = bt['isIE'] and bt['isWin'] |
|
bt['isIEMac'] = bt['isIE'] and bt['isMac'] |
|
return bt |
|
|
|
|
def writeMetadata(url,metadict,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,xmlfrag=None,digiliburlprefix=None): |
def writeMetadata(url,metadict,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,xmlfrag=None,digiliburlprefix=None): |
Line 1045 def writeMetadata(url,metadict,project=N
|
Line 1178 def writeMetadata(url,metadict,project=N
|
|
|
return dom.toxml(encoding='utf-8') |
return dom.toxml(encoding='utf-8') |
|
|
def readMetadata(url): |
|
"""Methode zum Auslesen der Metadateninformation zu einer Resource |
|
Vorerst noch Typ bib""" |
|
|
|
metadict={} |
|
|
|
try: |
|
geturl="" |
|
for line in urlopen(url).readlines(): |
|
geturl=geturl+line |
|
|
|
|
|
except: |
|
return (None,"Cannot open: "+url) |
|
|
|
try: |
|
dom=xml.dom.minidom.parseString(geturl) |
|
except: |
|
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
metanode=dom.getElementsByTagName('bib') |
|
metadict['bib_type']='Book' |
|
if len(metanode)==0: |
|
metanode=dom.getElementsByTagName('archimedes') |
|
metadict['bib_type']='Archimedes' |
|
|
|
|
|
if not len(metanode)==0: |
|
metacontent=metanode[0].childNodes |
|
|
|
try: |
|
metadict['bib_type']=getText(dom.getElementsByTagName('bib')[0].attributes['type'].childNodes) |
|
except: |
|
"""nothing""" |
|
|
|
for node in metacontent: |
|
try: |
|
#print urllib.unquote(getText(node.childNodes)),getText(node.childNodes) |
|
#metadict[re.sub('-','_',node.tagName.lower())]=urllib.unquote(getText(node.childNodes)) |
|
metadict[re.sub('-','_',node.tagName.lower())]=getText(node.childNodes) |
|
|
|
except: |
|
"""nothing""" |
|
|
|
return (metadict,"") |
|
|
|
|
|
class MapArea(SimpleItem): |
class MapArea(SimpleItem): |
"""simple class to hold coordinates""" |
"""simple class to hold coordinates""" |
Line 1209 class MapArea(SimpleItem):
|
Line 1298 class MapArea(SimpleItem):
|
return self.aq_parent.label or self.aq_parent.id |
return self.aq_parent.label or self.aq_parent.id |
return self.label |
return self.label |
|
|
|
def getTargetUrl(self): |
|
"""returns the URL of the linked object""" |
|
if hasattr(self, 'aq_parent'): |
|
p = self.aq_parent |
|
# ECHOResource and ECHOLink have 'link' attribute |
|
if hasattr(p, 'link'): |
|
if p.link is None: |
|
# return empty string for empty link |
|
return "" |
|
else: |
|
return p.link |
|
|
|
# return None for unknown type |
|
return None |
|
|
def setLabel(self, label): |
def setLabel(self, label): |
"""sets the label""" |
"""sets the label""" |
self.label = label |
self.label = label |