comparison documentViewer.py @ 57:7cdb0fc34a92

added getInfo_xml method
author casties
date Fri, 04 May 2007 15:17:02 +0200
parents ba8917b93c84
children 996b61d71351
comparison
equal deleted inserted replaced
56:0bc0d56cae7d 57:7cdb0fc34a92
78 viewer_main = PageTemplateFile('zpt/viewer_main', globals()) 78 viewer_main = PageTemplateFile('zpt/viewer_main', globals())
79 thumbs_main = PageTemplateFile('zpt/thumbs_main', globals()) 79 thumbs_main = PageTemplateFile('zpt/thumbs_main', globals())
80 image_main = PageTemplateFile('zpt/image_main', globals()) 80 image_main = PageTemplateFile('zpt/image_main', globals())
81 head_main = PageTemplateFile('zpt/head_main', globals()) 81 head_main = PageTemplateFile('zpt/head_main', globals())
82 docuviewer_css = PageTemplateFile('css/docuviewer.css', globals()) 82 docuviewer_css = PageTemplateFile('css/docuviewer.css', globals())
83 info_xml = PageTemplateFile('zpt/info_xml', globals())
83 84
84 security.declareProtected('View management screens','changeDocumentViewerForm') 85 security.declareProtected('View management screens','changeDocumentViewerForm')
85 changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals()) 86 changeDocumentViewerForm = PageTemplateFile('zpt/changeDocumentViewer', globals())
86 87
87 88
106 107
107 security.declareProtected('View','index_html') 108 security.declareProtected('View','index_html')
108 def index_html(self,mode,url,viewMode="auto",start=None,pn=1): 109 def index_html(self,mode,url,viewMode="auto",start=None,pn=1):
109 ''' 110 '''
110 view it 111 view it
111 @param mode: defines which type of document is behind url (text,images or auto) 112 @param mode: defines how to access the document behind url
112 @param url: url which contains display information 113 @param url: url which contains display information
113 @param viewMode: if images display images, if text display text, default is images 114 @param viewMode: if images display images, if text display text, default is images (text,images or auto)
114 115
115 ''' 116 '''
116 117
117 logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn)) 118 logger("documentViewer (index)", logging.INFO, "mode: %s url:%s start:%s pn:%s"%(mode,url,start,pn))
118 119
131 if docinfo.get("textURL",'') and self.textViewerUrl: #texturl gesetzt und textViewer konfiguriert 132 if docinfo.get("textURL",'') and self.textViewerUrl: #texturl gesetzt und textViewer konfiguriert
132 viewMode="text" 133 viewMode="text"
133 else: 134 else:
134 viewMode="images" 135 viewMode="images"
135 136
136
137 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode) 137 return pt(docinfo=docinfo,pageinfo=pageinfo,viewMode=viewMode)
138 138
139 139
140 def getLink(self,param=None,val=None): 140 def getLink(self,param=None,val=None):
141 """link to documentviewer with parameter param set to val""" 141 """link to documentviewer with parameter param set to val"""
150 # quote values and assemble into query string 150 # quote values and assemble into query string
151 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()]) 151 ps = "&".join(["%s=%s"%(k,urllib.quote(v)) for (k, v) in params.items()])
152 url=self.REQUEST['URL1']+"?"+ps 152 url=self.REQUEST['URL1']+"?"+ps
153 return url 153 return url
154 154
155
156 def getInfo_xml(self,url,mode):
157 """returns info about the document as XML"""
158
159 if not self.digilibBaseUrl:
160 self.digilibBaseUrl = self.findDigilibUrl() or "http://nausikaa.mpiwg-berlin.mpg.de/digitallibrary"
161
162 docinfo = self.getDocinfo(mode=mode,url=url)
163 pt = getattr(self.template, 'info_xml')
164 return pt(docinfo=docinfo)
165
155 166
156 def getStyle(self, idx, selected, style=""): 167 def getStyle(self, idx, selected, style=""):
157 """returns a string with the given style and append 'sel' if path == selected.""" 168 """returns a string with the given style and append 'sel' if path == selected."""
158 #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style)) 169 #logger("documentViewer (getstyle)", logging.INFO, "idx: %s selected: %s style: %s"%(idx,selected,style))
159 if idx == selected: 170 if idx == selected:
160 return style + 'sel' 171 return style + 'sel'
161 else: 172 else:
162 return style 173 return style
163 174
164 175
165 def isAccessible(self, docinfo): 176 def isAccessible(self, docinfo):
166 """returns if access to the resource is granted""" 177 """returns if access to the resource is granted"""
167 access = docinfo.get('accessType', None) 178 access = docinfo.get('accessType', None)
168 logger("documentViewer (accessOK)", logging.INFO, "access type %s"%access) 179 logger("documentViewer (accessOK)", logging.INFO, "access type %s"%access)