--- ECHO_content/ECHO_collection.py 2004/08/04 17:42:54 1.155 +++ ECHO_content/ECHO_collection.py 2004/08/05 20:29:23 1.161 @@ -274,6 +274,7 @@ class BrowserCheck: def writeMetadata(url,metadict,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,xmlfrag=None,digiliburlprefix=None): """Einlesen der Metadaten und und erstellen des geaenderten XML file""" + print "url",url def updateTextToolNode(tag,value): #print dom,tag,value metanode=dom.getElementsByTagName('texttool')[0] @@ -813,6 +814,7 @@ class ECHO_resource(Folder,Persistent): path=re.sub('http://foxridge.mpiwg-berlin.mpg.de:8080','',path) # falls foxridge als server path=re.sub('http://foxridge.mpiwg-berlin.mpg.de','',path) # falls foxridge als server path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server + path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server path=re.sub('/index.meta','',path) @@ -876,7 +878,7 @@ class ECHO_resource(Folder,Persistent): path=re.sub('http://foxridge.rz-berlin.mpg.de:8080','',path) # falls foxridge als server path=re.sub('http://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server - + path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server return urllib.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines() if RESPONSE is not None: @@ -994,6 +996,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""" @@ -1029,7 +1042,7 @@ class ECHO_resource(Folder,Persistent): def getCoords(self): - """gibt coordinaten als String zurück und löscht zugleich einträge die keine Koordinaten sind, letzteres zur korrektur der Eingabe der alten version""" + """gibt coordinaten als String zurück und löscht zugleich einträge die keine Koordinaten sind, letzteres zur korrektur der Eingabe der alten version""" retList=[] if hasattr(self,'coords'): for x in self.coords: @@ -1107,7 +1120,7 @@ class ECHO_resource(Folder,Persistent): def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,RESPONSE=None): - """Änderung der Properties""" + """Änderung der Properties""" self.resourceID=resourceID self.title=title self.label=label @@ -1125,7 +1138,7 @@ class ECHO_resource(Folder,Persistent): def changeECHO_resource_coords(self,coords,viewClassification,RESPONSE=None): - """Änderung der Properties - coords""" + """Änderung der Properties - coords""" if type(coords)==StringType: coords=[coords] @@ -1142,7 +1155,7 @@ class ECHO_resource(Folder,Persistent): RESPONSE.redirect('manage_main') def changeECHO_resource_credits(self,credits,responsible,copyrightType,RESPONSE=None): - """Änderung der Properties""" + """Änderung der Properties""" self.credits=credits self.responsible=responsible self.copyrightType=copyrightType @@ -1210,7 +1223,7 @@ class ECHO_resource(Folder,Persistent): return writeMetadata(self.metalink,self.metaDataHash) def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None): - """Änderung der Properties""" + """Änderung der Properties""" try: coordsnew=[ string.split(x,",") for x in coords] @@ -1482,7 +1495,7 @@ class ECHO_resource(Folder,Persistent): if sp: return sp[1]() - #prüfen ob irgendwo ein template + #prüfen ob irgendwo ein template if hasattr(self,'startpage_index_template'): return self.startpage_index_template() @@ -1596,7 +1609,7 @@ class ECHO_externalLink(Folder): def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None): - """Änderung der Properties""" + """Änderung der Properties""" try: coordsnew=[ string.split(x,",") for x in coords] except: @@ -1710,7 +1723,8 @@ class ECHO_collection(Folder, Persistent return ret - + + def changeLabels(self): """change form""" pt=PageTemplateFile('Products/ECHO_content/zpt/changeLabelsForm').__of__(self) @@ -1722,7 +1736,12 @@ class ECHO_collection(Folder, Persistent pt=PageTemplateFile('Products/ECHO_content/zpt/changeTitleForm').__of__(self) pt.content_type="text/html" return pt() - + + def changeMetaDataLinks(self): + """change form""" + pt=PageTemplateFile('Products/ECHO_content/zpt/changeMetaDataLinkForm').__of__(self) + pt.content_type="text/html" + return pt() def changeAccessRightsCollection(self): """change""" ret="" @@ -1738,6 +1757,21 @@ class ECHO_collection(Folder, Persistent """not""" return ret + def changeMetaDataLinkInCollection(self): + """change all lables of a collection""" + ret="" + argv=self.REQUEST.form + + resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) + for resource in resources: + + try: + ret+=resource[1].getId()+" "+argv[resource[1].getId()]+"
" + resource[1].metalink=argv[resource[1].getId()][0:] + except: + """not""" + return ret + def changeLabelsInCollection(self): """change all lables of a collection""" ret="" @@ -1840,7 +1874,7 @@ class ECHO_collection(Folder, Persistent def isSelectedViewerTemplateSet(self,obj,id): - """is ausgewählt""" + """is ausgewählt""" if self.REQUEST['viewerTemplateSet']==id: return 1 @@ -2499,7 +2533,7 @@ class ECHO_group(ECHO_collection): return pt() def changeECHO_group(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): - """Änderung der Properties""" + """Änderung der Properties""" self.secondaryLink=secondaryLink self.secondaryLinkTitle=secondaryLinkTitle @@ -2737,7 +2771,7 @@ class ECHO_root(Folder,Persistent,Implic def getBibTag(self,tag,content): - """get field tag für index-meta-generation""" + """get field tag für index-meta-generation""" if not content or content=="": return "" ret="<%s>"%tag @@ -2875,7 +2909,7 @@ class ECHO_root(Folder,Persistent,Implic """nothing""" return retStr - mediaTypes=['all','text','images','sound','video'] # konfigurierbar in neuer version über echoroot?? + mediaTypes=['all','text','images','sound','video'] # konfigurierbar in neuer version über echoroot?? def mediaTypeSelector_HTML(self,selected=None): """give type selector""" @@ -3024,11 +3058,11 @@ class ECHO_root(Folder,Persistent,Implic return "" - def xml2html(self,str): + def xml2html(self,str,quote="yes"): """link2html fuer VLP muss hier noch raus""" if str: - - str=re.sub("\&","&",str) + if quote=="yes2": + str=re.sub("\&","&",str) dom=xml.dom.minidom.parseString(str) links=dom.getElementsByTagName("link") @@ -3061,11 +3095,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() @@ -3223,7 +3260,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): @@ -3371,4 +3412,232 @@ 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.id=id + self.title='' + 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.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,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