Diff for /documentViewer/documentViewer.py between versions 1.43 and 1.61

version 1.43, 2010/03/19 11:42:40 version 1.61, 2010/05/21 14:36:17
Line 2 Line 2
 from OFS.Folder import Folder  from OFS.Folder import Folder
 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate  from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile   from Products.PageTemplates.PageTemplateFile import PageTemplateFile 
   from Products.PythonScripts.standard import url_quote
 from AccessControl import ClassSecurityInfo  from AccessControl import ClassSecurityInfo
 from AccessControl import getSecurityManager  from AccessControl import getSecurityManager
 from Globals import package_home  from Globals import package_home
Line 10  from Ft.Xml.Domlette import Nonvalidatin Line 11  from Ft.Xml.Domlette import Nonvalidatin
 from Ft.Xml.Domlette import PrettyPrint, Print  from Ft.Xml.Domlette import PrettyPrint, Print
 from Ft.Xml import EMPTY_NAMESPACE, Parse  from Ft.Xml import EMPTY_NAMESPACE, Parse
   
   from xml.dom.minidom import parse, parseString
   
   
   
 import Ft.Xml.XPath  import Ft.Xml.XPath
 import cStringIO  import cStringIO
Line 87  class documentViewer(Folder): Line 91  class documentViewer(Folder):
   
     # templates and forms      # templates and forms
     viewer_main = PageTemplateFile('zpt/viewer_main', globals())      viewer_main = PageTemplateFile('zpt/viewer_main', globals())
     thumbs_main = PageTemplateFile('zpt/thumbs_main', globals())      toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals())
     image_main = PageTemplateFile('zpt/image_main', globals()) # obsolete!      toc_text = PageTemplateFile('zpt/toc_text', globals())
       toc_figures = PageTemplateFile('zpt/toc_figures', globals())
     page_main_images = PageTemplateFile('zpt/page_main_images', globals())      page_main_images = PageTemplateFile('zpt/page_main_images', globals())
     page_main_text = PageTemplateFile('zpt/page_main_text', globals())      page_main_text = PageTemplateFile('zpt/page_main_text', globals())
       page_main_text_dict = PageTemplateFile('zpt/page_main_text_dict', globals())
       page_main_xml = PageTemplateFile('zpt/page_main_xml', globals())
     head_main = PageTemplateFile('zpt/head_main', globals())      head_main = PageTemplateFile('zpt/head_main', globals())
     docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())      docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())
     info_xml = PageTemplateFile('zpt/info_xml', globals())      info_xml = PageTemplateFile('zpt/info_xml', globals())
Line 100  class documentViewer(Folder): Line 107  class documentViewer(Folder):
     changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals())      changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals())
   
           
     def __init__(self,id,imageScalerUrl=None,textServerName=None,title="",digilibBaseUrl=None,thumbcols=2,thumbrows=10,authgroups="mpiwg"):      def __init__(self,id,imageScalerUrl=None,textServerName=None,title="",digilibBaseUrl=None,thumbcols=2,thumbrows=5,authgroups="mpiwg"):
         """init document viewer"""          """init document viewer"""
         self.id=id          self.id=id
         self.title=title          self.title=title
Line 161  class documentViewer(Folder): Line 168  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",start=None,pn=1,mk=None):      def index_html(self,url,mode="texttool",viewMode="auto",tocMode="thumbs",start=None,pn=1,mk=None, query=None, querySearch=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 
         @param url: url which contains display information          @param url: url which contains display information
         @param viewMode: if images display images, if text display text, default is images (text,images or auto)          @param viewMode: if images display images, if text display text, default is auto (text,images or auto)
                   @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none)
           @param querySearch: type of different search modes (fulltext, fulltextMorph, xpath, xquery, ftIndex, ftIndexMorph, fulltextMorphLemma)
         '''          '''
                   
         logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))          logging.debug("documentViewer (index) mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
Line 181  class documentViewer(Folder): Line 189  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)          
         pt = getattr(self.template, 'viewer_main')          
           if tocMode != "thumbs":
               # get table of contents
               docinfo = self.getToc(mode=tocMode, docinfo=docinfo)
               
           pageinfo = self.getPageinfo(start=start,current=pn,docinfo=docinfo,viewMode=viewMode,tocMode=tocMode)
                   
         if viewMode=="auto": # automodus gewaehlt          if viewMode=="auto": # automodus gewaehlt
             if docinfo.get("textURL",''): #texturl gesetzt und textViewer konfiguriert              if docinfo.get("textURL",''): #texturl gesetzt und textViewer konfiguriert
Line 190  class documentViewer(Folder): Line 203  class documentViewer(Folder):
             else:              else:
                 viewMode="images"                  viewMode="images"
                                 
           pt = getattr(self.template, 'viewer_main')               
         return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk))          return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode,mk=self.generateMarks(mk))
       
     def generateMarks(self,mk):      def generateMarks(self,mk):
         ret=""          ret=""
     if mk is None:      if mk is None:
         return ""          return ""
       
     if type(mk) is not ListType:      if type(mk) is not ListType:
         mk=[mk]          mk=[mk]
         for m in mk:          for m in mk:
             ret+="mk=%s"%m              ret+="mk=%s"%m
         return ret          return ret
   
   
     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 343  class documentViewer(Folder): Line 357  class documentViewer(Folder):
                 dom = Parse(txt)                  dom = Parse(txt)
                 break                  break
             except:              except:
                 logger("ERROR documentViewer (getIndexMata)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])                  logger("ERROR documentViewer (getIndexMeta)", logging.INFO,"%s (%s)"%sys.exc_info()[0:2])
                                   
         if dom is None:          if dom is None:
             raise IOError("Unable to read index meta from %s"%(url))              raise IOError("Unable to read index meta from %s"%(url))
Line 363  class documentViewer(Folder): Line 377  class documentViewer(Folder):
             server=self.digilibBaseUrl+"/servlet/Texter?fn="              server=self.digilibBaseUrl+"/servlet/Texter?fn="
             metaUrl=server+url.replace("/mpiwg/online","")              metaUrl=server+url.replace("/mpiwg/online","")
                         
           
         for cnt in range(num_retries):          for cnt in range(num_retries):
             try:              try:
                 # patch dirk encoding fehler treten dann nicht mehr auf                  # patch dirk encoding fehler treten dann nicht mehr auf
Line 461  class documentViewer(Folder): Line 474  class documentViewer(Folder):
         logger("documentViewer (getdocinfofromtexttool)", logging.INFO, "url: %s" % (url))          logger("documentViewer (getdocinfofromtexttool)", logging.INFO, "url: %s" % (url))
         if docinfo is None:          if docinfo is None:
            docinfo = {}             docinfo = {}
               
         if docinfo.get('lang', None) is None:          if docinfo.get('lang', None) is None:
             docinfo['lang'] = '' # default keine Sprache gesetzt              docinfo['lang'] = '' # default keine Sprache gesetzt
         if dom is None:          if dom is None:
Line 535  class documentViewer(Folder): Line 547  class documentViewer(Folder):
         if textUrls and (len(textUrls) > 0):          if textUrls and (len(textUrls) > 0):
             textUrl = getTextFromNode(textUrls[0])              textUrl = getTextFromNode(textUrls[0])
             docinfo['textURLPath'] = textUrl                 docinfo['textURLPath'] = textUrl   
               if not docinfo['imagePath']:
                   # text-only, no page images
                   docinfo = self.getNumPages(docinfo) #im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht    
                     
         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
Line 547  class documentViewer(Folder): Line 562  class documentViewer(Folder):
                 presentationUrl = url.replace('index.meta', presentationPath)                  presentationUrl = url.replace('index.meta', presentationPath)
             else:              else:
                 presentationUrl = url + "/" + presentationPath                  presentationUrl = url + "/" + presentationPath
             docinfo = self.getNumPages(docinfo) #im moment einfach auf eins setzen, navigation ueber die thumbs geht natuerlich nicht                      
             docinfo = self.getBibinfoFromTextToolPresentation(presentationUrl, docinfo=docinfo, dom=dom)              docinfo = self.getBibinfoFromTextToolPresentation(presentationUrl, docinfo=docinfo, dom=dom)
           
         docinfo = self.getAuthinfoFromIndexMeta(url, docinfo=docinfo, dom=dom)   # get access info          docinfo = self.getAuthinfoFromIndexMeta(url, docinfo=docinfo, dom=dom)   # get access info
Line 555  class documentViewer(Folder): Line 570  class documentViewer(Folder):
         return docinfo          return docinfo
   
   
   
      
      
     def getBibinfoFromTextToolPresentation(self,url,docinfo=None,dom=None):      def getBibinfoFromTextToolPresentation(self,url,docinfo=None,dom=None):
         """gets the bibliographical information from the preseantion entry in texttools          """gets the bibliographical information from the preseantion entry in texttools
         """          """
Line 618  class documentViewer(Folder): Line 630  class documentViewer(Folder):
             docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)              docinfo = self.getDocinfoFromImagePath(url, docinfo=docinfo,cut=1)
         else:          else:
             logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!")              logger("documentViewer (getdocinfo)", logging.ERROR,"unknown mode!")
             raise ValueError("Unknown mode %s"%(mode))              raise ValueError("Unknown mode %s! Has to be one of 'texttool','imagepath','filepath'."%(mode))
                                                   
         logger("documentViewer (getdocinfo)", logging.INFO,"docinfo: %s"%docinfo)          logger("documentViewer (getdocinfo)", logging.INFO,"docinfo: %s"%docinfo)
         self.REQUEST.SESSION['docinfo'] = docinfo          self.REQUEST.SESSION['docinfo'] = docinfo
         return docinfo          return docinfo
                   
                   
     def getPageinfo(self, current, start=None, rows=None, cols=None, docinfo=None):      def getPageinfo(self, current, start=None, rows=None, cols=None, docinfo=None, viewMode=None, tocMode=None):
         """returns pageinfo with the given parameters"""          """returns pageinfo with the given parameters"""
         pageinfo = {}          pageinfo = {}
         current = getInt(current)          current = getInt(current)
Line 640  class documentViewer(Folder): Line 652  class documentViewer(Folder):
         # int(current / grpsize) * grpsize +1))          # int(current / grpsize) * grpsize +1))
         pageinfo['start'] = start          pageinfo['start'] = start
         pageinfo['end'] = start + grpsize          pageinfo['end'] = start + grpsize
         if docinfo is not None:          if (docinfo is not None) and ('numPages' in docinfo):
             np = int(docinfo['numPages'])              np = int(docinfo['numPages'])
             pageinfo['end'] = min(pageinfo['end'], np)              pageinfo['end'] = min(pageinfo['end'], np)
             pageinfo['numgroups'] = int(np / grpsize)              pageinfo['numgroups'] = int(np / grpsize)
             if np % grpsize > 0:              if np % grpsize > 0:
                 pageinfo['numgroups'] += 1                  pageinfo['numgroups'] += 1
   
             
           pageinfo['viewMode'] = viewMode
           pageinfo['tocMode'] = tocMode
           pageinfo['query'] = self.REQUEST.get('query',' ')
           pageinfo['queryType'] = self.REQUEST.get('queryType',' ')
           pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
           pageinfo['textPN'] = self.REQUEST.get('textPN','1')
           pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
           pageinfo['tocPageSize'] = self.REQUEST.get('tocPageSize', '30')
           pageinfo['queryPageSize'] =self.REQUEST.get('queryPageSize', '10')
           pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')
           toc = int (pageinfo['tocPN'])
           pageinfo['textPages'] =int (toc)
           
           if 'tocSize_%s'%tocMode in docinfo:
               tocSize = int(docinfo['tocSize_%s'%tocMode])
               tocPageSize = int(pageinfo['tocPageSize'])
               # cached toc
              
               if tocSize%tocPageSize>0:
                   tocPages=tocSize/tocPageSize+1
               else:
                   tocPages=tocSize/tocPageSize
               pageinfo['tocPN'] = min (tocPages,toc)
                        
           pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
           pageinfo['sn'] =self.REQUEST.get('sn','')
   
         return pageinfo          return pageinfo
                                   
       def getSearch(self, pn=1, pageinfo=None,  docinfo=None, query=None, queryType=None):
           """get search list"""
           docpath = docinfo['textURLPath'] 
           url = docinfo['url']
           logging.debug("documentViewer (gettoc) docpath: %s"%(docpath))
           logging.debug("documentViewer (gettoc) url: %s"%(url))
           pagesize = pageinfo['queryPageSize']
           pn = pageinfo['searchPN']
           sn = pageinfo['sn']
           highlightQuery = pageinfo['highlightQuery']
           query =pageinfo['query']
           queryType =pageinfo['queryType']
           viewMode=  pageinfo['viewMode']
           tocMode = pageinfo['tocMode']
           tocPN = pageinfo['tocPN']
           selfurl = self.absolute_url()
           page=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&highlightQuery=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode,highlightQuery) ,outputUnicode=False)                
           pagexml = page.replace('?document=%s'%str(docpath),'?url=%s'%url)
           pagedom = Parse(pagexml)
           if (queryType=="fulltext")or(queryType=="xpath")or(queryType=="xquery")or(queryType=="fulltextMorphLemma"):   
               pagedivs = pagedom.xpath("//div[@class='queryResultPage']")
               if len(pagedivs)>0:
                   pagenode=pagedivs[0]
                   links=pagenode.xpath("//a")
                   for l in links:
                       hrefNode = l.getAttributeNodeNS(None, u"href")
                       if hrefNode:
                           href = hrefNode.nodeValue
                           if href.startswith('page-fragment.xql'):
                               selfurl = self.absolute_url()            
                               pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN))
                               hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                           
                   return serializeNode(pagenode)
   
           if (queryType=="fulltextMorph"):
               pagedivs = pagedom.xpath("//div[@class='queryResult']")
               if len(pagedivs)>0:
                   pagenode=pagedivs[0]
                   links=pagenode.xpath("//a")
                   for l in links:
                       hrefNode = l.getAttributeNodeNS(None, u"href")
                       if hrefNode:
                           href = hrefNode.nodeValue
                           if href.startswith('page-fragment.xql'):
                               selfurl = self.absolute_url()       
                               pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s'%(viewMode,queryType,query,pagesize,pn,tocMode,pn,tocPN))
                               hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)  
                           if href.startswith('../lt/lemma.xql'):
                               selfurl = self.absolute_url()
                               hrefNode.nodeValue = href.replace('..lt/lemma.xql','%s/template/head_main_lemma'%selfurl)        
                               l.setAttributeNS(None, 'target', '_blank')
                               l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;")
                               l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')                  
                   return serializeNode(pagenode)
           
           if (queryType=="ftIndex")or(queryType=="ftIndexMorph"):
               pagedivs= pagedom.xpath("//div[@class='queryResultPage']")
               if len(pagedivs)>0:
                   pagenode=pagedivs[0]
                   links=pagenode.xpath("//a")
                   for l in links:
                       hrefNode = l.getAttributeNodeNS(None, u"href")
                       if hrefNode:
                           href = hrefNode.nodeValue
                           hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s'%(viewMode,tocMode,tocPN,pn))
                          
                           if href.startswith('../lt/lex.xql'):
                               hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl)         
                               l.setAttributeNS(None, 'target', '_blank')
                               l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;")
                               l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
                           if href.startswith('../lt/lemma.xql'):
                               hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl)        
                               l.setAttributeNS(None, 'target', '_blank')
                               l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=400, scrollbars=1'); return false;")
                               l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
                   return serializeNode(pagenode)      
           return "no text here"   
   
     def getNumPages(self,docinfo=None):      def getNumPages(self,docinfo=None):
         """get list of pages from fulltext and put in docinfo"""          """get list of pages from fulltext and put in docinfo"""
Line 659  class documentViewer(Folder): Line 776  class documentViewer(Folder):
         docinfo['numPages'] = text.count("<pb ")          docinfo['numPages'] = text.count("<pb ")
         return docinfo          return docinfo
                 
     def getTextPage(self, mode="text", pn=1, docinfo=None):      def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None):
         """returns single page from fulltext"""          """returns single page from fulltext"""
         pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", "document=%s&mode=%s&pn=%s"%(docinfo['textURLPath'],mode,pn), outputUnicode=False)          docpath = docinfo['textURLPath']
         # post-processing downloaded xml          path = docinfo['textURLPath']
           url = docinfo['url']
           viewMode= pageinfo['viewMode']
           tocMode = pageinfo['tocMode']
           tocPN = pageinfo['tocPN']
           selfurl = self.absolute_url()   
          
           #pn = pageinfo['searchPN']
        
           if mode == "text_dict":
               textmode = "textPollux"
           else:
               textmode = mode
           
           textParam = "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn)
           if highlightQuery is not None:
               textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn)
               
           pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False)
         pagedom = Parse(pagexml)          pagedom = Parse(pagexml)
         # plain text mode          # plain text mode
         if mode == "text":          if mode == "text":
             # first div contains text              # first div contains text
             pagedivs = pagedom.xpath("/div")              pagedivs = pagedom.xpath("/div")
               #queryResultPage
             if len(pagedivs) > 0:              if len(pagedivs) > 0:
                 pagenode = pagedivs[0]                  pagenode = pagedivs[0]
                 return serializeNode(pagenode)                  links = pagenode.xpath("//a")
                   for l in links:
                       hrefNode = l.getAttributeNodeNS(None, u"href")
   
                       if hrefNode:
                           href= hrefNode.nodeValue
                           if href.startswith('#note-'):
                               hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn))
   
                   return serializeNode(pagenode)
           if mode == "xml":
                 # first div contains text
                 pagedivs = pagedom.xpath("/div")
                 if len(pagedivs) > 0:
                     pagenode = pagedivs[0]
                     return serializeNode(pagenode)
         # text-with-links mode          # text-with-links mode
         if mode == "textPollux":          if mode == "text_dict":
             # first div contains text              # first div contains text
             pagedivs = pagedom.xpath("/div")              pagedivs = pagedom.xpath("/div")
             if len(pagedivs) > 0:              if len(pagedivs) > 0:
Line 689  class documentViewer(Folder): Line 839  class documentViewer(Folder):
                             # is pollux link                              # is pollux link
                             selfurl = self.absolute_url()                              selfurl = self.absolute_url()
                             # change href                              # change href
                             hrefNode.nodeValue = href.replace('lt/lex.xql','%s/head_main_voc'%selfurl)                              hrefNode.nodeValue = href.replace('lt/lex.xql','%s/template/head_main_voc'%selfurl)
                             # add target                              # add target
                             l.setAttributeNS(None, 'target', '_blank')                              l.setAttributeNS(None, 'target', '_blank')
                               l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=700, scrollbars=1'); return false;")
                               l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
                               
                           if href.startswith('lt/lemma.xql'):    
                               selfurl = self.absolute_url()
                               hrefNode.nodeValue = href.replace('lt/lemma.xql','%s/template/head_main_lemma'%selfurl)
                               l.setAttributeNS(None, 'target', '_blank')
                               l.setAttributeNS(None, 'onClick',"popupWin = window.open(this.href, 'contacts', 'location,width=500,height=600,top=180, left=700, scrollbars=1'); return false;")
                               l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')
                           
                           if href.startswith('#note-'):
                               hrefNode.nodeValue = href.replace('#note-',"?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s#note-"%(url,viewMode,tocMode,tocPN,pn))    
                               
                               
                 return serializeNode(pagenode)                  return serializeNode(pagenode)
                   
         return "no text here"          return "no text here"
   
       def getTranslate(self, query=None, language=None):
           """translate into another languages"""
           pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lex.xql","document=&language="+str(language)+"&query="+url_quote(str(query)))
           return pagexml
       
       def getLemma(self, lemma=None, language=None):
           """simular words lemma """
           pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(lemma)))
           #pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","lemma=%s&language=%s"%(lemma,language),outputUnicode=False)
           return pagexml
   
       def getQuery (self,  docinfo=None, pageinfo=None, query=None, queryType=None, pn=1):
            """number of"""
            docpath = docinfo['textURLPath'] 
            pagesize = pageinfo['queryPageSize']
            pn = pageinfo['searchPN']
            query =pageinfo['query']
            queryType =pageinfo['queryType']
   
            tocSearch = 0
            tocDiv = None
            pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath, 'text', queryType, query, pagesize, pn) ,outputUnicode=False)
            
            pagedom = Parse(pagexml)
            numdivs = pagedom.xpath("//div[@class='queryResultHits']")
            tocSearch = int(getTextFromNode(numdivs[0]))
            tc=int((tocSearch/10)+1)
            logging.debug("documentViewer (gettoc) tc: %s"%(tc))
            return tc
   
       def getToc(self, mode="text", docinfo=None):
           """loads table of contents and stores in docinfo"""
           logging.debug("documentViewer (gettoc) mode: %s"%(mode))
           if 'tocSize_%s'%mode in docinfo:
               # cached toc
               return docinfo 
           docpath = docinfo['textURLPath']
           # we need to set a result set size
           pagesize = 1000
           pn = 1
           if mode == "text":
               queryType = "toc"
           else:
               queryType = mode
           # number of entries in toc
           tocSize = 0
           tocDiv = None
           pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql", "document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath,queryType,pagesize,pn), outputUnicode=False)
           # post-processing downloaded xml
           pagedom = Parse(pagexml)
           # get number of entries
           numdivs = pagedom.xpath("//div[@class='queryResultHits']")
           if len(numdivs) > 0:
               tocSize = int(getTextFromNode(numdivs[0]))
               # div contains text
               #pagedivs = pagedom.xpath("//div[@class='queryResultPage']")
               #if len(pagedivs) > 0:
               #    tocDiv = pagedivs[0]
   
           docinfo['tocSize_%s'%mode] = tocSize
           #docinfo['tocDiv_%s'%mode] = tocDiv
           return docinfo
       
       def getTocPage(self, mode="text", pn=1, pageinfo=None, docinfo=None):
           """returns single page from the table of contents"""
           # TODO: this should use the cached TOC
           if mode == "text":
               queryType = "toc"
           else:
               queryType = mode
           docpath = docinfo['textURLPath']
           path = docinfo['textURLPath']
           #logging.debug("documentViewer (gettoc) pathNomer: %s"%(pathNomer))
           pagesize = pageinfo['tocPageSize']
           pn = pageinfo['tocPN']
           url = docinfo['url']
           selfurl = self.absolute_url()  
           viewMode=  pageinfo['viewMode']
           tocMode = pageinfo['tocMode']
           tocPN = pageinfo['tocPN']
       
           pagexml=self.template.fulltextclient.eval("/mpdl/interface/doc-query.xql", "document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath,queryType, pagesize, pn), outputUnicode=False)
           page = pagexml.replace('page-fragment.xql?document=%s'%str(path),'%s?url=%s&viewMode=%s&tocMode=%s&tocPN=%s'%(selfurl,url, viewMode, tocMode, tocPN))
           text = page.replace('mode=image','mode=texttool')
           return text
           # post-processing downloaded xml
           #pagedom = Parse(text)
           # div contains text
           #pagedivs = pagedom.xpath("//div[@class='queryResultPage']")
           #if len(pagedivs) > 0:
           #    pagenode = pagedivs[0]
           #    return serializeNode(pagenode)
           #else:
           #    return "No TOC!"
   
           
     def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=10,authgroups='mpiwg',RESPONSE=None):      def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None):
         """init document viewer"""          """init document viewer"""
         self.title=title          self.title=title
         self.digilibBaseUrl = digilibBaseUrl          self.digilibBaseUrl = digilibBaseUrl

Removed from v.1.43  
changed lines
  Added in v.1.61


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>