--- ECHO_content/VLPExtension.py 2004/06/08 17:17:07 1.8 +++ ECHO_content/VLPExtension.py 2004/07/14 13:33:31 1.12 @@ -1,9 +1,11 @@ -from ECHO_collection import * +from Products.ECHO_content.ECHO_collection import * from Products.PageTemplates.PageTemplateFile import PageTemplateFile from Products.PageTemplates.PageTemplate import PageTemplate from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from Products.zogiLib import zogiLib +import xml.dom.minidom +import urllib def getText(nodelist): @@ -22,6 +24,21 @@ class VLP_essay(Folder): {'label':'Main Config','action':'ConfigVLP_essayForm'}, ) + def content_html(self,type='collection'): + """template fuer content""" + #templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) + # + #if templates: + # return templates[0][1]() + + if hasattr(self,type+"_template"): + obj=getattr(self,type+"_template") + return obj() + else: + pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_%s_template_standard.zpt'%type).__of__(self) + pt.content_type="text/html" + return pt() + def ConfigVLP_essayForm(self): """Form for adding""" pt=PageTemplateFile('Products/ECHO_content/vlp/ChangeVLP_essay.zpt').__of__(self) @@ -200,6 +217,11 @@ class VLP_resource(ECHO_resource): def show(self): """show the rendered file""" + + if self.REQUEST.get('p',None): + self.REQUEST.set('pn',self.file2page(self.REQUEST.get('p',None))) + + pt=PageTemplateFile('Products/ECHO_content/vlp/library_template.zpt').__of__(self) pt.content_type="text/html" return pt() @@ -208,11 +230,21 @@ class VLP_resource(ECHO_resource): def index_meta(self): """index_meta""" + pt=PageTemplateFile('Products/ECHO_content/vlp/index_meta.zpt').__of__(self) pt.content_type="text/html" return pt() - + def file2page(self,p): + """converts filename to pagenumber""" + dom=xml.dom.minidom.parse(urllib.urlopen(getattr(self,'index.xml').absolute_url())) + + for page in dom.getElementsByTagName('page'): + if page.getAttribute('file')==p: + return page.getAttribute('nr') + + return 0 + def dir2index(self): """dir to index""" @@ -230,9 +262,10 @@ class VLP_resource(ECHO_resource): for x in ret: if not (x[0]=="."): - temp.append(calculateName(x)) + temp.append((calculateName(x),os.path.splitext(x)[0])) return temp + def firstPage(self,url=None): """showlink to the first image""" if self.REQUEST.get('pn')=="1": #erste seinte dann kein a tag