Changeset 480:50a28442f21c in documentViewer for documentViewer.py
- Timestamp:
- Aug 15, 2011, 7:09:08 PM (13 years ago)
- Branch:
- elementtree
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
documentViewer.py
r479 r480 1 1 from OFS.Folder import Folder 2 from OFS.Image import File 2 3 from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate 3 4 from Products.PageTemplates.PageTemplateFile import PageTemplateFile … … 136 137 page_main_pureXml = PageTemplateFile('zpt/page_main_pureXml', globals()) 137 138 head_main = PageTemplateFile('zpt/head_main', globals()) 138 docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())139 139 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') 140 142 141 143 … … 348 350 url = self.template.zogilib.getDLBaseUrl() 349 351 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 350 371 351 372 def getDocumentViewerURL(self): … … 354 375 355 376 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.""" 357 378 #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) 358 379 if idx == selected: … … 709 730 current = getInt(current) 710 731 pageinfo['current'] = current 732 pageinfo['pn'] = current 711 733 rows = int(rows or self.thumbrows) 712 734 pageinfo['rows'] = rows … … 719 741 # int(current / grpsize) * grpsize +1)) 720 742 pageinfo['start'] = start 721 pn = self.REQUEST.get('pn','1') 722 pageinfo['pn'] = pn 743 723 744 np = int(docinfo.get('numPages', 0)) 724 745 if np == 0: … … 726 747 if docinfo.get('textURLPath', None): 727 748 # 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) 729 750 np = int(docinfo.get('numPages', 0)) 730 751 … … 738 759 pageZero = (cols == 2 and (pageFlowLtr != oddScanLeft)) 739 760 pageinfo['pageZero'] = pageZero 740 pageinfo['page List'] = 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) 741 762 763 # TODO: do we need this here? 742 764 pageinfo['characterNormalization'] = self.REQUEST.get('characterNormalization','reg') 743 765 pageinfo['query'] = self.REQUEST.get('query','') … … 765 787 766 788 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 769 792 if maxIdx == 0: 770 maxIdx = start + rows * cols793 maxIdx = start + grpsize 771 794 772 795 pages = [] … … 793 816 pages.append(row) 794 817 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 797 832 798 833
Note: See TracChangeset
for help on using the changeset viewer.