changeset 395:e6f3fcb2058f

*** empty log message ***
author abukhman
date Mon, 08 Nov 2010 16:04:06 +0100
parents ce9fa69f81c3
children 28a03e25a0e8
files MpdlXmlTextServer.py
diffstat 1 files changed, 59 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/MpdlXmlTextServer.py	Mon Nov 08 15:59:40 2010 +0100
+++ b/MpdlXmlTextServer.py	Mon Nov 08 16:04:06 2010 +0100
@@ -138,10 +138,7 @@
          
         docinfo['numPages']=int(getTextFromNode(result[0]))
         return docinfo
-    
-    #def getQueryResultHits(self, docinfo=None, pageinfo=None):
-        
-    
+            
     def getGisPlaces(self, docinfo=None, pageinfo=None):
         """ Show all Gis Places of whole Page"""
         xpath='//place'
@@ -174,6 +171,7 @@
         text=self.getServerData("xpath.xql", "document=%s&xpath=%s"%(docinfo['textURLPath'],xpath))
         dom =Parse(text)
         result = dom.xpath("//result/resultPage/place")
+        
         for l in result:
             hrefNode = l.getAttributeNodeNS(None, u"id")
             href= hrefNode.nodeValue
@@ -356,6 +354,63 @@
          logging.debug("documentViewer (gettoc) tc: %s"%(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):
         """loads table of contents and stores in docinfo"""
         logging.debug("documentViewer (gettoc) mode: %s"%(mode))