--- zogiLib/zogiLib.py 2004/06/02 19:01:36 1.20
+++ zogiLib/zogiLib.py 2004/06/03 18:05:57 1.22
@@ -427,13 +427,14 @@ class zogiLib(Folder):
{'label':'Main Config','action':'changeZogiLibForm'},
)
- def __init__(self, id,title,digilibBaseUrl, localFileBase,version="book"):
+ def __init__(self, id, title, digilibBaseUrl, localFileBase, version="book", basePath=""):
"""init"""
self.id=id
self.title=title
self.digilibBaseUrl=digilibBaseUrl
self.localFileBase=localFileBase
+ self.basePath=basePath
self.layout=version
@@ -463,12 +464,12 @@ class zogiLib(Folder):
return pt()
- def createScalerImg(self, requestString = None):
+ def createScalerImg(self, requestString = None, bottom = 0, side = 0):
"""generate Scaler IMG Tag"""
self.checkQuery()
bt = self.REQUEST.SESSION['browserType']
if not requestString:
- requestString = self.REQUEST.QUERY_STRING
+ requestString = self.getAllDLParams()
url = self.digilibBaseUrl+requestString
tag = ""
if bt.isN4:
@@ -477,7 +478,12 @@ class zogiLib(Folder):
tag += '
'
tag += ''
if bt.isN4:
tag += ''
@@ -563,6 +569,21 @@ class zogiLib(Folder):
"""mark image"""
return sendFile(self, 'images/urechts.gif', 'image/gif')
+ def up_img(self):
+ """mark image"""
+ return sendFile(self, 'images/up.gif', 'image/gif')
+
+ def down_img(self):
+ """mark image"""
+ return sendFile(self, 'images/down.gif', 'image/gif')
+
+ def left_img(self):
+ """mark image"""
+ return sendFile(self, 'images/left.gif', 'image/gif')
+
+ def right_img(self):
+ """mark image"""
+ return sendFile(self, 'images/right.gif', 'image/gif')
@@ -577,12 +598,20 @@ class zogiLib(Folder):
- def storeQuery(self):
+ def storeQuery(self, more = None):
"""storeQuery in session"""
dlParams = {}
for fm in self.REQUEST.form.keys():
dlParams[fm] = self.REQUEST.form[fm]
-
+ # look for more
+ if more:
+ for fm in more.split('&'):
+ try:
+ pv = fm.split('=')
+ dlParams[pv[0]] = pv[1]
+ except:
+ print "ouch!"
+ # parse digilib mode parameter
if 'mo' in dlParams:
if len(dlParams['mo']) > 0:
modes=dlParams['mo'].split(',')
@@ -596,11 +625,11 @@ class zogiLib(Folder):
def checkQuery(self):
"""check if the query has been stored"""
- if not (self.REQUEST.SESSION and 'query' in self.REQUEST.SESSION):
+ if not (self.REQUEST.SESSION):
print "ZOGILIB: have to store query!!"
storeQuery(self)
- def getDLParam(self,param):
+ def getDLParam(self, param):
"""returns parameter"""
try:
return self.REQUEST.SESSION['query'][param]
@@ -639,6 +668,8 @@ class zogiLib(Folder):
self.setDLParam('cont', cont)
if pn:
+ # unmark
+ self.setDLParam('mk', None)
self.setDLParam('pn', pn)
if ws:
@@ -653,7 +684,10 @@ class zogiLib(Folder):
def display(self):
"""(re)display page"""
params = self.getAllDLParams()
- self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params)
+ if self.basePath:
+ self.REQUEST.RESPONSE.redirect(self.REQUEST['URL2']+'?'+params)
+ else:
+ self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params)
def getPT(self):
"""pagenums"""
@@ -678,7 +712,6 @@ class zogiLib(Folder):
return int(ws)+1
else:
return 2
-
def getSmallerWS(self):
"""ws-1"""
@@ -706,7 +739,28 @@ class zogiLib(Folder):
pn = self.getPN()
return (pn > 1)
-
+ def canMoveLeft(self):
+ """returns if its possible to move left"""
+ wx = float(self.getDLParam('wx') or 0)
+ return (wx > 0)
+
+ def canMoveRight(self):
+ """returns if its possible to move right"""
+ wx = float(self.getDLParam('wx') or 0)
+ ww = float(self.getDLParam('ww') or 1)
+ return (wx + ww < 1)
+
+ def canMoveUp(self):
+ """returns if its possible to move up"""
+ wy = float(self.getDLParam('wy') or 0)
+ return (wy > 0)
+
+ def canMoveDown(self):
+ """returns if its possible to move down"""
+ wy = float(self.getDLParam('wy') or 0)
+ wh = float(self.getDLParam('wh') or 1)
+ return (wy + wh < 1)
+
def dl_HMirror(self):
"""mirror action"""
@@ -728,6 +782,66 @@ class zogiLib(Folder):
return self.display()
+ def dl_Zoom(self, z):
+ """general zoom action"""
+ ww1 = float(self.getDLParam('ww') or 1)
+ wh1 = float(self.getDLParam('wh') or 1)
+ wx = float(self.getDLParam('wx') or 0)
+ wy = float(self.getDLParam('wy') or 0)
+ ww2 = ww1 * z
+ wh2 = wh1 * z
+ wx += (ww1 - ww2) / 2
+ wy += (wh1 - wh2) / 2
+ ww2 = max(min(ww2, 1), 0)
+ wh2 = max(min(wh2, 1), 0)
+ wx = max(min(wx, 1), 0)
+ wy = max(min(wy, 1), 0)
+ self.setDLParam('ww', ww2)
+ self.setDLParam('wh', wh2)
+ self.setDLParam('wx', wx)
+ self.setDLParam('wy', wy)
+ return self.display()
+
+ def dl_ZoomIn(self):
+ """zoom in action"""
+ z = 0.7071
+ return self.dl_Zoom(z)
+
+ def dl_ZoomOut(self):
+ """zoom out action"""
+ z = 1.4142
+ return self.dl_Zoom(z)
+
+ def dl_Move(self, dx, dy):
+ """general move action"""
+ ww = float(self.getDLParam('ww') or 1)
+ wh = float(self.getDLParam('wh') or 1)
+ wx = float(self.getDLParam('wx') or 0)
+ wy = float(self.getDLParam('wy') or 0)
+ wx += dx * 0.5 * ww
+ wy += dy * 0.5 * wh
+ wx = max(min(wx, 1), 0)
+ wy = max(min(wy, 1), 0)
+ self.setDLParam('wx', wx)
+ self.setDLParam('wy', wy)
+ return self.display()
+
+ def dl_MoveLeft(self):
+ """move left action"""
+ return self.dl_Move(-1, 0)
+
+ def dl_MoveRight(self):
+ """move left action"""
+ return self.dl_Move(1, 0)
+
+ def dl_MoveUp(self):
+ """move left action"""
+ return self.dl_Move(0, -1)
+
+ def dl_MoveDown(self):
+ """move left action"""
+ return self.dl_Move(0, 1)
+
def dl_WholePage(self):
"""zoom out action"""
self.setDLParam('ww', 1)
@@ -788,11 +902,12 @@ class zogiLib(Folder):
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiLibForm.zpt')).__of__(self)
return pt()
- def changeZogiLib(self,title,digilibBaseUrl, localFileBase, version, RESPONSE=None):
+ def changeZogiLib(self,title,digilibBaseUrl, localFileBase, version, basePath, RESPONSE=None):
"""change it"""
self.title=title
self.digilibBaseUrl=digilibBaseUrl
self.localFileBase=localFileBase
+ self.basePath = basePath
self.layout=version
if RESPONSE is not None:
@@ -804,9 +919,9 @@ def manage_addZogiLibForm(self):
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibForm')).__of__(self)
return pt()
-def manage_addZogiLib(self,id,title,digilibBaseUrl, localFileBase,version="book",RESPONSE=None):
+def manage_addZogiLib(self,id,title,digilibBaseUrl, localFileBase,version="book",basePath="",RESPONSE=None):
"""add dgilib"""
- newObj=zogiLib(id,title,digilibBaseUrl, localFileBase, version)
+ newObj=zogiLib(id,title,digilibBaseUrl, localFileBase, version, basePath)
self.Destination()._setObject(id,newObj)
if RESPONSE is not None:
RESPONSE.redirect('manage_main')