version 1.103, 2010/10/11 13:15:00
|
version 1.103.2.3, 2012/01/17 18:39:07
|
Line 19 import bz2
|
Line 19 import bz2
|
import xmlrpclib |
import xmlrpclib |
import sys |
import sys |
import logging |
import logging |
import amara |
#import amara |
|
|
#erstzt logging |
#erstzt logging |
def logger(txt,method,txt2): |
def logger(txt,method,txt2): |
Line 131 class ECHO_basis:
|
Line 131 class ECHO_basis:
|
"""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 324 class ECHO_basis:
|
Line 327 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 441 class ECHO_basis:
|
Line 442 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 458 class ECHO_basis:
|
Line 459 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() |
url = ob.getTargetUrl() |
url = ob.getTargetUrl() |
if url == "": |
if url == "": |
Line 480 class ECHO_basis:
|
Line 481 class ECHO_basis:
|
|
|
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)" %s %s'%(id,id,id,href,targetattr) |
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>" |
Line 494 class ECHO_basis:
|
Line 495 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() |
url = ob.getTargetUrl() |
Line 511 class ECHO_basis:
|
Line 512 class ECHO_basis:
|
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 574 class ECHO_basis:
|
Line 575 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 589 class ECHO_basis:
|
Line 590 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 817 def ECHO_rerenderLinksMD(self,obj=None,t
|
Line 818 def ECHO_rerenderLinksMD(self,obj=None,t
|
|
|
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 |
|
|
|
if RESPONSE is not None: |
|
#RESPONSE.redirect('./manage_main') |
|
RESPONSE.write( "</html></body>") |
|
|
|
return ret |
|
|
|
def getRDFDescription(self,linkURL,urn=None,nameDef=None,typeName=None,ap=""): |
def getRDFDescription(self,linkURL,urn=None,nameDef=None,typeName=None,ap=""): |
"""rdf""" |
"""rdf""" |
Line 1015 def sendFile(self, filename, type):
|
Line 997 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 1158 def writeMetadata(url,metadict,project=N
|
Line 1142 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): |