Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 109)
+++ documentViewer.py	(revision 112)
@@ -660,5 +660,5 @@
                 pageinfo['numgroups'] += 1
         
-        #pageinfo['viewMode'] = viewMode   
+          
         pageinfo['viewMode'] = viewMode
         pageinfo['tocMode'] = tocMode
@@ -666,5 +666,4 @@
         pageinfo['queryType'] = self.REQUEST.get('queryType',' ')
         pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
-        pageinfo['sn'] = self.REQUEST.get('sn','')
         pageinfo['textPN'] = self.REQUEST.get('textPN','1')
         pageinfo['highlightQuery'] = self.REQUEST.get('highlightQuery','')
@@ -687,5 +686,5 @@
                      
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
-        pageinfo['sn'] =self.REQUEST.get('sn','1')
+        pageinfo['sn'] =self.REQUEST.get('sn','')
 
         return pageinfo
@@ -707,5 +706,4 @@
         tocPN = pageinfo['tocPN']
         selfurl = self.absolute_url()
-       # logging.debug("documentViewer (gettoc) /mpdl/interface/doc-query.xql?document=%s&mode=%s&queryType=%s&query=%s&queryResultPageSize=%s&queryResultPN=%s&sn=%s&viewMode=%s"%(docpath, 'text', queryType, query, pagesize, pn, sn, viewMode))
         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)
@@ -721,11 +719,7 @@
                         href = hrefNode.nodeValue
                         if href.startswith('page-fragment.xql'):
-                            selfurl = self.absolute_url()
-                            #l.setAttributeNS(None, "span class = 'hit highlight'", "background-color: #77DD77;")            
+                            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)                                          
-                            l.setAttributeNS(None, "onClick", "id='highlighting'") 
-                            logging.debug("documentViewer (gettoc) highlightQuery: %s"%(highlightQuery))
-                            l.setAttributeNS(None, highlightQuery, "id='highlighting'") 
+                            hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)                                           
                 return serializeNode(pagenode)
         
@@ -764,5 +758,4 @@
                        
                         if href.startswith('../lt/lex.xql'):
-                           # selfurl = self.absolute_url()
                             hrefNode.nodeValue = href.replace('../lt/lex.xql','%s/template/head_main_voc'%selfurl)         
                             l.setAttributeNS(None, 'target', '_blank')
@@ -770,5 +763,4 @@
                             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')
@@ -786,21 +778,26 @@
         return docinfo
        
-    def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None):
+    def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None, highlightQuery=None,sn=None, viewMode=None):
         """returns single page from fulltext"""
         docpath = docinfo['textURLPath']
-        #pageinfo = pageinfo['highlightQuery']
+        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
-            
-        #selfurl = self.absolute_url()  
-        #viewMode=  pageinfo['viewMode']
-        #tocMode = pageinfo['tocMode']
-        #tocPN = pageinfo['tocPN']
-  
-        pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", "document=%s&mode=%s&pn=%s&highlightQuery=%s&sn=%s"%(docpath,textmode,pn,highlightQuery,sn), outputUnicode=False)
-        logging.debug("documentViewer (gettoc) document=%s&mode=%s&pn=%s&highlightQuery=%s"%(docpath,textmode,pn,highlightQuery))
-        # post-processing downloaded xml
+        
+        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)
         # plain text mode
@@ -809,15 +806,15 @@
             pagedivs = pagedom.xpath("/div")
             #queryResultPage
-            if len(pagedivs) > 0:
-               
+            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('#note-0006-01'):
-                            selfurl = self.absolute_url()
-                            hrefNode.nodeValue = href.replace("href='#note-'",'xaxa/%s/'%selfurl)
+                        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":
@@ -856,4 +853,9 @@
                             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)
         
