|
|
| version 1.130, 2010/10/18 09:57:47 | version 1.153, 2010/11/08 14:59:40 |
|---|---|
| Line 18 import math | Line 18 import math |
| import urlparse | import urlparse |
| import cStringIO | import cStringIO |
| import re | import re |
| import string | |
| def logger(txt,method,txt2): | def logger(txt,method,txt2): |
| """logging""" | """logging""" |
| Line 51 def serializeNode(node, encoding='utf-8' | Line 51 def serializeNode(node, encoding='utf-8' |
| buf.close() | buf.close() |
| return s | return s |
| def getBrowserType(self): | def browserCheck(self): |
| """get browser type object""" | """check the browsers request to find out the browser type""" |
| if self.REQUEST.SESSION.has_key('browserType'): | bt = {} |
| return self.REQUEST.SESSION['browserType'] | ua = self.REQUEST.get_header("HTTP_USER_AGENT") |
| else: | bt['ua'] = ua |
| bt = browserCheck(self) | bt['isIE'] = False |
| self.REQUEST.SESSION.set('browserType', bt) | bt['isN4'] = False |
| logging.debug("documentViewer (BROWSER TYPE) bt %s"%bt) | if string.find(ua, 'MSIE') > -1: |
| bt['isIE'] = True | |
| else: | |
| bt['isN4'] = (string.find(ua, 'Mozilla/4.') > -1) | |
| try: | |
| nav = ua[string.find(ua, '('):] | |
| ie = string.split(nav, "; ")[1] | |
| if string.find(ie, "MSIE") > -1: | |
| bt['versIE'] = string.split(ie, " ")[1] | |
| except: pass | |
| bt['isMac'] = string.find(ua, 'Macintosh') > -1 | |
| bt['isWin'] = string.find(ua, 'Windows') > -1 | |
| bt['isIEWin'] = bt['isIE'] and bt['isWin'] | |
| bt['isIEMac'] = bt['isIE'] and bt['isMac'] | |
| bt['staticHTML'] = False | |
| return bt | return bt |
| Line 182 class documentViewer(Folder): | Line 199 class documentViewer(Folder): |
| """get query""" | """get query""" |
| return self.template.fulltextclient.getQuery(**args) | return self.template.fulltextclient.getQuery(**args) |
| def getPDF(self, **args): | |
| """get query""" | |
| return self.template.fulltextclient.getPDF(**args) | |
| def getSearch(self, **args): | def getSearch(self, **args): |
| """get search""" | """get search""" |
| return self.template.fulltextclient.getSearch(**args) | return self.template.fulltextclient.getSearch(**args) |
| Line 243 class documentViewer(Folder): | Line 264 class documentViewer(Folder): |
| self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary" | self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary" |
| docinfo = self.getDocinfo(mode=mode,url=url) | docinfo = self.getDocinfo(mode=mode,url=url) |
| #pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo) | |
| pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo) | pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo) |
| #pageinfo = self.getPageinfo(start=start,current=pn, originalPage=originalPage, docinfo=docinfo) | |
| ''' ZDES ''' | ''' ZDES ''' |
| pt = getattr(self.template, 'thumbs_main_rss') | pt = getattr(self.template, 'thumbs_main_rss') |
| Line 257 class documentViewer(Folder): | Line 278 class documentViewer(Folder): |
| return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) | return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) |
| security.declareProtected('View','index_html') | security.declareProtected('View','index_html') |
| def index_html(self,url,mode="texttool",viewMode="auto",tocMode="thumbs",start=None,pn=1,mk=None, query=None, querySearch=None, characterNormalization=""): | def index_html(self,url,mode="texttool",viewMode="auto",tocMode="thumbs",start=None,pn=1,mk=None, query=None, querySearch=None, characterNormalization="", optionsClose=None): |
| ''' | ''' |
| view it | view it |
| @param mode: defines how to access the document behind url | @param mode: defines how to access the document behind url |
| Line 306 class documentViewer(Folder): | Line 327 class documentViewer(Folder): |
| return ret | return ret |
| def getBrowser(self): | |
| """getBrowser the version of browser """ | |
| names="" | |
| names = browserCheck(self) | |
| #logging.debug("XXXXXXXXXXXXXXXX: %s"%names) | |
| return names | |
| def findDigilibUrl(self): | def findDigilibUrl(self): |
| """try to get the digilib URL from zogilib""" | """try to get the digilib URL from zogilib""" |
| url = self.template.zogilib.getDLBaseUrl() | url = self.template.zogilib.getDLBaseUrl() |
| Line 369 class documentViewer(Folder): | Line 397 class documentViewer(Folder): |
| pt = getattr(self.template, 'info_xml') | pt = getattr(self.template, 'info_xml') |
| return pt(docinfo=docinfo) | return pt(docinfo=docinfo) |
| def getOptionToggle(self, newState=None, optionName='text_options_open', initialState=True): | |
| """returns new option state""" | |
| opt = self.REQUEST.SESSION.get(optionName,None) | |
| if opt is None: | |
| # not in session -- initial | |
| opt = {'lastState': newState, 'state': initialState} | |
| else: | |
| if opt['lastState'] != newState: | |
| # state in session has changed -- toggle | |
| opt['state'] = not opt['state'] | |
| opt['lastState'] = newState | |
| self.REQUEST.SESSION[optionName] = opt | |
| return opt['state'] | |
| def isAccessible(self, docinfo): | def isAccessible(self, docinfo): |
| """returns if access to the resource is granted""" | """returns if access to the resource is granted""" |
| Line 662 class documentViewer(Folder): | Line 704 class documentViewer(Folder): |
| presentationUrls = dom.xpath("//texttool/presentation") | presentationUrls = dom.xpath("//texttool/presentation") |
| docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag | docinfo = self.getBibinfoFromIndexMeta(url, docinfo=docinfo, dom=dom) # get info von bib tag |
| docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom) | docinfo = self.getNameFromIndexMeta(url, docinfo=docinfo, dom=dom) |
| docinfo =self.getOrigPages(docinfo=docinfo, pageinfo=pageinfo) | |
| if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen | if presentationUrls and (len(presentationUrls) > 0): # ueberschreibe diese durch presentation informationen |
| # presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten | # presentation url ergiebt sich ersetzen von index.meta in der url der fuer die Metadaten |
| Line 743 class documentViewer(Folder): | Line 785 class documentViewer(Folder): |
| raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) | raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode)) |
| logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo) | logging.debug("documentViewer (getdocinfo) docinfo: %s"%docinfo) |
| #logging.debug("documentViewer (getdocinfo) docinfo: %s"%) | |
| self.REQUEST.SESSION['docinfo'] = docinfo | self.REQUEST.SESSION['docinfo'] = docinfo |
| return docinfo | return docinfo |
| Line 750 class documentViewer(Folder): | Line 793 class documentViewer(Folder): |
| """returns pageinfo with the given parameters""" | """returns pageinfo with the given parameters""" |
| pageinfo = {} | pageinfo = {} |
| current = getInt(current) | current = getInt(current) |
| #pageinfo ['originalPage'] = originalPage | |
| pageinfo['current'] = current | pageinfo['current'] = current |
| rows = int(rows or self.thumbrows) | rows = int(rows or self.thumbrows) |
| pageinfo['rows'] = rows | pageinfo['rows'] = rows |
| Line 770 class documentViewer(Folder): | Line 813 class documentViewer(Folder): |
| pageinfo['numgroups'] += 1 | pageinfo['numgroups'] += 1 |
| pageinfo['viewMode'] = viewMode | pageinfo['viewMode'] = viewMode |
| pageinfo['tocMode'] = tocMode | pageinfo['tocMode'] = tocMode |
| #pageinfo['characterNormalization'] =characterNormalization | |
| pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization',' ') | pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization',' ') |
| pageinfo['query'] = self.REQUEST.get('query',' ') | pageinfo['query'] = self.REQUEST.get('query',' ') |
| pageinfo['optionsClose']= self.REQUEST.get('optionsClose','') | |
| pageinfo['queryType'] = self.REQUEST.get('queryType',' ') | pageinfo['queryType'] = self.REQUEST.get('queryType',' ') |
| pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') | pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext') |
| pageinfo['textPN'] = self.REQUEST.get('textPN','1') | pageinfo['textPN'] = self.REQUEST.get('textPN','1') |