version 1.175.2.26, 2011/08/15 19:09:08
|
version 1.175.2.29, 2011/08/22 15:00:28
|
Line 2 from OFS.Folder import Folder
|
Line 2 from OFS.Folder import Folder
|
from OFS.Image import File |
from OFS.Image import File |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
|
from Products.ZSimpleFile import ZSimpleFile |
from AccessControl import ClassSecurityInfo |
from AccessControl import ClassSecurityInfo |
from AccessControl import getSecurityManager |
from AccessControl import getSecurityManager |
from Globals import package_home |
from Globals import package_home |
Line 124 class documentViewer(Folder):
|
Line 125 class documentViewer(Folder):
|
|
|
# templates and forms |
# templates and forms |
viewer_text = PageTemplateFile('zpt/viewer_text', globals()) |
viewer_text = PageTemplateFile('zpt/viewer_text', globals()) |
|
viewer_images = PageTemplateFile('zpt/viewer_images', globals()) |
viewer_main = PageTemplateFile('zpt/viewer_main', globals()) |
viewer_main = PageTemplateFile('zpt/viewer_main', globals()) |
toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals()) |
toc_thumbs = PageTemplateFile('zpt/toc_thumbs', globals()) |
toc_text = PageTemplateFile('zpt/toc_text', globals()) |
toc_text = PageTemplateFile('zpt/toc_text', globals()) |
Line 138 class documentViewer(Folder):
|
Line 140 class documentViewer(Folder):
|
head_main = PageTemplateFile('zpt/head_main', globals()) |
head_main = PageTemplateFile('zpt/head_main', globals()) |
info_xml = PageTemplateFile('zpt/info_xml', globals()) |
info_xml = PageTemplateFile('zpt/info_xml', globals()) |
# TODO: can this be nicer? |
# TODO: can this be nicer? |
docuviewer_css = File('docuviewer_css','',open(os.path.join(package_home(globals()),'css/docuviewer.css')), content_type='text/css') |
docuviewer_css = ZSimpleFile(content_type='text/css',filename='css/docuviewer.css', id='docuviewer_css',_prefix=globals()) |
|
|
|
|
thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals()) |
thumbs_main_rss = PageTemplateFile('zpt/thumbs_main_rss', globals()) |
Line 555 class documentViewer(Folder):
|
Line 557 class documentViewer(Folder):
|
# override image path from texttool with url |
# override image path from texttool with url |
docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1) |
docinfo['imagePath'] = url.replace('/mpiwg/online/', '', 1) |
|
|
|
|
|
|
# number of images from digilib |
# number of images from digilib |
if docinfo.get('imagePath', None): |
if docinfo.get('imagePath', None): |
docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + docinfo['imagePath'] |
docinfo['imageURL'] = self.digilibBaseUrl + "/servlet/Scaler?fn=" + docinfo['imagePath'] |
Line 786 class documentViewer(Folder):
|
Line 786 class documentViewer(Folder):
|
return pageinfo |
return pageinfo |
|
|
|
|
def getPageBatch(self, start=None, rows=None, cols=None, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): |
def getPageBatch(self, start=1, rows=10, cols=2, pageFlowLtr=True, pageZero=False, minIdx=1, maxIdx=0): |
"""returns dict with array of page informations for one screenfull of thumbnails""" |
"""returns dict with array of page informations for one screenfull of thumbnails""" |
|
batch = {} |
grpsize = rows * cols |
grpsize = rows * cols |
if maxIdx == 0: |
if maxIdx == 0: |
maxIdx = start + grpsize |
maxIdx = start + grpsize |
|
|
|
nb = int(math.ceil(maxIdx / float(grpsize))) |
|
# list of all batch start and end points |
|
batches = [] |
|
if pageZero: |
|
ofs = 0 |
|
else: |
|
ofs = 1 |
|
|
|
for i in range(nb): |
|
s = i * grpsize + ofs |
|
e = min((i + 1) * grpsize + ofs - 1, maxIdx) |
|
batches.append({'start':s, 'end':e}) |
|
|
|
batch['batches'] = batches |
|
|
pages = [] |
pages = [] |
if pageZero and start == 1: |
if pageZero and start == 1: |
# correct beginning |
# correct beginning |
Line 815 class documentViewer(Folder):
|
Line 831 class documentViewer(Folder):
|
|
|
pages.append(row) |
pages.append(row) |
|
|
batch = {} |
|
if start > 1: |
if start > 1: |
batch['prevStart'] = max(start - grpsize, 1) |
batch['prevStart'] = max(start - grpsize, 1) |
else: |
else: |
Line 827 class documentViewer(Folder):
|
Line 842 class documentViewer(Folder):
|
batch['nextStart'] = None |
batch['nextStart'] = None |
|
|
batch['pages'] = pages |
batch['pages'] = pages |
#logging.debug("getPageList returns=%s"%(batch)) |
return batch |
|
|
|
def getBatch(self, start=1, size=10, end=0, data=None, fullData=True): |
|
"""returns dict with information for one screenfull of data.""" |
|
batch = {} |
|
if end == 0: |
|
end = start + size |
|
|
|
nb = int(math.ceil(end / float(size))) |
|
# list of all batch start and end points |
|
batches = [] |
|
for i in range(nb): |
|
s = i * size + 1 |
|
e = min((i + 1) * size, end) |
|
batches.append({'start':s, 'end':e}) |
|
|
|
batch['batches'] = batches |
|
# list of elements in this batch |
|
this = [] |
|
j = 0 |
|
for i in range(start, min(start+size, end)): |
|
if data: |
|
if fullData: |
|
d = data[i] |
|
else: |
|
d = data[j] |
|
j += 1 |
|
|
|
else: |
|
d = i+1 |
|
|
|
this.append(d) |
|
|
|
batch['this'] = this |
|
if start > 1: |
|
batch['prevStart'] = max(start - size, 1) |
|
else: |
|
batch['prevStart'] = None |
|
|
|
if start + size < end: |
|
batch['nextStart'] = start + size |
|
else: |
|
batch['nextStart'] = None |
|
|
return batch |
return batch |
|
|
|
|
Line 862 def manage_AddDocumentViewer(self,id,ima
|
Line 920 def manage_AddDocumentViewer(self,id,ima
|
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
## DocumentViewerTemplate class |
|
class DocumentViewerTemplate(ZopePageTemplate): |
|
"""Template for document viewer""" |
|
meta_type="DocumentViewer Template" |
|
|
|
|
|
def manage_addDocumentViewerTemplateForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile('zpt/addDocumentViewerTemplate', globals()).__of__(self) |
|
return pt() |
|
|
|
def manage_addDocumentViewerTemplate(self, id='viewer_main', title=None, text=None, |
|
REQUEST=None, submit=None): |
|
"Add a Page Template with optional file content." |
|
|
|
self._setObject(id, DocumentViewerTemplate(id)) |
|
ob = getattr(self, id) |
|
txt=file(os.path.join(package_home(globals()),'zpt/viewer_main.zpt'),'r').read() |
|
logging.info("txt %s:"%txt) |
|
ob.pt_edit(txt,"text/html") |
|
if title: |
|
ob.pt_setTitle(title) |
|
try: |
|
u = self.DestinationURL() |
|
except AttributeError: |
|
u = REQUEST['URL1'] |
|
|
|
u = "%s/%s" % (u, urllib.quote(id)) |
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
|
|
|
|
|