Index: documentViewer.py
===================================================================
--- documentViewer.py	(revision 127)
+++ documentViewer.py	(revision 128)
@@ -640,6 +640,5 @@
         self.REQUEST.SESSION['docinfo'] = docinfo
         return docinfo
-        
-        
+               
     def getPageinfo(self, current, start=None, rows=None, cols=None, docinfo=None, viewMode=None, tocMode=None):
         """returns pageinfo with the given parameters"""
@@ -662,7 +661,5 @@
             pageinfo['numgroups'] = int(np / grpsize)
             if np % grpsize > 0:
-                pageinfo['numgroups'] += 1
-        
-          
+                pageinfo['numgroups'] += 1        
         pageinfo['viewMode'] = viewMode
         pageinfo['tocMode'] = tocMode
@@ -681,18 +678,15 @@
             tocSize = int(docinfo['tocSize_%s'%tocMode])
             tocPageSize = int(pageinfo['tocPageSize'])
-            # cached toc
-           
+            # cached toc           
             if tocSize%tocPageSize>0:
                 tocPages=tocSize/tocPageSize+1
             else:
                 tocPages=tocSize/tocPageSize
-            pageinfo['tocPN'] = min (tocPages,toc)
-                     
+            pageinfo['tocPN'] = min (tocPages,toc)                    
         pageinfo['searchPN'] =self.REQUEST.get('searchPN','1')
         pageinfo['sn'] =self.REQUEST.get('sn','')
-
         return pageinfo
                 
-    def getSearch(self, pn=1, pageinfo=None,  docinfo=None, query=None, queryType=None):
+    def getSearch(self, pn=1, pageinfo=None,  docinfo=None, query=None, queryType=None, lemma=None):
         """get search list"""
         docpath = docinfo['textURLPath'] 
@@ -726,6 +720,5 @@
                             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)
-        
+                return serializeNode(pagenode)        
         if (queryType=="fulltextMorph"):
             pagedivs = pagedom.xpath("//div[@class='queryResult']")
@@ -742,12 +735,10 @@
                             hrefNode.nodeValue = pagexml.replace('page-fragment.xql','%s'%selfurl)  
                         if href.startswith('../lt/lemma.xql'):
-                            
-                            hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma'%selfurl)        
+                            hrefNode.nodeValue = href.replace('../lt/lemma.xql','%s/template/head_main_lemma_New'%(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();')  
                 pagedivs = pagedom.xpath("//div[@class='queryResultMorphExpansion']")                
-                return serializeNode(pagenode)
-        
+                return serializeNode(pagenode)        
         if (queryType=="ftIndex")or(queryType=="ftIndexMorph"):
             pagedivs= pagedom.xpath("//div[@class='queryResultPage']")
@@ -759,6 +750,5 @@
                     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))
-                       
+                        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)         
@@ -791,7 +781,4 @@
         tocPN = pageinfo['tocPN']
         selfurl = self.absolute_url()   
-       
-        #pn = pageinfo['searchPN']
-     
         if mode == "text_dict":
             textmode = "textPollux"
@@ -801,6 +788,5 @@
         textParam = "document=%s&mode=%s&pn=%s"%(docpath,textmode,pn)
         if highlightQuery is not None:
-            textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn)
-            
+            textParam +="&highlightQuery=%s&sn=%s"%(highlightQuery,sn)           
         pagexml=self.template.fulltextclient.eval("/mpdl/interface/page-fragment.xql", textParam, outputUnicode=False)
         pagedom = Parse(pagexml)
@@ -809,5 +795,4 @@
             # first div contains text
             pagedivs = pagedom.xpath("/div")
-            #queryResultPage
             if len(pagedivs) > 0:      
                 pagenode = pagedivs[0]
@@ -815,10 +800,8 @@
                 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":
@@ -855,6 +838,5 @@
                             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();')
-                            
+                            l.setAttributeNS(None, 'onDblclick', 'popupWin.focus();')      
                         if href.startswith('lt/lemma.xql'):    
                             selfurl = self.absolute_url()
@@ -862,12 +844,8 @@
                             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();')
-                        
+                            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 "no text here"
 
@@ -880,5 +858,9 @@
         """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 getLemmaNew(self, query=None, language=None):
+        """simular words lemma """
+        pagexml=self.template.fulltextclient.eval("/mpdl/interface/lt/lemma.xql","document=&language="+str(language)+"&lemma="+url_quote(str(query)))
         return pagexml
 
@@ -890,9 +872,7 @@
          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']")
@@ -906,6 +886,5 @@
         logging.debug("documentViewer (gettoc) mode: %s"%(mode))
         if mode == "none":
-            return docinfo
-        
+            return docinfo        
         if 'tocSize_%s'%mode in docinfo:
             # cached toc
@@ -930,14 +909,8 @@
         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):
+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
@@ -947,6 +920,5 @@
             queryType = mode
         docpath = docinfo['textURLPath']
-        path = docinfo['textURLPath']
-        #logging.debug("documentViewer (gettoc) pathNomer: %s"%(pathNomer))
+        path = docinfo['textURLPath']       
         pagesize = pageinfo['tocPageSize']
         pn = pageinfo['tocPN']
@@ -955,21 +927,11 @@
         viewMode=  pageinfo['viewMode']
         tocMode = pageinfo['tocMode']
-        tocPN = pageinfo['tocPN']
-    
+        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=5,authgroups='mpiwg',RESPONSE=None):
+    
+def changeDocumentViewer(self,title="",digilibBaseUrl=None,thumbrows=2,thumbcols=5,authgroups='mpiwg',RESPONSE=None):
         """init document viewer"""
         self.title=title
@@ -980,6 +942,4 @@
         if RESPONSE is not None:
             RESPONSE.redirect('manage_main')
-    
-    
         
 def manage_AddDocumentViewerForm(self):
@@ -996,8 +956,5 @@
         RESPONSE.redirect('manage_main')
 
-
-##
 ## DocumentViewerTemplate class
-##
 class DocumentViewerTemplate(ZopePageTemplate):
     """Template for document viewer"""
