Diff for /documentViewer/MpdlXmlTextServer.py between versions 1.170 and 1.209

version 1.170, 2010/10/18 10:26:39 version 1.209, 2010/11/09 12:41:41
Line 38  class MpdlXmlTextServer(SimpleItem): Line 38  class MpdlXmlTextServer(SimpleItem):
         url = self.serverUrl+method          url = self.serverUrl+method
         return documentViewer.getHttpData(url,data,timeout=self.timeout)          return documentViewer.getHttpData(url,data,timeout=self.timeout)
   
     def getSearch(self, pn=1, pageinfo=None,  docinfo=None, query=None, queryType=None, lemma=None):      def getSearch(self, pn=1, pageinfo=None,  docinfo=None, query=None, queryType=None, lemma=None, characterNormalization=None, optionToggle=None):
         """get search list"""          """get search list"""
         docpath = docinfo['textURLPath']           docpath = docinfo['textURLPath'] 
         url = docinfo['url']          url = docinfo['url']
Line 51  class MpdlXmlTextServer(SimpleItem): Line 51  class MpdlXmlTextServer(SimpleItem):
         viewMode=  pageinfo['viewMode']          viewMode=  pageinfo['viewMode']
         tocMode = pageinfo['tocMode']          tocMode = pageinfo['tocMode']
         characterNormalization = pageinfo['characterNormalization']          characterNormalization = pageinfo['characterNormalization']
           optionToggle = pageinfo['optionToggle']
         tocPN = pageinfo['tocPN']          tocPN = pageinfo['tocPN']
         selfurl = self.absolute_url()          selfurl = self.absolute_url()
                   
         data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, sn, viewMode,urllib.quote(highlightQuery)))          data = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s&characterNormalization=%s&optionToggle=%s&highlightQuery=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn, sn, viewMode,characterNormalization,optionToggle ,urllib.quote(highlightQuery)))
         #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)                          #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 = data.replace('?document=%s'%str(docpath),'?url=%s'%url)          pagexml = data.replace('?document=%s'%str(docpath),'?url=%s'%url)
Line 70  class MpdlXmlTextServer(SimpleItem): Line 71  class MpdlXmlTextServer(SimpleItem):
                         href = hrefNode.nodeValue                          href = hrefNode.nodeValue
                         if href.startswith('page-fragment.xql'):                          if href.startswith('page-fragment.xql'):
                             selfurl = self.absolute_url()                                          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,urllib.quote(query),pagesize,pn,tocMode,pn,tocPN))                              pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s&optionToggle=%s'%(viewMode,queryType,urllib.quote(query),pagesize,pn,tocMode,pn,tocPN,optionToggle))
                             hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                                                         hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                           
                 return serializeNode(pagenode)                          return serializeNode(pagenode)        
         if (queryType=="fulltextMorph"):          if (queryType=="fulltextMorph"):
Line 84  class MpdlXmlTextServer(SimpleItem): Line 85  class MpdlXmlTextServer(SimpleItem):
                         href = hrefNode.nodeValue                          href = hrefNode.nodeValue
                         if href.startswith('page-fragment.xql'):                          if href.startswith('page-fragment.xql'):
                             selfurl = self.absolute_url()                                     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,urllib.quote(query),pagesize,pn,tocMode,pn,tocPN))                              pagexml=href.replace('mode=text','mode=texttool&viewMode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&tocMode=%s&searchPN=%s&tocPN=%s&optionToggle=%s'%(viewMode,queryType,urllib.quote(query),pagesize,pn,tocMode,pn,tocPN,optionToggle))
                             hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)  
                         if href.startswith('../lt/lemma.xql'):                          if href.startswith('../lt/lemma.xql'):
                             hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma_New'%(selfurl))                                      hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma_New'%(selfurl))        
Line 102  class MpdlXmlTextServer(SimpleItem): Line 103  class MpdlXmlTextServer(SimpleItem):
                     hrefNode = l.getAttributeNodeNS(None, u"href")                      hrefNode = l.getAttributeNodeNS(None, u"href")
                     if hrefNode:                      if hrefNode:
                         href = hrefNode.nodeValue                          href = hrefNode.nodeValue
                         hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s'%(viewMode,tocMode,tocPN,pn))                                       hrefNode.nodeValue=href.replace('mode=text','mode=texttool&viewMode=%s&tocMode=%s&tocPN=%s&pn=%s&optionToggle=%s'%(viewMode,tocMode,tocPN,pn,optionToggle))             
                         if href.startswith('../lt/lex.xql'):                          if href.startswith('../lt/lex.xql'):
                             hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl)                                       hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl)         
                             l.setAttributeNS(None, 'target', '_blank')                              l.setAttributeNS(None, 'target', '_blank')
Line 135  class MpdlXmlTextServer(SimpleItem): Line 136  class MpdlXmlTextServer(SimpleItem):
         text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'], xpath))          text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'], xpath))
         dom = Parse(text)          dom = Parse(text)
         result= dom.xpath("//result/resultPage")          result= dom.xpath("//result/resultPage")
            
         docinfo['numPages']=int(getTextFromNode(result[0]))          docinfo['numPages']=int(getTextFromNode(result[0]))
         return docinfo          return docinfo
           
Line 170  class MpdlXmlTextServer(SimpleItem): Line 172  class MpdlXmlTextServer(SimpleItem):
         text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'],xpath))          text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'],xpath))
         dom =Parse(text)          dom =Parse(text)
         result = dom.xpath("//result/resultPage/place")          result = dom.xpath("//result/resultPage/place")
           
         for l in result:          for l in result:
             hrefNode = l.getAttributeNodeNS(None, u"id")              hrefNode = l.getAttributeNodeNS(None, u"id")
             href= hrefNode.nodeValue              href= hrefNode.nodeValue
Line 178  class MpdlXmlTextServer(SimpleItem): Line 181  class MpdlXmlTextServer(SimpleItem):
             logging.debug("getALLGisPlaces :%s"%(myList))              logging.debug("getALLGisPlaces :%s"%(myList))
         return myList          return myList
           
     def getOrigPages (self, docinfo=None):      
       def getPDF (self, docinfo=None, pageinfo=None):
           """Show and Save different Pages as PDF in Options"""
           selfurl=self.absolute_url()
           pn=pageinfo['current']
           
           viewMode =pageinfo['viewMode']
           
           #text = ("page-fragment.xql","document=%s&mode=%s&pn=%s&export=%s"%(docinfo['textURLPath'], 'text',  pn,'pdf'))
           #text = self.getServerData("page-fragment.xql", "document=%s&mode=%s&pn=%s&export=%s"(docinfo['textURLPath'],'text', pn,'pdf'))
           #logging.debug("text :%s"%(text))
           #dom =Parse(text)
           #logging.debug("text :%s"%(text))
           #return text 
              
       def getOrigPages (self, docinfo=None, pageinfo=None):
         """Show original page """          """Show original page """
         #docpath = docinfo['textURLPath']           docpath = docinfo['textURLPath'] 
           logging.debug ("docinfo['textURLPath']=%s"%(docinfo['textURLPath']))
         #url = docinfo['url']          #url = docinfo['url']
         selfurl = self.absolute_url()          selfurl = self.absolute_url()
         #pn =pageinfo['current']          pn =pageinfo['current']
                 
         viewMode=  pageinfo['viewMode']          viewMode=  pageinfo['viewMode']
         #text = self.getServerData("page-fragment.xql","document=%s&mode=%s&pn=%s"%(docinfo['textURLPath'], 'text',  pn))          text = self.getServerData("page-fragment.xql","document=%s&mode=%s&pn=%s"%(docinfo['textURLPath'], 'text',  pn))
         text = self.getServerData("page-fragment.xql","document=%s&mode=%s"%(docinfo['textURLPath'], 'text'))  
         dom =Parse(text)          dom =Parse(text)
         pagedivs = dom.xpath("//div[@class='pageNumberOrig']")          pagedivs = dom.xpath("//div[@class='pageNumberOrig']")
           logging.debug("YYYYYYpagedivs :%s"%(pagedivs))
         if len(pagedivs)>0:          if len(pagedivs)>0:
             docinfo['originalPage'] = getTextFromNode(pagedivs[0])              originalPage= getTextFromNode(pagedivs[0])
         #return docinfo['originalPage']          #return docinfo['originalPage']
         #return originalPage              return originalPage
         return docinfo  
                   
     def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization=""):      
       def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, viewMode=None, tocMode=None, tocPN=None, characterNormalization="", highlightQuery=None, sn=None, optionToggle=None):
         """returns single page from fulltext"""          """returns single page from fulltext"""
         docpath = docinfo['textURLPath']          docpath = docinfo['textURLPath']
         path = docinfo['textURLPath']          path = docinfo['textURLPath']
         url = docinfo['url']          url = docinfo['url']
         name = docinfo['name']          name = docinfo['name']
         viewMode= pageinfo['viewMode']          viewMode= pageinfo['viewMode']
           sn = pageinfo['sn']
           highlightQuery = pageinfo['highlightQuery']
           
         tocMode = pageinfo['tocMode']          tocMode = pageinfo['tocMode']
         characterNormalization=pageinfo['characterNormalization']          characterNormalization=pageinfo['characterNormalization']
         tocPN = pageinfo['tocPN']          tocPN = pageinfo['tocPN']
Line 211  class MpdlXmlTextServer(SimpleItem): Line 233  class MpdlXmlTextServer(SimpleItem):
             textmode = "textPollux"              textmode = "textPollux"
         else:          else:
             textmode = mode              textmode = mode
         #logging.debug("documentViewer (characterNormalization) characterNormalization: %s"%(characterNormalization))          #logging.debug("documentViewer highlightQuery: %s"%(highlightQuery))
         textParam = "document=%s&mode=%s&pn=%s&characterNormalization=%s"%(docpath,textmode,pn,characterNormalization)          textParam = "document=%s&mode=%s&pn=%s&characterNormalization=%s"%(docpath,textmode,pn,characterNormalization)
         if highlightQuery is not None:          if highlightQuery is not None:
             textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn)                         textParam +="&highlightQuery=%s&sn=%s"%(urllib.quote(highlightQuery),sn)           
                       #logging.debug("documentViewer highlightQuery: %s"%(highlightQuery))
         pagexml = self.getServerData("page-fragment.xql",textParam)          pagexml = self.getServerData("page-fragment.xql",textParam)
           logging.debug("documentViewer highlightQuery: %s"%(highlightQuery))
         #pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False)          #pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False)
                   
         pagedom = Parse(pagexml)          pagedom = Parse(pagexml)
Line 312  class MpdlXmlTextServer(SimpleItem): Line 335  class MpdlXmlTextServer(SimpleItem):
         #pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(query)))          #pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(query)))
         return data          return data
           
     def getQuery (self,  docinfo=None, pageinfo=None, query=None, queryType=None, pn=1):      def getQuery (self,  docinfo=None, pageinfo=None, query=None, queryType=None, pn=1, optionToggle=None):
          """number of"""           """number of"""
          docpath = docinfo['textURLPath']            docpath = docinfo['textURLPath'] 
          pagesize = pageinfo['queryPageSize']           pagesize = pageinfo['queryPageSize']
Line 327  class MpdlXmlTextServer(SimpleItem): Line 350  class MpdlXmlTextServer(SimpleItem):
          pagedom = Parse(pagexml)           pagedom = Parse(pagexml)
          numdivs = pagedom.xpath("//div[@class='queryResultHits']")           numdivs = pagedom.xpath("//div[@class='queryResultHits']")
          tocSearch = int(getTextFromNode(numdivs[0]))           tocSearch = int(getTextFromNode(numdivs[0]))
            logging.debug("documentViewer (gettoc) tocSearch: %s"%(tocSearch))
          tc=int((tocSearch/10)+1)           tc=int((tocSearch/10)+1)
          logging.debug("documentViewer (gettoc) tc: %s"%(tc))           logging.debug("documentViewer (gettoc) tc: %s"%(tc))
          return tc           return tc
   
       def getQueryResultHits(self,  docinfo=None, pageinfo=None, query=None, queryType=None, pn=1, optionsClose=None):
           
            """number of hits in Search mode"""
            docpath = docinfo['textURLPath'] 
            pagesize = pageinfo['queryPageSize']
            pn = pageinfo['searchPN']
            query =pageinfo['query']
            queryType =pageinfo['queryType']
            tocSearch = 0
            tocDiv = None
            
            pagexml = self.getServerData("doc-query.xql","document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s"%(docpath, 'text', queryType, urllib.quote(query), pagesize, pn))
            #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]))    
            return tocSearch
        
       def getQueryResultHitsText(self,  docinfo=None, pageinfo=None):      
            """number of hits in Text of Contents mode"""
            
            docpath = docinfo['textURLPath'] 
            pagesize = pageinfo['queryPageSize']
            pn = pageinfo['searchPN']
            query =pageinfo['query']
            queryType =pageinfo['queryType']
            tocSearch = 0
            tocDiv = None
            tocMode = pageinfo['tocMode']
            tocPN = pageinfo['tocPN']  
            pagexml=self.getServerData("doc-query.xql", "document=%s&queryType=%s"%(docpath,'toc'))
            pagedom = Parse(pagexml)
            logging.debug("documentViewer (pagedom) pagedom: %s"%(pagedom))
            numdivs = pagedom.xpath("//div[@class='queryResultHits']")
            tocSearch = int(getTextFromNode(numdivs[0]))    
            return tocSearch 
   
       def getQueryResultHitsFigures(self,  docinfo=None, pageinfo=None):      
            """number of hits in Text of Figures mode"""
            
            docpath = docinfo['textURLPath'] 
            pagesize = pageinfo['queryPageSize']
            pn = pageinfo['searchPN']
            query =pageinfo['query']
            queryType =pageinfo['queryType']
            tocSearch = 0
            tocDiv = None
            tocMode = pageinfo['tocMode']
            tocPN = pageinfo['tocPN']  
            pagexml=self.getServerData("doc-query.xql", "document=%s&queryType=%s"%(docpath,'figures'))
            pagedom = Parse(pagexml)
            logging.debug("documentViewer (pagedom) pagedom: %s"%(pagedom))
            numdivs = pagedom.xpath("//div[@class='queryResultHits']")
            tocSearch = int(getTextFromNode(numdivs[0]))    
            return tocSearch 
   
   
     def getToc(self, mode="text", docinfo=None):      def getToc(self, mode="text", docinfo=None):
         """loads table of contents and stores in docinfo"""          """loads table of contents and stores in docinfo"""
         logging.debug("documentViewer (gettoc) mode: %s"%(mode))          logging.debug("documentViewer (gettoc) mode: %s"%(mode))
Line 378  class MpdlXmlTextServer(SimpleItem): Line 459  class MpdlXmlTextServer(SimpleItem):
         selfurl = self.absolute_url()            selfurl = self.absolute_url()  
         viewMode=  pageinfo['viewMode']          viewMode=  pageinfo['viewMode']
         characterNormalization = pageinfo ['characterNormalization']          characterNormalization = pageinfo ['characterNormalization']
           optionToggle =pageinfo ['optionToggle']
         tocMode = pageinfo['tocMode']          tocMode = pageinfo['tocMode']
         tocPN = pageinfo['tocPN']            tocPN = pageinfo['tocPN']  
                   
         data = self.getServerData("doc-query.xql","document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s&characterNormalization=%s"%(docpath,queryType, pagesize, pn,characterNormalization))            data = self.getServerData("doc-query.xql","document=%s&queryType=%s&queryResultPageSize=%s&queryResultPN=%s&characterNormalization=%s&optionToggle=%s"%(docpath,queryType, pagesize, pn,characterNormalization,optionToggle))  
         page = data.replace('page-fragment.xql?document=%s'%str(path),'%s?url=%s&viewMode=%s&tocMode=%s&tocPN=%s'%(selfurl,url, viewMode, tocMode, tocPN))          page = data.replace('page-fragment.xql?document=%s'%str(path),'%s?url=%s&viewMode=%s&tocMode=%s&tocPN=%s&optionToggle=%s'%(selfurl,url, viewMode, tocMode, tocPN,optionToggle))
         text = page.replace('mode=image','mode=texttool')          text = page.replace('mode=image','mode=texttool')
         logging.debug("documentViewer (characterNormalization) characterNormalization: %s"%(characterNormalization))          logging.debug("documentViewer (characterNormalization) characterNormalization: %s"%(characterNormalization))
         #logging.debug("documentViewer (characterNormalization) text: %s"%(text))          #logging.debug("documentViewer (characterNormalization) text: %s"%(text))

Removed from v.1.170  
changed lines
  Added in v.1.209


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