version 1.6, 2005/10/26 17:30:26
|
version 1.11, 2007/07/24 09:11:46
|
Line 1
|
Line 1
|
from sys import argv |
from sys import argv |
|
|
import string |
import string |
|
import logging |
import xml.dom.minidom |
import xml.dom.minidom |
import Ft.Xml.XLink.Processor |
import Ft.Xml.XLink.Processor |
import Ft.Xml.XLink.XLinkElements |
import Ft.Xml.XLink.XLinkElements |
Line 15 from Ft.Xml import EMPTY_NAMESPACE
|
Line 16 from Ft.Xml import EMPTY_NAMESPACE
|
from Ft.Lib import Uri |
from Ft.Lib import Uri |
import urllib |
import urllib |
import re |
import re |
|
from ECHO_collection import unicodify,utf8ify |
|
|
patternTXT=r"<\s*txt.*?>(.*?)</txt>" |
patternTXT=r"<\s*txt.*?>(.*?)</txt>" |
regexpTXT = re.compile(patternTXT, re.IGNORECASE + re.DOTALL) |
regexpTXT = re.compile(patternTXT, re.IGNORECASE + re.DOTALL) |
Line 175 def checkRef(self,ref):
|
Line 177 def checkRef(self,ref):
|
'vl_people':'AND complete =\'yes\'', |
'vl_people':'AND complete =\'yes\'', |
'vl_sites':'AND complete =\'yes\'', |
'vl_sites':'AND complete =\'yes\'', |
'vl_transcript':'AND complete =\'yes\'', |
'vl_transcript':'AND complete =\'yes\'', |
'vl_essays':'AND online =\'yes\'' |
'vl_essays':'AND online =\'yes\'', |
|
'vl_categories':'' |
} |
} |
res=None |
res=None |
for db in dbs.keys(): |
for db in dbs.keys(): |
Line 188 def link2html(self,str):
|
Line 191 def link2html(self,str):
|
if str: |
if str: |
|
|
str=re.sub("\&","&",str) |
str=re.sub("\&","&",str) |
dom=xml.dom.minidom.parseString("<?xml version='1.0' encoding='utf-8'?><txt>"+str+"</txt>") |
dom=xml.dom.minidom.parseString("<?xml version='1.0' encoding='utf-8'?><txt>"+utf8ify(str)+"</txt>") |
links=dom.getElementsByTagName("link") |
links=dom.getElementsByTagName("link") |
|
|
|
|
Line 207 def link2html(self,str):
|
Line 210 def link2html(self,str):
|
newxml=dom.toxml('utf-8') |
newxml=dom.toxml('utf-8') |
|
|
retStr=regexpTXT.search(newxml) |
retStr=regexpTXT.search(newxml) |
|
retStr = retStr.group(1) |
|
|
return retStr.group(1) |
return retStr.decode('utf-8') # we return unicode |
|
|
|
return u"" |
|
|
|
def related2html(self,str): |
|
"""related library items: xlinks in html wandeln / mb 22.11.2006""" |
|
if str: |
|
|
|
str=re.sub("\&","&",str) |
|
dom=xml.dom.minidom.parseString("<?xml version='1.0' encoding='utf-8'?><txt>"+str+"</txt>") |
|
links=dom.getElementsByTagName("link") |
|
|
|
for link in links: |
|
link.tagName = "a" |
|
ref = link.getAttribute("ref") |
|
pn = link.getAttribute("page") |
|
|
|
searchStr="select fullreference, online from vl_literature where reference =\'%s\' and authorized = 1"%(ref) |
|
res = self.search(var=searchStr) |
|
|
|
if res: |
|
if res[0]['online'] == 1: |
|
# item online verfuegbar |
|
if pn: |
|
link.setAttribute("href",self.REQUEST['SERVER_URL']+"/references?id="+ref+"&page="+pn) |
|
else: |
|
link.setAttribute("href",self.REQUEST['SERVER_URL']+"/references?id="+ref) |
|
|
|
link.setAttribute("title", "click to view") |
|
link.removeAttribute("ref") |
|
|
|
# prefix preceding the link |
|
prefix = dom.createTextNode(U"\u2013\u0020") # = ndash + space |
|
dom.documentElement.insertBefore(prefix, link) |
|
|
|
else: |
|
# item nur als bibliographische angabe vorhanden |
|
link.setAttribute("alt", res[0]['fullreference'].decode('utf-8')) |
|
link.setAttribute("title", "click to expand") |
|
link.setAttribute("onclick", "return toggle(this);") |
|
link.setAttribute("class", "x_offline") |
|
|
|
# prefix inside link text |
|
link.firstChild.data = '+ ' + link.firstChild.data |
|
|
|
|
|
newxml=dom.toxml('utf-8') |
|
|
|
retStr=regexpTXT.search(newxml) |
|
retStr = retStr.group(1) |
|
|
|
return retStr.decode('utf-8') # we return unicode |
|
|
|
return u"" |
|
|
return "" |
|
|
|
|
|
|
|
Line 257 def xml2html(self,str,quote="yes"):
|
Line 312 def xml2html(self,str,quote="yes"):
|
retStr=regexpPage.search(str) |
retStr=regexpPage.search(str) |
|
|
try: # hack warum fehtl manchmal page?? |
try: # hack warum fehtl manchmal page?? |
return retStr.group(1) |
return retStr.group(1).decode('utf-8') |
except: |
except: |
return str |
return str |
return "" |
return "" |