--- ECHO_content/ECHO_collection.py 2004/08/04 18:36:24 1.156 +++ ECHO_content/ECHO_collection.py 2004/08/05 12:19:30 1.157 @@ -995,6 +995,17 @@ class ECHO_resource(Folder,Persistent): """nothing""" return ret + + def getInstitutionsHTML(self): + """gibt Liste der fšrdernden Institutionen aus""" + + if hasattr(self,'support'): + obj=self.support + ret=obj.getSupporter() + return ret + else: + return '' + def getCredits(self): """Ausgabe der credits""" @@ -3062,11 +3073,14 @@ class ECHO_root(Folder,Persistent,Implic """Get list of Partners. Presently only from a subfolder partners""" return [ item[1] for item in self.partners.ZopeFind(self.partners,obj_metatypes=['ECHO_partner'])] - - - + + + def getInstitutions(self): + """Get list of Partners. Presently only from a subfolder partners""" + + return [ item[1] for item in self.institutions.ZopeFind(self.institutions,obj_metatypes=['ECHO_institution'])] - + def getPartnersXML(self): """partner liste als xml""" partners=self.getPartners() @@ -3224,7 +3238,11 @@ class ECHO_root(Folder,Persistent,Implic """ find partners from ID""" par=self.ZopeFind(self.partners, obj_ids=[id]) return par - + + def getInstitutionFromID(self,id): + """ find institution from id """ + inst=self.ZopeFind(self.institutions, obj_ids=[id]) + return inst def manage_addECHO_root(self,id,title,RESPONSE=None): @@ -3372,4 +3390,233 @@ def manage_addECHO_partner(self, id, url REQUEST.RESPONSE.redirect('%s/manage_main' % url) return id +class ECHO_linkList(ZopePageTemplate): + """LinkList Objekt""" + meta_type="ECHO_linkList" + + _default_content_fn = os.path.join(package_home(globals()), 'html/ECHO_pageTemplateDefault.html') + + manage_options = ZopePageTemplate.manage_options+( + {'label':'Main Config','action':'changeECHO_linkListWeightForm'}, + ) + + def content_html(self): + """content_html""" + return content_html(self,'pageTemplate') + + def changeECHO_linkListWeightForm(self): + """change""" + pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_linkListTemplate.zpt').__of__(self) + return pt() + + def changeECHO_linkListWeight(self,contentType,label,RESPONSE=None): + """change""" + self.contentType=contentType + self.label=label + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + def getLabel(self): + if hasattr(self,'label'): + return self.label.encode('utf-8') + else: + return 0 + + def getcontentType(self): + """get contentType""" + if hasattr(self,'contentType'): + return self.contentType + else: + return 0 + + def __init__(self, id, label, title=None, text=None, contentType=None): + self.id = str(id) + self.title=title + self.label=label + self.ZBindings_edit(self._default_bindings) + if text is None: + text = '' + self.pt_edit(text, contentType) + + + + +def manage_addECHO_linkListForm(self): + """Form for adding""" + pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_linkListTemplate.zpt').__of__(self) + return pt() + +from urllib import quote + + +def manage_addECHO_linkList(self, id, label,contentType=0,title=None, text=None, + REQUEST=None, submit=None): + """Add a LinkList with optional file content.""" + + id = str(id) + if REQUEST is None: + self._setObject(id, ECHO_linkList(id, label, text)) + ob = getattr(self, id) + setattr(ob,'contentType',contentType) + 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 = ECHO_linkList(id, file) + else: + zpt = ECHO_linkList(id, label,'', file, headers.get('contentType')) + + self._setObject(id, zpt) + ob = getattr(self, id) + if title: + ob.pt_setTitle(title) + + 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 ECHO_support(Folder): + """gefšrdert durch""" + meta_type="ECHO_support" + + + + def __init__(self,id,institutions=None): + """init""" + ##self.title=title + self.id=id + self.institutions=toList(institutions) + + def getSupporter(self): + """return institutions""" + if self.institutions: + return self.institutions + else: + return [] + + manage_options = Folder.manage_options+( + {'label':'Main Config','action':'ECHO_support_configForm'}, + ) + + def ECHO_support_configForm(self): + """change form""" + pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_support').__of__(self) + pt.content_type="text/html" + return pt() + + def ECHO_support_config(self,institutions=None,RESPONSE=None): + """change""" + ##self.title=title + self.institutions=toList(institutions) + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + +def manage_addECHO_supportForm(self): + """Form for adding""" + pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_support.zpt').__of__(self) + return pt() + +def manage_addECHO_support(self, id,title,institutions=None,RESPONSE=None): + """add the copyright""" + + meta_type="ECHO_support" + + + self._setObject(id, ECHO_support(id,institutions)) + + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + +class ECHO_institution(Image,Persistent): + """ECHO Institution""" + + meta_type="ECHO_institution" + + def __init__(self, id, title,url, file, person, email, country, content_type='', precondition=''): + self.__name__=id + self.title=title + self.url=url + self.person=person + self.email=email + self.country=country + self.precondition=precondition + data, size = self._read_data(file) + content_type=self._get_content_type(file, data, id, content_type) + self.update_data(data, content_type, size) + + manage_options = Image.manage_options+( + {'label':'Institution Information','action':'ECHO_institution_config'}, + ) + + + def changeECHO_institution(self,url,person, email, country,RESPONSE=None): + """Change main information""" + self.url=url + self.person=person + self.email=email + self.country=country + if RESPONSE is not None: + RESPONSE.redirect('manage_main') + + + + def ECHO_institution_config(self): + """Main configuration""" + if not hasattr(self,'url'): + self.url="" + pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_institution.zpt').__of__(self) + return pt() + + +manage_addECHO_institutionForm=DTMLFile('dtml/ECHO_institutionAdd',globals(), + Kind='ECHO_institution',kind='ECHO_institution') + + +def manage_addECHO_institution(self, id, url, person, email, country, file=None, title='', precondition='', content_type='', + REQUEST=None): + """ + Add a new ECHO_institution object. + + Creates a new ECHO_institution object 'id' with the contents of 'file'. + Based on Image.manage_addImage + """ + + id=str(id) + title=str(title) + content_type=str(content_type) + precondition=str(precondition) + + id, title = OFS.Image.cookId(id, title, file) + + self=self.this() + + # First, we create the image without data: + self._setObject(id, ECHO_institution(id,title,url,'', person, email, country, content_type, precondition)) + + # Now we "upload" the data. By doing this in two steps, we + # can use a database trick to make the upload more efficient. + if file: + self._getOb(id).manage_upload(file) + if content_type: + self._getOb(id).content_type=content_type + + if REQUEST is not None: + try: url=self.DestinationURL() + except: url=REQUEST['URL1'] + REQUEST.RESPONSE.redirect('%s/manage_main' % url) + return id \ No newline at end of file