version 1.26, 2004/06/07 17:56:55
|
version 1.30, 2004/06/25 16:59:45
|
Line 15 import urllib
|
Line 15 import urllib
|
import types |
import types |
from Globals import package_home |
from Globals import package_home |
|
|
|
ZOGIVERSION = "0.9.5 ROC:25.6.2004" |
|
|
|
def cropf(f): |
|
"""returns a float with reduced precision""" |
|
return float(int(f * 10000)/10000.0) |
|
|
|
|
def sendFile(self, filename, type): |
def sendFile(self, filename, type): |
"""sends an object or a local file (in the product) as response""" |
"""sends an object or a local file (in the product) as response""" |
paths = filename.split('/') |
paths = filename.split('/') |
Line 55 def browserCheck(self):
|
Line 62 def browserCheck(self):
|
|
|
return bt |
return bt |
|
|
def manage_addZogiLibMainTemplateForm(self): |
|
"""Form for adding""" |
|
#FIXME:??? |
|
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/AddOSAS_thumbTemplate.zpt')).__of__(self) |
|
return pt() |
|
|
|
|
|
|
|
|
|
def manage_addZogiLibMainTemplate(self, id,title=None, text=None, |
|
REQUEST=None, submit=None): |
|
"Add a Page Template with optional file content." |
|
#FIXME:??? |
|
id = str(id) |
|
if REQUEST is None: |
|
self._setObject(id, zogiLib_mainTemplate(id, text)) |
|
ob = getattr(self, id) |
|
|
|
if title: |
|
ob.pt_setTitle(title) |
|
return ob |
|
else: |
|
file = REQUEST.form.get('file') |
|
headers = getattr(file, 'headers', None) |
|
if headers is None or not file.filename: |
|
zpt = zogiLib_mainTemplate(id) |
|
else: |
|
zpt = zogiLib_mainTemplate(id, file, headers.get('content_type')) |
|
|
|
self._setObject(id, zpt) |
|
ob = getattr(self, id) |
|
|
|
|
|
try: |
|
u = self.DestinationURL() |
|
except AttributeError: |
|
u = REQUEST['URL1'] |
|
|
|
if submit == " Add and Edit ": |
|
u = "%s/%s" % (u, quote(id)) |
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
|
return '' |
|
|
|
|
|
class zogiImage(Image): |
class zogiImage(Image): |
"""einzelnes Image""" |
"""einzelnes Image""" |
Line 424 class zogiLib(Folder):
|
Line 388 class zogiLib(Folder):
|
{'label':'Main Config','action':'changeZogiLibForm'}, |
{'label':'Main Config','action':'changeZogiLibForm'}, |
) |
) |
|
|
def __init__(self, id, title, digilibBaseUrl, localFileBase, version="book", basePath=""): |
def __init__(self, id, title, digilibBaseUrl, localFileBase, version="book", basePath="", dlTarget=None): |
"""init""" |
"""init""" |
|
|
self.id=id |
self.id=id |
Line 433 class zogiLib(Folder):
|
Line 397 class zogiLib(Folder):
|
self.localFileBase=localFileBase |
self.localFileBase=localFileBase |
self.basePath=basePath |
self.basePath=basePath |
self.layout=version |
self.layout=version |
|
if dlTarget: |
|
self.dlTarget = dlTarget |
|
else: |
|
self.dlTarget = "digilib" |
|
|
|
def version(self): |
|
"""version information""" |
|
return ZOGIVERSION |
|
|
def getDLInfo(self): |
def getDLInfo(self): |
"""get DLInfo from digilib server""" |
"""get DLInfo from digilib server""" |
Line 536 class zogiLib(Folder):
|
Line 507 class zogiLib(Folder):
|
|
|
|
|
def option_js(self): |
def option_js(self): |
"""option_js""" |
"""javascript""" |
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/option_js')).__of__(self) |
return sendFile(self, 'js/option.js', 'text/plain') |
return pt() |
|
|
|
def dl_lib_js(self): |
def dl_lib_js(self): |
"""javascript""" |
"""javascript""" |
Line 714 class zogiLib(Folder):
|
Line 684 class zogiLib(Folder):
|
# assemble query string |
# assemble query string |
ret = "" |
ret = "" |
for param in dlParams.keys(): |
for param in dlParams.keys(): |
|
if dlParams[param] is None: continue |
val = str(dlParams[param]) |
val = str(dlParams[param]) |
if val != "": |
if val != "": |
ret += param + "=" + val + "&" |
ret += param + "=" + val + "&" |
|
|
# omit trailing "&" |
# omit trailing "&" |
return ret.rstrip('&') |
return ret.rstrip('&') |
|
|
Line 746 class zogiLib(Folder):
|
Line 718 class zogiLib(Folder):
|
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params) |
self.REQUEST.RESPONSE.redirect(self.REQUEST['URL1']+'?'+params) |
|
|
|
|
|
def getDLTarget(self): |
|
"""returns dlTarget""" |
|
self.checkQuery() |
|
s = self.dlTarget |
|
# s = 'dl' |
|
# if self.getDLParam('fn'): |
|
# s += "_" + self.getDLParam('fn') |
|
# if self.getDLParam('pn'): |
|
# s += "_" + self.getDLParam('pn') |
|
return s |
|
|
def setStaticHTML(self, static=True): |
def setStaticHTML(self, static=True): |
"""sets the preference to static HTML""" |
"""sets the preference to static HTML""" |
self.checkQuery() |
self.checkQuery() |
Line 873 class zogiLib(Folder):
|
Line 856 class zogiLib(Folder):
|
wh2 = max(min(wh2, 1), 0) |
wh2 = max(min(wh2, 1), 0) |
wx = max(min(wx, 1), 0) |
wx = max(min(wx, 1), 0) |
wy = max(min(wy, 1), 0) |
wy = max(min(wy, 1), 0) |
self.setDLParam('ww', ww2) |
self.setDLParam('ww', cropf(ww2)) |
self.setDLParam('wh', wh2) |
self.setDLParam('wh', cropf(wh2)) |
self.setDLParam('wx', wx) |
self.setDLParam('wx', cropf(wx)) |
self.setDLParam('wy', wy) |
self.setDLParam('wy', cropf(wy)) |
return self.display() |
return self.display() |
|
|
def dl_ZoomIn(self): |
def dl_ZoomIn(self): |
Line 899 class zogiLib(Folder):
|
Line 882 class zogiLib(Folder):
|
wy += dy * 0.5 * wh |
wy += dy * 0.5 * wh |
wx = max(min(wx, 1), 0) |
wx = max(min(wx, 1), 0) |
wy = max(min(wy, 1), 0) |
wy = max(min(wy, 1), 0) |
self.setDLParam('wx', wx) |
self.setDLParam('wx', cropf(wx)) |
self.setDLParam('wy', wy) |
self.setDLParam('wy', cropf(wy)) |
return self.display() |
return self.display() |
|
|
def dl_MoveLeft(self): |
def dl_MoveLeft(self): |
Line 979 class zogiLib(Folder):
|
Line 962 class zogiLib(Folder):
|
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiLibForm.zpt')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/changeZogiLibForm.zpt')).__of__(self) |
return pt() |
return pt() |
|
|
def changeZogiLib(self,title,digilibBaseUrl, localFileBase, version, basePath, RESPONSE=None): |
def changeZogiLib(self,title,digilibBaseUrl, localFileBase, version, basePath, dlTarget, RESPONSE=None): |
"""change it""" |
"""change it""" |
self.title=title |
self.title=title |
self.digilibBaseUrl=digilibBaseUrl |
self.digilibBaseUrl=digilibBaseUrl |
self.localFileBase=localFileBase |
self.localFileBase=localFileBase |
self.basePath = basePath |
self.basePath = basePath |
self.layout=version |
self.layout=version |
|
if dlTarget: |
|
self.dlTarget = dlTarget |
|
else: |
|
self.dlTarget = "digilib" |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
Line 996 def manage_addZogiLibForm(self):
|
Line 983 def manage_addZogiLibForm(self):
|
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibForm')).__of__(self) |
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibForm')).__of__(self) |
return pt() |
return pt() |
|
|
def manage_addZogiLib(self,id,title,digilibBaseUrl, localFileBase,version="book",basePath="",RESPONSE=None): |
def manage_addZogiLib(self,id,title,digilibBaseUrl, localFileBase,version="book",basePath="",dlTarget="digilib",RESPONSE=None): |
"""add dgilib""" |
"""add dgilib""" |
newObj=zogiLib(id,title,digilibBaseUrl, localFileBase, version, basePath) |
newObj=zogiLib(id,title,digilibBaseUrl, localFileBase, version, basePath, dlTarget) |
self.Destination()._setObject(id,newObj) |
self.Destination()._setObject(id,newObj) |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
class zogiLibPageTemplate(ZopePageTemplate): |
|
"""pageTemplate Objekt""" |
|
meta_type="zogiLib_pageTemplate" |
|
|
|
|
|
## def __init__(self, id, text=None, contentType=None): |
|
## self.id = str(id) |
|
## self.ZBindings_edit(self._default_bindings) |
|
## if text is None: |
|
## text = open(self._default_cont).read() |
|
## self.pt_edit(text, contentType) |
|
|
|
def manage_addZogiLibPageTemplateForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/addZogiLibPageTemplateForm')).__of__(self) |
|
return pt() |
|
|
|
def manage_addZogiLibPageTemplate(self, id='zogiLibMainTemplate', title=None, layout=None, text=None, |
|
REQUEST=None, submit=None): |
|
"Add a Page Template with optional file content." |
|
|
|
id = str(id) |
|
self._setObject(id, zogiLibPageTemplate(id)) |
|
ob = getattr(self, id) |
|
if not layout: layout = "book" |
|
ob.pt_edit(open(os.path.join(package_home(globals()),'zpt/zogiLibMain_%s.zpt'%layout)).read(),None) |
|
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 '' |