--- ECHO_content/VLPExtension.py 2004/06/04 10:04:16 1.5 +++ ECHO_content/VLPExtension.py 2004/06/25 11:02:16 1.10 @@ -1,4 +1,4 @@ -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 @@ -13,6 +13,93 @@ def getText(nodelist): rc = rc + node.data return rc +class VLP_essay(Folder): + """classe für VLP essays""" + + meta_type="VLP_essay" + + manage_options = Folder.manage_options+( + {'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) + return pt() + + def ChangeVLP_essay(self,title,label,description,RESPONSE=None): + """Change vlp_essay""" + self.title=title + self.label=label + self.description=description + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + def __init__(self,id,title,label): + """init""" + self.id=id + self.title=title + self.label=label + + def getPage(self,pagenum): + """gibt essay page mit num aus""" + def sortFind(x,y): + return cmp(x[0],y[0]) + + pages=self.ZopeFind(self,obj_metatypes=['DTML Document','File']) + + pages.sort(sortFind) + #print str(pages[int(pagenum)][1]()) + if pages[int(pagenum)-1][1].meta_type=='File': + return self.xml2html(str(pages[int(pagenum)-1][1])) + else: + return str(self.xml2html(pages[int(pagenum)-1][1]())) + + def nextPage(self,pagenum,url): + pages=len(self.ZopeFind(self,obj_metatypes=['DTML Document','File'])) # teste ob performance ok, sonst in variable + if int(pagenum)+1 <= pages: + retstr=url+"?p="+str(int(pagenum)+1) + return """next"""%retstr + + def previousPage(self,pagenum,url): + + if int(pagenum)-1 > 0: + retstr=url+"?p="+str(int(pagenum)-1) + return """previous"""%retstr + + +def manage_addVLP_essayForm(self): + """Form for adding""" + pt=PageTemplateFile('Products/ECHO_content/vlp/AddVLP_essay.zpt').__of__(self) + return pt() + +def manage_addVLP_essay(self, id,title,label,RESPONSE=None): + """add the copyright""" + + + self._setObject(id, VLP_essay(id, title,label)) + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + + class VLP_collection(ECHO_collection): """VLP spezifische Erweiterung der Collection"""