changeset 471:415a7026eeda elementtree

split viewMode in viewMode and viewType
author casties
date Thu, 04 Aug 2011 16:57:02 +0200
parents c1ba044d4961
children 9705161bc888
files MpdlXmlTextServer.py documentViewer.py
diffstat 2 files changed, 23 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/MpdlXmlTextServer.py	Thu Aug 04 10:01:35 2011 +0200
+++ b/MpdlXmlTextServer.py	Thu Aug 04 16:57:02 2011 +0200
@@ -1,4 +1,3 @@
-
 from OFS.SimpleItem import SimpleItem
 from Products.PageTemplates.PageTemplateFile import PageTemplateFile 
 
@@ -269,7 +268,7 @@
         return
          
            
-    def getTextPage(self, mode="text_dict", pn=1, docinfo=None, pageinfo=None):
+    def getTextPage(self, mode="text", pn=1, docinfo=None, pageinfo=None):
         """returns single page from fulltext"""
         logging.debug("getTextPage mode=%s, pn=%s"%(mode,pn))
         # check for cached text -- but this shouldn't be called twice
@@ -292,9 +291,12 @@
         characterNormalization = pageinfo.get('characterNormalization', None)
         selfurl = docinfo['viewerUrl']   
         
-        if mode == "text_dict":
+        if mode == "dict":
             # text_dict is called textPollux in the backend
             textmode = "textPollux"
+        elif not mode:
+            # default is text
+            textmode = "text"
         else:
             textmode = mode
         
--- a/documentViewer.py	Thu Aug 04 10:01:35 2011 +0200
+++ b/documentViewer.py	Thu Aug 04 16:57:02 2011 +0200
@@ -266,12 +266,13 @@
 
   
     security.declareProtected('View','index_html')
-    def index_html(self,url,mode="texttool",viewMode="auto",tocMode="thumbs",start=None,pn=1,mk=None):
+    def index_html(self,url,mode="texttool",viewMode="auto",viewTYpe=None,tocMode="thumbs"):
         """
-        view it
+        view page
+        @param url: url which contains display information
         @param mode: defines how to access the document behind url 
-        @param url: url which contains display information
-        @param viewMode: if images display images, if text display text, default is auto (text,images or auto)
+        @param viewMode: 'images': display images, 'text': display text, default is 'auto'
+        @param viewType: sub-type of viewMode, e.g. 'dict' for viewMode='text'
         @param tocMode: type of 'table of contents' for navigation (thumbs, text, figures, none)
         """
         
@@ -291,19 +292,20 @@
             # get table of contents
             docinfo = self.getToc(mode=tocMode, docinfo=docinfo)
 
-        # auto viewMode: text_dict if text else images
+        # auto viewMode: text if there is a text else images
         if viewMode=="auto": 
             if docinfo.get('textURL', None) or docinfo.get('textURLPath', None): 
-                viewMode="text_dict"
+                viewMode = "text"
+                viewType = "dict"
             else:
-                viewMode="images"
+                viewMode = "images"
                 
-        pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, tocMode=tocMode)
+        pageinfo = self.getPageinfo(start=start, current=pn, docinfo=docinfo, viewMode=viewMode, viweType=viewType, tocMode=tocMode)
                     
         # get template /template/viewer_main
         pt = getattr(self.template, 'viewer_main')
         # and execute with parameters
-        return pt(docinfo=docinfo, pageinfo=pageinfo, viewMode=viewMode, mk=self.generateMarks(mk))
+        return pt(docinfo=docinfo, pageinfo=pageinfo)
   
     def generateMarks(self,mk):
         ret=""
@@ -664,9 +666,13 @@
         return docinfo
     
 
-    def getPageinfo(self, current, start=None, rows=None, cols=None, docinfo=None, viewMode=None, tocMode=None):
+    def getPageinfo(self, current, start=None, rows=None, cols=None, docinfo=None, viewMode=None, viewType=None, tocMode=None):
         """returns pageinfo with the given parameters"""
         pageinfo = {}
+        pageinfo['viewMode'] = viewMode
+        pageinfo['viewType'] = viewType
+        pageinfo['tocMode'] = tocMode
+
         current = getInt(current)
         pageinfo['current'] = current
         rows = int(rows or self.thumbrows)
@@ -687,7 +693,7 @@
             # numPages unknown - maybe we can get it from text page
             if docinfo.get('textURLPath', None):
                 # cache text page as well
-                pageinfo['textPage'] = self.getTextPage(mode=viewMode, pn=pn, docinfo=docinfo, pageinfo=pageinfo)
+                pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=pn, docinfo=docinfo, pageinfo=pageinfo)
                 np = int(docinfo.get('numPages', 0))
                 
         pageinfo['end'] = min(pageinfo['end'], np)
@@ -695,10 +701,7 @@
         if np % grpsize > 0:
             pageinfo['numgroups'] += 1
                 
-        pageinfo['viewMode'] = viewMode
-        pageinfo['tocMode'] = tocMode
         pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg')
-        #pageinfo['optionToggle'] = self.REQUEST.get('optionToggle','1')
         pageinfo['query'] = self.REQUEST.get('query','') 
         pageinfo['queryType'] = self.REQUEST.get('queryType','')
         pageinfo['querySearch'] =self.REQUEST.get('querySearch', 'fulltext')
@@ -708,7 +711,7 @@
         pageinfo['tocPN'] = self.REQUEST.get('tocPN', '1')
         # WTF?:
         toc = int(pageinfo['tocPN'])
-        pageinfo['textPages'] =int(toc)
+        pageinfo['textPages'] = int(toc)
         
         # What does this do?
         if 'tocSize_%s'%tocMode in docinfo: