Changeset 480:50a28442f21c in documentViewer for documentViewer.py


Ignore:
Timestamp:
Aug 15, 2011, 7:09:08 PM (13 years ago)
Author:
casties
Branch:
elementtree
Message:

more new template stuff

File:
1 edited

Legend:

Unmodified
Added
Removed
  • documentViewer.py

    r479 r480  
    11from OFS.Folder import Folder
     2from OFS.Image import File
    23from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate
    34from Products.PageTemplates.PageTemplateFile import PageTemplateFile
     
    136137    page_main_pureXml = PageTemplateFile('zpt/page_main_pureXml', globals())
    137138    head_main = PageTemplateFile('zpt/head_main', globals())
    138     docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())
    139139    info_xml = PageTemplateFile('zpt/info_xml', globals())
     140    # TODO: can this be nicer?
     141    docuviewer_css = File('docuviewer_css','',open(os.path.join(package_home(globals()),'css/docuviewer.css')), content_type='text/css')
    140142   
    141143   
     
    348350        url = self.template.zogilib.getDLBaseUrl()
    349351        return url
     352   
     353    def getScalerUrl(self, fn=None, pn=None, dw=100, dh=100, docinfo=None):
     354        """returns URL to digilib Scaler with params"""
     355        url = None
     356        if docinfo is not None:
     357            url = docinfo.get('imageURL', None)
     358           
     359        if url is None:
     360            url = "%s/servlet/Scaler?"%self.digilibBaseUrl
     361            if fn is None and docinfo is not None:
     362                fn = docinfo.get('imagePath','')
     363           
     364            url += "fn=%s"%fn
     365           
     366        if pn:
     367            url += "&pn=%s"%pn
     368           
     369        url += "&dw=%s&dh=%s"%(dw,dh)
     370        return url
    350371
    351372    def getDocumentViewerURL(self):
     
    354375   
    355376    def getStyle(self, idx, selected, style=""):
    356         """returns a string with the given style and append 'sel' if path == selected."""
     377        """returns a string with the given style and append 'sel' if idx == selected."""
    357378        #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style))
    358379        if idx == selected:
     
    709730        current = getInt(current)
    710731        pageinfo['current'] = current
     732        pageinfo['pn'] = current
    711733        rows = int(rows or self.thumbrows)
    712734        pageinfo['rows'] = rows
     
    719741        # int(current / grpsize) * grpsize +1))
    720742        pageinfo['start'] = start
    721         pn = self.REQUEST.get('pn','1')
    722         pageinfo['pn'] = pn
     743       
    723744        np = int(docinfo.get('numPages', 0))
    724745        if np == 0:
     
    726747            if docinfo.get('textURLPath', None):
    727748                # cache text page as well
    728                 pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=pn, docinfo=docinfo, pageinfo=pageinfo)
     749                pageinfo['textPage'] = self.getTextPage(mode=viewType, pn=current, docinfo=docinfo, pageinfo=pageinfo)
    729750                np = int(docinfo.get('numPages', 0))
    730751               
     
    738759        pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft))
    739760        pageinfo['pageZero'] = pageZero
    740         pageinfo['pageList'] = self.getPageList(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np)
     761        pageinfo['pageBatch'] = self.getPageBatch(start=start, rows=rows, cols=cols, pageFlowLtr=pageFlowLtr, pageZero=pageZero, minIdx=1, maxIdx=np)
    741762               
     763        # TODO: do we need this here?
    742764        pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg')
    743765        pageinfo['query'] = self.REQUEST.get('query','')
     
    765787
    766788
    767     def getPageList(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0):
    768         """returns array of page informations for one screenfull of thumbnails"""
     789    def getPageBatch(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0):
     790        """returns dict with array of page informations for one screenfull of thumbnails"""
     791        grpsize = rows * cols
    769792        if maxIdx == 0:
    770             maxIdx = start + rows * cols
     793            maxIdx = start + grpsize
    771794
    772795        pages = []
     
    793816            pages.append(row)
    794817           
    795         logging.debug("getPageList returns=%s"%(pages))
    796         return pages
     818        batch = {}
     819        if start > 1:
     820            batch['prevStart'] = max(start - grpsize, 1)
     821        else:
     822            batch['prevStart'] = None
     823           
     824        if start + grpsize < maxIdx:
     825            batch['nextStart'] = start + grpsize
     826        else:
     827            batch['nextStart'] = None
     828
     829        batch['pages'] = pages
     830        #logging.debug("getPageList returns=%s"%(batch))
     831        return batch
    797832       
    798833
Note: See TracChangeset for help on using the changeset viewer.