The file will be stored for a while, you can download it later, the URL is:
+
%s?fn=%s\n"""%(tmpFn,downloadUrl,tmpFn))
+ RESPONSE.close()
+
+
+ def downloadPDF(self,fn):
+ """download prepared set"""
+ filename="/tmp/archivesImageServer/"+fn
+ namePDF=self.getId()+".pdf"
+ self.REQUEST.RESPONSE.setHeader("Content-Disposition","""attachement; filename="%s" """%namePDF)
+ self.REQUEST.RESPONSE.setHeader("Content-Type","application/octet-stream")
+ len=os.stat(filename)[6]
+ self.REQUEST.RESPONSE.setHeader("Content-Length",len)
+ images=file(filename).read()
+ self.REQUEST.RESPONSE.write(images)
+ self.REQUEST.RESPONSE.close()
+
+
+ def getRDF(self,urn=None):
+ """rdf"""
+ ret=getRDFDescription(self,self.link,urn=urn)
+ return ret+self.createSubElementRDF(urn=urn)
+
+
+ def changeAccessRightForm(self,preselect=None):
+ """change the access rights"""
+ pt=zptFile(self, 'zpt/ChangeECHO_resourceAccessRight.zpt')
+ return pt(preselect=preselect)
+
+ def changeAccessRight(self):
+ """changeRights"""
+ argv=self.REQUEST.form
+ self.setAccessRightXML(argv["%s_xml"%self.getId()])
+ self.accessRight=argv["%s_echo"%self.getId()]
+
+ self.REQUEST.RESPONSE.redirect('manage_main')
+
+
+ def getAccessRightSelectorHTML(self,outlook="select",xmldominant=None,preselect=None):
+ """htmlselector, xmldominant= in der regel wird der wert des xmlfiles ausgegeben ausser er existiert nicht"""
+ values=['','free','MPIWG']
+
+ if preselect:#set all to the preselected
+ ar=(preselect,preselect)
+ else:#else set to actual value
+ ar=self.getAccessRightMD()
+
+ if outlook=="select":
+ ret=""""
+ else:
+ if ar[0] is not None:
+ return ret+""
+ else:
+ return "
No xml file (only local selection):"+ret1
+
+ else:
+ ret=""
+ ret1=""
+ for value in values:
+
+ if value==ar[0]:
+ ret+="""%s"""%(self.getId(),value,value)
+ else:
+ ret+="""%s"""%(self.getId(),value,value)
+
+ if value==ar[1]:
+ ret1+="""%s"""%(self.getId(),value,value)
+ else:
+ ret1+="""%s"""%(self.getId(),value,value)
+
+ if not xmldominant:
+ return ret,ret1
+ else:
+ if ar[0]:
+ return ret
+ else:
+ return "
No xml file (only local selection)
"+ret1
+
- security.declarePublic('get_source_type')
- def get_source_type(self):
- return self.source_type
+ def copyAccessRightsFromMD(self):
+ """kopiere rechte aus den metadaten"""
+ self.accessRight=self.getAccessRightMD()[0]
+
+
+
+
- security.declarePublic('get_period')
- def get_period(self):
- return self.period
+ def getAccessRightMD(self):
+ """set accessright"""
+ url=self.metalink
+ try:
+ urllib.urlopen(url)
+ except:
+ zLOG.LOG("ECHO_Resource (getAccessRightMD)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])
-class ECHO_resource(Folder):
- """ECHO Ressource"""
- meta_type='ECHO_resource'
+ return None,getattr(self,'accessRight','')
+
+
+ try:
+ dom = NonvalidatingReader.parseUri(url)
+ except:
+ zLOG.LOG("ECHO_Resource (getAccessRightMD)", zLOG.INFO,"%s (%s)"%sys.exc_info()[0:2])
+ return (None,"Cannot parse: "+url+" "+"%s (%s)"%sys.exc_info()[0:2])
- viewClassificationList=viewClassificationListMaster
- def getViewClassification(self):
- if hasattr(self,'viewClassification'):
- return self.viewClassification
- else:
- return ""
+ accessright=dom.xpath("//meta/access-conditions/access/@type")
+ if accessright:
+ accessright=accessright[0].value
+ if str(accessright)=='institution':
+ tmp=dom.xpath("//meta/access-conditions/access/name")
+ if tmp:
+ accessright=getTextFromNode(tmp[0])
+
+ if not accessright:
+ accessright=""
+
+ return accessright,getattr(self,'accessRight','')
+
+ def changeAccessRightMD(self,accessright,RESPONSE=None):
+ """change the rights - not user anymore"""
+ #TODO: check if method still needed
+ params="accessright=%s"%accessright
+
+
+ #print ECHO_helpers.urlopen(self.absolute_url()+'/setAccessRightXML'+'?'+params).read()
+
+
+ ECHO_helpers.urlopen('http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/setAccessRightXML'+urllib.quote('?'+params))).read()
+
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+ def setAccessRightXML(self,accessright):
+ """set accessright"""
+ url=self.metalink
+ accessrights=['MPIWG','free']#allowes rights
+
+ if accessright =='':
+ """do nothing"""
+ return ""
+
+
+ try:
+ geturl=""
+ for line in ECHO_helpers.urlopen(url).readlines():
+ geturl=geturl+line
+
+
+ except:
+ return (None,"Cannot open: "+url)
+
+ try:
+ dom=xml.dom.minidom.parseString(geturl)
+ root=dom.getElementsByTagName('resource')[0]
+ except:
+ return (None,"Cannot parse: "+url+" "+geturl)
+
+ metamains=dom.getElementsByTagName('meta')
+
+ if not metamains:
+ nodenew=dom.createElement('meta')
+ root.appendChild(nodenew)
+ metamain=nodenew
+ else:
+ metamain=metamains[0]
+
+
+ metanodes=metamain.getElementsByTagName('access-conditions')
+
+ if not metanodes:
+ nodenew=dom.createElement('access-conditions')
+ metamain.appendChild(nodenew)
+ metanode=nodenew
+ else:
+ metanode=metanodes[0]
+
+ accesses=metanode.getElementsByTagName('access')
+
+ #delete old
+ if accesses:
+ metanode.removeChild(accesses[0]).unlink()
+
+ #create new
+
+ nodenew2=dom.createElement('access')
+ metanode.appendChild(nodenew2)
+ metanode2=nodenew2
+
+ attribute=metanode2.getAttribute('type')
+
+ if accessright=="free":
+
+ metanode2.setAttribute('type','free')
+
+ elif accessright.upper()=='MPIWG':
+ metanode2.setAttribute('type','institution')
+ nodenew4=dom.createElement('name')
+ metanodetext=dom.createTextNode('MPIWG')
+ nodenew4.appendChild(metanodetext)
+ nodenew2.appendChild(nodenew4)
+ #print dom.toxml().encode('utf-8')
+ string= encodeRPC(dom.toxml().encode('utf-8'))
+
+ #TODO: make server configurable
+ server=xmlrpclib.Server("http://foxridge.mpiwg-berlin.mpg.de/server")
+
+ path=urlparse.urlparse(self.metalink)[2]
+
+ server.writeMetaDataFile(path,string,"yes")
+ def setStartPageForm(self):
+ """Form for changing the startpage"""
+
+
+ pt=zptFile(self, 'zpt/ChangeECHO_resourceStartPage.zpt')
+ pt.content_type="text/html"
+ return pt()
+
+
+ def createImageUrl(self,pn=1):
+ """create ImageUrl"""
+
+
+ resourcepath=readFieldFromXML(self.metalink,'resource','archive-path')
+
+ digiliburlprefix=readFieldFromXML(self.metalink,'texttool','digiliburlprefix')
+ images=readFieldFromXML(self.metalink,'texttool','image')
+
+
+ if (not resourcepath) or (not digiliburlprefix) or (not images):
+ zLOG.LOG("ECHO (createImageUrl)",zLOG.ERROR,"Cannot create ImageUrl for %s"%self.absolute_url())
+ return None
+ resourcepath=resourcepath.replace('/mpiwg/online','')
+ if not digiliburlprefix: digiliburlprefix="http://echo.mpiwg-berlin.mpg.de/zogilib?"
+
+ if (not images) or (not resourcepath): return None
+
+ return "%sfn=%s&pn=%i"%(digiliburlprefix,resourcepath+"/"+images,pn)
+
+ def copyTitleToInfoXML(self,RESPONSE=None):
+ """copy title from the resource"""
+ presentationXML=readFieldFromXML(self.metalink,'texttool','presentation')
+ resourcepath=readFieldFromXML(self.metalink,'resource','archive-path')
+ if (not presentationXML) or (not resourcepath):
+ if RESPONSE:
+ RESPONSE.write("Error: %s\n"%self.getId())
+ else:
+ return None,self.absolute_url()
+
+ try:
+ fh=file(os.path.join(resourcepath,presentationXML),'w')
+ fh.write("""
+
+ %s
+
+ yes
+ """%self.title)
+ fh.close()
+ return 1,self.getId()
+ except:
+ if RESPONSE:
+ RESPONSE.write("Error: %s\n"%self.getId())
+ else:
+ return None,self.absolute_url()
+
+
+ def setStartPage(self,startpage=None,RESPONSE=None):
+ """set start page, if no startpage defined use the generic one of the resource"""
+
+ if (not (type(startpage)==StringType)):
+ if ("__generic" in startpage): # checke ob generic in der liste
+ startpage=self.absolute_url()+"/startpage_html"
+ elif ("__firstPage" in startpage): # checke ob generic in der liste
+ startpage=self.createImageUrl()
+
+ if (not startpage):
+ startpage=self.absolute_url()+"/startpage_html"
+ elif (startpage=="__generic"):
+ startpage=self.absolute_url()+"/startpage_html"
+ elif (startpage=="__firstPage"):
+ startpage=self.createImageUrl()
+
+ params="startpage=%s"%startpage
+ #print 'http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))
+
+ ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read()
+
+
+ path=self.metalink
+
+ path=re.sub(self.REQUEST['SERVER_URL'],'',path)
+ path=re.sub('http://'+self.REQUEST['HTTP_HOST'],'',path)
+
+ 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('http://vision.mpiwg-berlin.mpg.de','',path) # falls vision als server
+ path=re.sub('http://xserve02.mpiwg-berlin.mpg.de:18880','',path) # falls vision als server
+ path=re.sub('http://echo.mpiwg-berlin.mpg.de','',path) # falls echo
+ path=re.sub('/index.meta','',path)
+
+
+ ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines()
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def changeViewerTemplateSetForm(self):
+ """change the viewer template set"""
+ pt=zptFile(self, 'zpt/changeResourceViewerTemplateSet')
+ return pt()
+
+
+
+ def getTextToolsField(self,name,default=''):
+ """Lese Textoolsfelder aus index.meta im path aus"""
+
+ try:
+ dom=xml.dom.minidom.parse(self.metalink)
+ node=dom.getElementsByTagName('texttool')[0] #getNode
+ subnode=node.getElementsByTagName(name)[0]
+
+ # bei text wird nur der Folder gebraucht
+ if name=="text":
+ splitted=getText(subnode.childNodes).split("/")
+ return splitted[len(splitted)-2]
+ else:
+ return getText(subnode.childNodes)
+ except:
+ return default
+
+
+ def changeViewerTemplateSet(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None):
+ """changeit"""
+
+ paramList=['project','startpage','xslt','thumbtemplate','topbar','digiLibTemplate','digiliburlprefix']
+
+
+ #writeMetadata(self.metalink,self.metaDataHash,project,None,xslt,thumbtemplate,topbar,digiLibTemplate)
+
+ params="project=%s&xslt=%s&thumbtemplate=%s&topbar=%s&digiLibTemplate=%s&digiliburlprefix=%s"%(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix)
+
+
+ ECHO_helpers.urlopen('http://echo.mpiwg-berlin.mpg.de/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML'+urllib.quote('?'+params))).read()
+
+ #print self.absolute_url()+'/newMetaXML'+urllib.quote'?'+params)
+ # hack Pfad auf die Dokumente
+ path=self.metalink
+
+
+
+ path=re.sub('/index.meta','',path)
+
+ path=re.sub(self.REQUEST['SERVER_URL'],'',path)
+ path=re.sub('http://'+self.REQUEST['HTTP_HOST'],'',path)
+
+ path=re.sub('http://foxridge.mpiwg-berlin.mpg.de:8080','',path) # falls foxridge als server
+ 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://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server
+ path=re.sub('http://content.mpiwg-berlin.mpg.de','',path) # falls content als server
+ path=re.sub('http://echo.mpiwg-berlin.mpg.de','',path) # falls echo
+
+ path=re.sub('http://vision.rz-berlin.mpg.de','',path) # falls vision als server
+
+ return ECHO_helpers.urlopen("http://nausikaa2.rz-berlin.mpg.de:86/cgi-bin/toc/admin/reg.cgi?path=%s"%path).readlines()
+
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+
+ security.declarePublic('content_html')
+ def content_html(self):
+ """template fuer content"""
+ return ECHO_basis.content_html(self,'resource')
+
+# def getViewClassification(self):
+# if hasattr(self,'viewClassification'):
+# return self.viewClassification
+# else:
+# return ""
+
+ def getFullTextXML(self,noredirect=None):
+ """getFullTextXML; gives the FullText as an XML Document, and if somthing goes wrong."""
+
+ try:
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"open %s"%self.metalink)
+ fh=ECHO_helpers.urlopen(self.metalink)
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"opened %s"%self.metalink)
+ dom=xml.dom.minidom.parse(fh)
+ texttools=dom.getElementsByTagName('texttool')
+ text=texttools[0].getElementsByTagName('text')
+ texturl=getText(text[0].childNodes)
+
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"found %s"%texturl)
+ fh.close()
+ #zLOG.LOG("ECHO Fulltext",zLOG.INFO,"closed fh")
+ #keine url
+ if not (texturl.split(":")[0] in ['http','ftp','file']):
+ if not noredirect:
+ return file(texturl).read()
+ else:
+ return texturl
+
+ if not noredirect:
+ self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
+ zLOG.LOG("ECHO Fulltext",zLOG.INFO,"redirect to:%s"%texturl)
+ self.REQUEST.RESPONSE.redirect(texturl)
+ else:
+ return texturl
+ except:
+
+ if not noredirect:
+ self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
+ self.REQUEST.RESPONSE.write("no fulltext available")
+ else:
+ return "no fulltext available"
+
+ def getImagePath(self):
+ """gibt pfad zum image aus"""
+ return self.getImageView(noredirect="yes",onlyPath="yes")
+
+ def getImageView(self,noredirect=None,onlyPath=None):
+ """getImages; give Imageviewr and if somthing goes wrong."""
+ try:
+ fh=ECHO_helpers.urlopen(self.metalink)
+ dom=xml.dom.minidom.parse(fh)
+ texttools=dom.getElementsByTagName('texttool')
+ text=texttools[0].getElementsByTagName('image')
+ imagetemp=getText(text[0].childNodes)
+
+ text=dom.getElementsByTagName('archive-path')
+ archivepath=getText(text[0].childNodes)
+ archivepath=re.sub('/mpiwg/online/','',archivepath)
+ imageurl="http://echo.mpiwg-berlin.mpg.de/zogilib?fn="+archivepath+"/"+imagetemp
+ fh.close()
+
+ if not noredirect:
+ self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
+ self.REQUEST.RESPONSE.redirect(imageurl)
+ else:
+ if not onlyPath:
+ return imageurl
+ else:
+ return archivepath+"/"+imagetemp
+ except:
+
+ if not noredirect:
+ self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
+ self.REQUEST.RESPONSE.write("no fulltext available")
+ else:
+ return "no images available"
+
+
+ def getCopyrightsHTML(self):
+ """gib (link auf copyright link, mediatyp, institution, copyrightType, label von copyrightType) aus"""
+
+ if hasattr(self,'copyrightModel'):
+ obj=self.copyrightModel
+
+ else:
+ return "ERROR"
+ ret=[]
+
+ for copyright in obj.getCopyrights(): #copyright - media / partner / copyrightID
+
+
+ try:
+ if hasattr(self.copyrightTypes,copyright[2]):
+ copyrightTypeObj=getattr(self.copyrightTypes,copyright[2])
+ link="copyrightTypes/"+copyright[2]+'/copyright.html'
+ else:
+ copyrightTypeObj=getattr(obj,copyright[2])
+ link="copyrightModel/"+copyright[2]+'/copyright.html'
+
+ label=copyrightTypeObj.label
+ url=getattr(copyrightTypeObj, 'url', '')
+
+ if url!='':
+ ret.append((url,copyright[0],copyright[1],copyright[2],label))
+ else:
+ if hasattr(copyrightTypeObj, 'copyright.html'):
+ ret.append(("""%s?partner=%s"""%(link,copyright[1]),copyright[0],copyright[1],copyright[2],label))
+ else:
+ ret.append(('empty',copyright[0],copyright[1],copyright[2],label))
+ except:
+ """nothing"""
+
+ return ret
+
+ def getInstitutionsHTML(self):
+ """gibt Liste der foerdernden Institutionen aus"""
+
+ if hasattr(self,'support'):
+ obj=self.support
+ ret=obj.getSupporter()
+ return ret
+ else:
+ return ''
+
+
def getCredits(self):
"""Ausgabe der credits"""
if self.credits:
return self.credits
else:
return []
+
+
- def __init__(self,id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords):
+ def __init__(self,id,link,metalink,resourceID,title,label,description,contentType,renderingType,copyrightType,responsible,credits,weight,coords):
self.id = id
"""Festlegen der ID"""
@@ -205,8 +1036,11 @@ class ECHO_resource(Folder):
self.weight=weight
self.credits=toList(credits)
self.description=description
- self.content_type=content_type
+ self.contentType=contentType
+ self.copyrightType=copyrightType
+ self.renderingType=renderingType
self.responsible=responsible
+ self.resourceID=resourceID
if coords:
coordsnew=[ string.split(x,",") for x in coords]
@@ -214,36 +1048,276 @@ class ECHO_resource(Folder):
coordsnew=[]
self.coords=coordsnew
+# self.viewClassification=""
- def getCoords(self):
- try:
- return [string.join(x,",") for x in self.coords]
- except:
- return []
+ def getContentType(self):
+ try:
+ return self.contentType
+ except:
+ return ""
+
+ def getCopyrightType(self):
+ try:
+ return self.copyrightType
+ except:
+ return ""
+
+ def getRenderingType(self):
+ try:
+ return self.renderingType
+ except:
+ return ""
def ECHO_resource_config(self):
"""Main configuration"""
if not hasattr(self,'weight'):
self.weight=""
- if not hasattr(self,'coords'):
- self.coords=[]
- pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self)
+ pt=zptFile(self, 'zpt/ChangeECHO_resource.zpt')
+ return pt()
+
+
+ def ECHO_resource_config_main(self):
+ """Main configuration"""
+ if not hasattr(self,'weight'):
+ self.weight=""
+ pt=zptFile(self, 'zpt/ChangeECHO_resource_main.zpt')
+ return pt()
+
+ def ECHO_resource_config_coords(self):
+ """Coords configuration """
+ pt=zptFile(self, 'zpt/ChangeECHO_resource_coords.zpt')
+ return pt()
+
+ def ECHO_resource_config_credits(self):
+ """Main configuration"""
+ pt=zptFile(self, 'zpt/ChangeECHO_resource_credits.zpt')
return pt()
+
+ def ECHO_resource_config_metadata(self):
+ """Main configuration"""
+ if (hasattr(self,'metadata')) and not (hasattr(self,'metaDataHash')):
+ self.metaDataHash={}
+ self.contentType=self.bib_type
+ for data in self.metadata:
+ data_neu=re.sub('-','_',data)
+ self.metaDataHash[data_neu]=getattr(self,data)[0:]
+
+
+ pt=zptFile(self, 'zpt/ChangeECHO_resource_metadata.zpt')
+ return pt()
+
+
- def changeECHO_resource(self,metalink,link,title,label,description,content_type,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):
+ def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,RESPONSE=None):
+ """Aenderung der Properties"""
+ self.resourceID=resourceID
+ self.title=title
+ self.label=label
+ self.description=description
+
+ self.contentType=contentType
+ self.renderingType=renderingType
+ self.weight=weight
+
+ self.link=link
+ self.metalink=metalink
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def changeECHO_resource_coords(self,RESPONSE=None):
+ """Aenderung der Properties - coords"""
+ #return self.REQUEST
+ for area in self.getMapAreas():
+ id = area.getId()
+ if self.REQUEST.has_key('del.'+id):
+ # delete this area
+ self._delObject(id)
+ # return to same menu
+ if RESPONSE is not None:
+ RESPONSE.redirect('ECHO_resource_config_coords')
+ return
+ # modify this area
+ coordstring = self.REQUEST.get('coords.'+id, '')
+ coords = string.split(coordstring, ',')
+ angle = self.REQUEST.get('angle.'+id, '0')
+ type = self.REQUEST.get('type.'+id, 'area')
+ if len(coords) == 4:
+ area.setCoordString(coordstring)
+ area.setAngle(angle)
+ area.setType(type)
+ # return to main menu
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
- """Änderung der Properties"""
+
+ def changeECHO_resource_credits(self,credits,responsible,copyrightType,RESPONSE=None):
+ """Aenderung der Properties"""
+ self.credits=credits
+ self.responsible=responsible
+ self.copyrightType=copyrightType
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
- setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords,viewClassification)
+ def changeECHO_resource_metadata_local(self,RESPONSE=None):
+ """change metadata"""
+ tags=self.findTagsFromMapping(self.contentType)
+ for field in tags[1]:
+ self.metaDataHash[self.getFieldTag(tags,field)]=self.REQUEST.form[self.getFieldTag(tags,field)][0:]
+
+
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def changeECHO_resource_metadata(self,RESPONSE=None):
+ """change metadata"""
+ tags=self.findTagsFromMapping(self.contentType)
+ self.OSAS_meta={}
+ for field in tags[1]:
+ try:
+ self.metaDataHash[self.getFieldTag(tags,field)]=self.REQUEST.form[self.getFieldTag(tags,field)]
+ self.OSAS_meta[self.getFieldTag(tags,field)]=self.REQUEST.form['OSAS_%s'%self.getFieldTag(tags,field)]
+ except:
+ zLOG.LOG("ECHO_collection (changeECHO_resource_metadata)",zLOG.ERROR,"%s (%s)"%sys.exc_info()[0:2])
+
+ print self.newMetaXML()
+ ECHO_helpers.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/echo_nav/storage/downloadExternalXML?index_meta_url=%s&xml_url=%s'%(self.metalink,self.absolute_url()+'/newMetaXML')).read()
+
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+
+ def getMDValueSimpleSearchField(self):
+ """returns value for simple search"""
+
+ try:
+ return " ".join([self.getMDValue('title',generic="yes"),
+ self.getMDValue('author',generic="yes"),
+ self.getMDValue('year',generic="yes"),self.getTitle()])
+ except:
+
+ #zLOG.LOG(" ECHO_collection(getMDSimpleSearchField)",zLOG.INFO," ".join([self.getMDValue('title',generic="yes"),
+ # self.getMDValue('author',generic="yes"),
+ # self.getMDValue('year',generic="yes"),'']))
+ return ""
+
+ def getMDValue(self,fieldNameTest,empty=None,generic=None):
+ """get md values"""
+ #TODO: cache mappinghash
+
+ fieldName=None
+ if generic:
+ if self.contentType:
+ ct=self.contentType.replace(" ","_").lower()
+ else:
+ zLOG.LOG("ECHO_collection (getMDValue)", zLOG.INFO, "no_content type for %s"%self.getId())
+ ct=""
+
+ #caching
+ if not hasattr(self,'_v_mapHash'): #noch keine cachevariable
+ self._v_mapHash={}
+
+ tmp=self._v_mapHash.get(ct,None)
+ if tmp: #teste ob type schon existiert
+ fieldName=tmp.get(fieldNameTest,None)
+ else:
+ self._v_mapHash[ct]={}
+
+ #noch nicht gecached
+ if not fieldName and hasattr(self.standardMD,ct):
+ fieldName=getattr(self.standardMD,ct).generateMappingHash()[fieldNameTest][0]
+ self._v_mapHash[ct][fieldNameTest]=fieldName
+ if not fieldName:
+ fieldName=fieldNameTest
+ if not empty:
+ #FIXME: warum gibt es manchmal kein metadatahas
+ try:
+
+ ret =self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType)
+ except:
+ zLOG.LOG("ECHO (line 1069)",zLOG.ERROR,"no md hash for %s"%self.getId())
+ return ""
+
+ else:
+
+
+ ret= self.metaDataHash.get(fieldNameTest,empty)
+
+ if type(ret) is StringType:
+ return ret.decode('utf-8')
+ else:
+ return ret
+
+ getFieldValue=getMDValue #depricated
+
+ def newMetaXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None,digiliburlprefix=None):
+ """new index.meta"""
+ self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
+
+ if not hasattr(self,'metaDataHash'):
+
+ self.copyIndex_meta2echo_resource()
+ try:
+ return writeMetadata(self.metalink,self.OSAS_meta,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix)
+ except:
+ return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix=digiliburlprefix)
+
+ def showMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None):
+ """return bibliographical metadata as stored in the object"""
+
+ try:
+
+ return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate,xmlfrag="yes")
+ except:
+ return " no metadata stored"
+
+ def getXQueryMetaData(self,xquery):
+ '''
+ execute an xquery on the metadata and returns a list of tuples,
+ each tuple represent the content of the node as text and the whole node as xml-fragment
+ @param xquery: xquery auf den metadaten
+ '''
+
+ try:
+ md=writeMetadata(self.metalink,self.metaDataHash,xmlfrag="yes")
+ except:
+ return None
+
+ dom = NonvalidatingReader.parseString(md,"http://www.mpiwg-berlin.mpg.de/")
+
+ results=Ft.Xml.XPath.Evaluate(xquery, contextNode=dom)
+
+ ret=[]
+ for result in results:
+
+ buf = cStringIO.StringIO()
+ PrettyPrint(result, stream=buf)
+ str = buf.getvalue()[0:]
+ buf.close()
+ ret.append((getTextFromNode(result),str))
+
+ return ret
+
+ def getMetaDataXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None):
+ """prints out metadata as stored in the echo environment, format is the index.meta format"""
+ self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml')
+ return writeMetadata(self.metalink,self.metaDataHash)
+
+ def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None):
+ """Aenderung der Properties"""
+ setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)
self.link=link
self.metalink=metalink
@@ -252,80 +1326,296 @@ class ECHO_resource(Folder):
manage_options = Folder.manage_options+(
- {'label':'Main Config','action':'ECHO_resource_config'},
- {'label':'Metadata','action':'ECHO_getResourceMD'},
- {'label':'Graphics','action':'ECHO_graphicEntry'},
+ {'label':'Main Config','action':'ECHO_resource_config_main'},
+ {'label':'Change Metadata','action':'ECHO_resource_config_metadata'},
+ {'label':'Graphic Coords','action':'ECHO_graphicEntry'},
+ {'label':'Sync Metadata','action':'ECHO_getResourceMD'},
+ {'label':'Change TemplateSets and Image Viewer','action':'changeViewerTemplateSetForm'},
+ {'label':'set/change startpage','action':'setStartPageForm'},
+ {'label':'Copy MD for indexing and search','action':'copySearchFields'},
+ {'label':'Change AccessRights','action':'changeAccessRightForm'},
)
- def ECHO_graphicEntry(self):
- """DO nothing"""
- overview = self.ZopeFind(self,obj_ids=['overview'])
+
+ def isDefinedInThisSet(self,fields,field):
+ """checks if field is defined in fields"""
+ if (fields[0].has_key(field)) and not (fields[0][field]==""):
+ return 1
+ else:
+
+ return 0
+
+ def getFieldLabel(self,fields,field):
+ """get labels"""
+ try:
+ ret =fields[0][field]
+ if ret == "":
+ return field
+ else:
+ return ret
+ except:
+ return field
+
+
+
+ def getFieldTag(self,fields,field):
+ """get labels"""
+ try:
+ ret =fields[0][field]
+ if ret == "":
+ return field
+ else:
+ return ret
+ except:
+ return field
+
+
+
+ def getMetaDataHash(self):
+ """md hash"""
+ return self.metaDataHash
+
+ def setFieldValue(self,field,value):
+ """get value"""
+ #TODO: remove setFieldValue
- if overview:
- pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_draw.zpt').__of__(self)
- return pt()
- else:
- return "NO OVERVIEW GRAPHICS"
+ if not hasattr(self,'metaDataHash'):
+ setattr(self,'metaDataHash',{})
+ self.metaDataHash[field]=value[0:]
+
+ def copySearchFields(self):
+ """copys metadatafields to the object"""
+ fields=['author','title','year']
+
+ for field in fields:
+ setattr(self,'MD_'+field,self.getMDValue(field,generic="yes"))
+
- def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None):
- """Enter coords"""
- coords=self.coords
- temco=coordstr.split(",")
- temco.append(angle)
- coords.append(temco)
+ def findLabelsFromMapping(self,referenceType):
+ """gib hash mit label -> generic zurueck"""
+ #return {},[]
+
+ temp=self.ZopeFind(self.standardMD)
+
+ if referenceType=="":
+ referenceType="book"
- self.coords=coords[0:]
+
+ bibdata={}
+ retdata={}
+ fields=[]
+ fieldlist=self.standardMD.fieldList
- if RESPONSE is not None:
- RESPONSE.redirect('ECHO_graphicEntry')
+ tags=self.findTagsFromMapping(self.contentType)
+ self.referencetypes=tags[2]
+ for referenceTypeF in self.referencetypes:
- def ECHO_getResourceMD(self,template="yes"):
- """Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource"""
- (metadict, error)=readMetadata(self.metalink)
+ if referenceTypeF[1].title.lower() == referenceType.lower():
+ try:
+ bibdata[referenceTypeF[1].title]=referenceTypeF[1].fields
+ referenceType=referenceTypeF[1].title
+ except:
+ bibdata[referenceType]=referenceTypeF[1].fields
+
+ bibdata['data']=referenceTypeF[1]
+ fields=bibdata[referenceType]
+ for field in fieldlist:
+ retdata[field]=referenceTypeF[1].getValue(field)[1]
- if not error=="": #Fehler beim Auslesen des Metafiles
- return "ERROR:",error
- for key in metadict.keys():#Hinzufügen der Felder
+ return retdata,fieldlist,temp,fields
- setattr(self,key,metadict[key].encode('ascii','replace'))
+ def findTagsFromMapping(self,referenceType):
+ """gib hash mit label -> generic zurueck"""
- self.metadata=metadict.keys()
+ if referenceType=="":
+ referenceType="book"
+
+ temp = self.ZopeFind(self.standardMD)[0:]
- self.label=self.generate_label()
+ #self.referencetypes=temp[0:]
+
+
+
+
+ bibdata={}
+ retdata={}
+ fieldlist=self.standardMD.fieldList
+ fields=[]
+ for referenceTypeF in temp:
+ #print referenceType
+
+ if referenceTypeF[1].title.lower() == referenceType.lower():
+ try:
+ bibdata[referenceTypeF[1].title]=referenceTypeF[1].fields
+ referenceType=referenceTypeF[1].title
+ except:
+ bibdata[referenceType]=referenceTypeF[1].fields
+ bibdata['data']=referenceTypeF[1]
+ fields=bibdata[referenceType]
+ for field in fieldlist:
+ retdata[field]=referenceTypeF[1].getValue(field)[0]
+
+ return retdata,fieldlist,temp,fields
+
+
+ security.declarePublic('copyIndex_meta2echo_resource') # has to be change, presentlyset because of OSAS koordination
+ def copyIndex_meta2echo_resource(self,RESPONSE=None):
+ """copy MD von Index_meta to the echo_resource"""
+
+ (metadict, error)=readMetadata(self.metalink)
+
+
+
+ self.metaDataHash={}
+ if not error=="": #Fehler beim Auslesen des Metafiles
+
+ return "ERROR:",error,self.absolute_url()
+
+ self.contentType=metadict['bib_type'][0:]
+ fields=self.findTagsFromMapping(self.contentType)
+
+ #fields=self.findLabelsFromMapping(self.contentType)
+ for field in fields[1]:
+
+ if self.isDefinedInThisSet(fields,field):
+ #print urllib.unquote(metadict.get(self.getFieldTag(fields,field),''))
+ self.setFieldValue(self.getFieldTag(fields,field),metadict.get(self.getFieldTag(fields,field),''))
+
+
+
+ if RESPONSE:
+ return RESPONSE.redirect('manage_main')
+
+ return "OK:",self.absolute_url(),self.contentType
+
+ def ECHO_getResourceMD(self,template="yes",back=None,overwrite="no"):
+ """Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource"""
+ (metadict, error)=readMetadata(self.metalink)
+
+ if back:
+ self.REQUEST.SESSION['back']=back
+
+ if not error=="": #Fehler beim Auslesen des Metafiles
+ return "ERROR:",error
+
+ if (not self.contentType) or (overwrite=="yes"):
+ self.contentType=metadict['bib_type'].lower()
+
+ if not (metadict['bib_type'].lower()==self.contentType.lower()):
+ self.REQUEST.SESSION['contentStorage']=metadict['bib_type']
+ self.REQUEST.SESSION['contentZope']=self.contentType
+
+ return zptFile(self, 'zpt/ECHO_getResourceMDErrorContentType.zpt')()
+
+ #self.REQUEST.SESSION['metadict']=metadict
+
+
+
+
+ self.REQUEST.SESSION['diffs']=checkDiffs(self,metadict)
+
+
if template=="yes":
- pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_resourceMD.zpt').__of__(self)
- return pt()
+ #pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/ECHO_resourceMD.zpt'),metadict=metadict).__of__(self)
+ pt=zptFile(self, 'zpt/ECHO_resourceMD.zpt')
+
+ return pt(metadict=metadict)
+
+
+
+
def ECHO_getMD(self,item):
"""Ausgabe der MD"""
return getattr(self,item)
-
+
+ def checkRDF(self,path):
+ """check if pdf in the path"""
+ try:
+ for fileName in os.listdir(path):
+ if os.path.splitext(fileName)[1]==".pdf":
+ return os.path.join(path,fileName)
+ return None
+ except:
+ return None
+
+
+ security.declareProtected('View','index_html')
def index_html(self):
"""standard page"""
-
+ pdf=self.checkRDF(self.link)
+ if pdf:
+ fh=file(pdf,'r').read()
+ self.REQUEST.RESPONSE.setHeader('Content-Type','application/pdf')
+ self.REQUEST.RESPONSE.write(fh)
+ self.REQUEST.RESPONSE.close()
+ return
return self.REQUEST.RESPONSE.redirect(self.link)
+ def startpage_html(self):
+ """prints out a startpage for a resource for use e.g. in the BVE"""
+
+ # suche ob startpage.html in dem Ordner vorhanden ist, dann wir diese angezeigt
+
+ sp=self.ZopeFind(self,obj_ids=['startpage.html'])
+
+ if sp:
+ return sp[1]()
+
+ #pruefen ob irgendwo ein template
+ if hasattr(self,'startpage_index_template'):
+ return self.startpage_index_template()
+
+ #generisches template ausgeben
+
+ pt=zptFile(self, 'zpt/ECHO_startpage_index_template_standard.zpt')
+ pt.content_type="text/html"
+ return pt()
+
+ def toc_html(self):
+
+ sp=self.ZopeFind(self,obj_ids=['toc.html'])
+
+ if sp:
+ return sp[0][1]()
+
+
+ security.declarePublic('generate_label') # has to be change, presentlyset because of OSAS koordination
+
def generate_label(self):
"""Erzeugt_standard_Label aus Template"""
- pt=getattr(self,"label_template_"+self.bib_type)
+ pt=getattr(self,"label_template_"+self.contentType.lower())
+ self.label=pt()[0:]
return pt()
+ security.declarePublic('generate_title') # has to be change, presentlyset because of OSAS koordination
+
+ def generate_title(self,RESPONSE=None):
+ """Erzeugt_standard_Label aus Template"""
+ pt=getattr(self,"label_template_"+self.contentType.lower())
+
+ self.title=pt()[0:]
+
+ return pt()
+
+Globals.InitializeClass(ECHO_resource)
+
def manage_addECHO_resourceForm(self):
"""Form for adding a ressource"""
- pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_resourceForm.zpt').__of__(self)
+ pt=zptFile(self, 'zpt/AddECHO_resourceForm.zpt')
return pt()
-def manage_addECHO_resource(self,id,title,label,description,content_type,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None):
- """addaresource"""
+def manage_addECHO_resource(self,id,title,label,description="",responsible="",link="",metalink="",weight="",copyrightType=None,resourceID=None,contentType=None,renderingType=None,credits=None,coords=None,RESPONSE=None):
+ """addresource"""
- newObj=ECHO_resource(id,link,metalink,title,label,description,content_type,responsible,credits,weight,coords)
+ newObj=ECHO_resource(id,link,metalink,resourceID,title,label,description,contentType,renderingType,copyrightType,responsible,credits,weight,coords)
self._setObject(id,newObj)
@@ -333,13 +1623,24 @@ def manage_addECHO_resource(self,id,titl
RESPONSE.redirect('manage_main')
-class ECHO_externalLink(Folder):
+class ECHO_externalLink(Folder,ECHO_basis):
"""Link zu einer externen Ressource"""
security=ClassSecurityInfo()
meta_type='ECHO_externalLink'
-
- def __init__(self,id,link,title,label,description,content_type,responsible,credits,weight,coords):
+ security.declarePublic('content_html')
+ def content_html(self):
+ """template fuer content"""
+ ret= ECHO_basis.content_html(self,'externalLink')
+
+ if type(ret) is StringType:
+ return ret.decode('utf-8')
+ else:
+ return ret
+
+
+
+ def __init__(self,id,link,title,label,description,contentType,responsible,credits,weight,coords):
self.id = id
"""Festlegen der ID"""
@@ -350,7 +1651,7 @@ class ECHO_externalLink(Folder):
self.title=title
self.weight=weight
self.description=description
- self.content_type=content_type
+ self.contentType=contentType
self.responsible=responsible
coordsnew=[ string.split(x,",") for x in coords]
self.coords=coordsnew
@@ -363,20 +1664,16 @@ class ECHO_externalLink(Folder):
if not hasattr(self,'coords'):
self.coords=['']
- #print "G",self.coords
- pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_externalLink.zpt').__of__(self)
+
+ pt=zptFile(self, 'zpt/ChangeECHO_externalLink.zpt')
return pt()
- def changeECHO_externalLink(self,link,title,label,description,content_type,responsible,weight,coords=None,credits=None,RESPONSE=None):
+ def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None):
+ """Aenderung der Properties"""
+ setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)
- """Änderung der Properties"""
-
-
- setECHO_collectionInformation(self,title,label,description,content_type,responsible,credits,weight,coords)
-
-
self.link=link
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
@@ -384,14 +1681,9 @@ class ECHO_externalLink(Folder):
manage_options = Folder.manage_options+(
{'label':'Main Config','action':'ECHO_externalLink_config'},
+ {'label':'Graphic Coords','action':'ECHO_graphicEntry'},
)
- def getCredits(self):
- """Ausgabe der credits"""
- if self.credits:
- return self.credits
- else:
- return []
def index_html(self):
"""standard page"""
@@ -400,36 +1692,634 @@ class ECHO_externalLink(Folder):
def manage_addECHO_externalLinkForm(self):
"""Form for external Links"""
- pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_externalLinkForm.zpt').__of__(self)
+ pt=zptFile(self, 'zpt/AddECHO_externalLinkForm.zpt')
return pt()
-def manage_addECHO_externalLink(self,id,title,label,description,content_type,responsible,link,weight,coords=None,credits=None,RESPONSE=None):
+def manage_addECHO_externalLink(self,id,title,label,description,contentType,responsible,link,weight,coords=None,credits=None,RESPONSE=None):
"""Add an external Link"""
- newObj=ECHO_externalLink(id,link,title,label,description,content_type,responsible,credits,weight,coords)
+ newObj=ECHO_externalLink(id,link,title,label,description,contentType,responsible,credits,weight,coords)
self._setObject(id,newObj)
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
+
+class ECHO_link(ECHO_externalLink):
+ """external_link"""
+
+ meta_type="ECHO_link"
+
+ manage_options = ECHO_externalLink.manage_options+(
+ {'label':'add links config','action':'ECHO_link_addLinksForm'},
+ )
+
+ def ECHO_link_addLinksForm(self):
+ """Main configuration"""
+
+ pt=zptFile(self, 'zpt/ChangeECHO_link_addLinks.zpt')
+ return pt()
+
+ def ECHO_link_addLinks(self,addLinks,RESPONSE):
+ """add links"""
+ self.addLinks=addLinks
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def content_html(self):
+ """template fuer link"""
+
+
+ if hasattr(self,"link_template"):
+ ret=ECHO_basis.content_html(self,'link')
+
+ else:
+ ret=ECHO_basis.content_html(self,'collection')
+
+
+ #return ret
+ return ret
+#
+#
+# try:
+# return ret.decode('utf-8')
+# except:
+# try:
+# return ret.decode('latin-1')
+# except:
+#
+# return ret
+#
+
+
+ def index_html(self):
+ """standard link"""
+ if self.link:
+ splitted=self.link.split("?")
+ if len(splitted)>1:
+ params=cgi.parse_qs(splitted[1])
+
+ for x in params.keys():
+ if type(params[x]) is ListType:
+ params[x]=params[x][0]
-class ECHO_collection(Folder, Persistent, Implicit):
+
+ else:
+ params={}
+
+ if getattr(self,'addLinks','yes')=="yes":
+ params['backLink']=self.aq_parent.absolute_url()
+ params['startLink']=splitted[0]+"?"+urllib.urlencode(params)
+
+
+ return self.REQUEST.RESPONSE.redirect(splitted[0]+"?"+urllib.urlencode(params))
+ else:
+ return ""
+
+def manage_addECHO_linkForm(self):
+ """Form for external Links"""
+ pt=zptFile(self, 'zpt/AddECHO_linkForm.zpt')
+ return pt()
+
+
+def manage_addECHO_link(self,id,title,label,description="",contentType="",responsible="",link="",weight="",coords=[],credits=None,RESPONSE=None):
+ """Add an external Link"""
+
+ newObj=ECHO_link(id,link,title,label,description,contentType,responsible,credits,weight,coords)
+
+ self._setObject(id,newObj)
+
+ getattr(self,id).addLinks='no'
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+class ECHO_collection(CatalogAware, Folder, Persistent, Implicit, Cacheable,ECHO_basis):
"""ECHO Collection"""
+
+ management_page_charset="utf-8"
security=ClassSecurityInfo()
meta_type='ECHO_collection'
+ default_catalog='resourceCatalog'
+
+# viewClassificationList=viewClassificationListMaster
+ displayTypes=displayTypes
+
+ path="/mpiwg/online/permanent/shipbuilding"
+
+ def getMDValueSimpleSearchField(self):
+ """returns value for simple search"""
+ return " ".join([self.title,self.description])
+
+ def getTitleAndLabel(self):
+ """gibt title und label zurueck"""
+ return (getattr(self,'title',''),getattr(self,'label',''))
+
+ def localizeObjects(self):
+ """localize all objects"""
+ contents=self.ZopeFind(self,obj_metatypes=['ECHO_externalLink','ECHO_link','ECHO_mapText'])
+
+ find=self.ZopeFind(self,obj_ids=('locale_en'))
+ if not find:
+ self.manage_addECHO_locale("en",'','')
+ for content in contents:
+
+ if content[1].meta_type in ['ECHO_link','ECHO_externalLink']:
+
+ find=content[1].ZopeFind(content[1],obj_metatypes=('ECHO_mapText'))
+ if find:
+ root=find[0][1]
+
+ locale=find[0][1].ZopeFind(find[0][1],obj_ids=('locale_en'))
+ else:
+ root=None
+ else:
+ root=content[1]
+ locale=content[1].ZopeFind(content[1],obj_ids=('locale_en'))
+ if root and not locale:
+ root.manage_addECHO_locale("en",'','')
+
+ pt=zptFile(self, 'zpt/localizeObjects.zpt')
+ return pt()
+
+
+ def localize(self,REQUEST,RESPONSE):
+ """localize"""
+ for key in REQUEST.form.keys():
+ splitted=key.split("!")
+
+ if splitted[0]=="" or splitted[0]=="en" or splitted[0]=="title" or splitted[0]=="label":
+ if splitted[0]=="en":
+ setattr(self.locale_en,splitted[1],REQUEST.form[key])
+ else:
+ setattr(self,splitted[0],REQUEST.form[key])
+ else:
+ obj=getattr(self,splitted[0])
+
+ if obj.meta_type=="ECHO_mapText":
+ if splitted[1]=="en":
+ obj.locale_en.pt_edit(REQUEST.form[key],None)
+ else:
+ obj.pt_edit(REQUEST.form[key],None)
+ else:
+ text=obj.ZopeFind(obj,obj_metatypes=['ECHO_mapText'])
+ if splitted[1]=="en":
+
+ text[0][1].locale_en.pt_edit(REQUEST.form[key],None)
+ else:
+ text[0][1].pt_edit(REQUEST.form[key],None)
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+ def getRDF(self,urn=None):
+ """rdf of the collection"""
+
+ contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection'])
+
+ ret=getRDFDescription(self,self.absolute_url(),urn=urn)
+
+ if not urn:
+ urn=self.absolute_url()
+
+ li="""\n"""
+
+
+ for content in contents:
+ ret+=content[1].getRDF()+"\n"
+
+ ret+="""\n"""%urn
+ for content in contents:
+ nurn=content[1].absolute_url()
+ ret+=li%nurn
+ return ret+""
+
+
+
+ def changeLabels(self):
+ """change form"""
+ pt=zptFile(self, 'zpt/changeLabelsForm')
+ pt.content_type="text/html"
+ return pt()
+
+ def changeTitles(self):
+ """change form"""
+ pt=zptFile(self, 'zpt/changeTitleForm')
+ pt.content_type="text/html"
+ return pt()
+
+ def changeWeights(self):
+ """change form"""
+ pt=zptFile(self, 'zpt/changeWeightForm')
+ pt.content_type="text/html"
+ return pt()
+
+ def changeMetaDataLinks(self):
+ """change form"""
+ pt=zptFile(self, 'zpt/changeMetaDataLinkForm')
+ pt.content_type="text/html"
+ return pt()
+
+ def changeAccessRightsCollectionForm(self,preselect=None):
+ """change access rights of all resources in this collection"""
+
+ pt=zptFile(self, 'zpt/changeAccessRightsCollectionForm')
+ pt.content_type="text/html"
+ return pt(preselect=preselect)
+
+
+ def changeAccessRightsCollection(self):
+ """change"""
+ ret=""
+ argv=self.REQUEST.form
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'])
+ for resource in resources:
+
+ if argv.has_key(resource[1].getId()+'_xml'):
+ ret+=resource[1].getId()+" "+argv[resource[1].getId()+'_xml']+""
+ resource[1].setAccessRightXML(argv[resource[1].getId()+'_xml'])
+ resource[1].accessRight=argv[resource[1].getId()+'_xml']
+ elif argv.has_key(resource[1].getId()+'_echo'):
+ ret+="only local:"+resource[1].getId()+" "+argv[resource[1].getId()+'_echo']+""
+ resource[1].accessRight=argv[resource[1].getId()+'_echo']
+ else:
+ ret+="ERROR:" +resource[0]
+ 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:
+ pass
+ 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:
+ pass
+ return ret
+
+ def changeWeightsInCollection(self):
+ """change all lables of a collection"""
+ ret=""
+ argv=self.REQUEST.form
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink'])
+ for resource in resources:
+
+ try:
+ ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
+ resource[1].weight=argv[resource[1].getId()][0:]
+ except:
+ pass
+ return ret
+
+ def changeTitlesInCollection(self):
+ """change all lables of a collection"""
+ ret=""
+ argv=self.REQUEST.form
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink'])
+ for resource in resources:
+
+ try:
+ ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
+ resource[1].title=argv[resource[1].getId()][0:]
+ except:
+ pass
+ return ret
+
+ def changeLabelsInCollection(self):
+ """change all lables of a collection"""
+ ret=""
+ argv=self.REQUEST.form
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_pageTemplate','ECHO_movie','ECHO_resource','ECHO_collection','ECHO_link','ECHO_externalLink'])
+ for resource in resources:
+
+ try:
+ ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
+ resource[1].label=argv[resource[1].getId()][0:]
+ except:
+ pass
+ return ret
+
+ def importCollection(self,path=None,RESPONSE=None):
+ """liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner"""
+
+ if path is None:
+ pt=zptFile(self, 'zpt/importCollection.zpt')
+ return pt()
+
+ files=os.listdir(path)
+ ret=""
+ for fileName in files:
+
+ if fileName:
+
+ tempPath=re.sub("/mpiwg/online","",path)
+ link="http://echo.mpiwg-berlin.mpg.de/zogilib_book?fn="+tempPath+"/"+fileName+"/pageimg"
+
+ metalink=self.path+"/"+fileName+"/index.meta"
+ try:
+
+ #link="http://nausikaa2.mpiwg-berlin.mpg.de/cgi-bin/toc/toc.x.cgi?dir="+fileName+"&step=thumb"
+
+ newObj=ECHO_resource(fileName,link,metalink,fileName,fileName,fileName,'generated','book','','','','','','')
+ self._setObject(fileName,newObj)
+
+ genObj=getattr(self,fileName)
+ #genObj.createIndexFile()
+ ret+="OK:"+fileName+" "
+ except:
+ print "ERROR"
+ ret+="ERROR:"+fileName+" "
+
+ return ret
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def changeViewerTemplateSetsForm(self):
+ """change the viewer template set"""
+ pt=zptFile(self, 'zpt/changeViewerTemplateSet')
+ return pt()
+
+ def getViewerTemplateSets(self,obj_ids=None,RESPONSE=None):
+ """Get the ViewerTemplateSet title for configuration"""
+ ret=[]
+
+ try:
+ viewerTemplateSets=self.ZopeFind(self.viewerTemplateSets,obj_metatypes=['OSAS_viewerTemplateSet'],obj_ids=obj_ids)#assumes viewerTemplateSets folder somewhere in the hierarchie.
+
+ for viewerTemplateSet in viewerTemplateSets:
+ ret.append((viewerTemplateSet[1].title,viewerTemplateSet[0],viewerTemplateSet[1]))
+
+ return ret
+
+ except:
+ return [('no ViewerTemplateSetfolders','')]
+
+ def getTextToolsField(self,name,default=''):
+ """Lese viewerTemplateSet der Collection not implemented yet!"""
+
+ return default
+
+
+ def isSelectedViewerTemplateSet(self,obj,id):
+ """is ausgewaehlt"""
+
+ if self.REQUEST['viewerTemplateSet']==id:
+ return 1
+ else:
+ return None
+
+ def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix,RESPONSE=None):
+ """change the templates"""
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1)
+
+ for resource in resources:
+
+ resource[1].changeViewerTemplateSet(project,xslt,thumbtemplate,topbar,digiLibTemplate,digiliburlprefix)
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+
+ def setStartpageFolderForm(self):
+ """Form for changing the startpage"""
+
+
+ pt=zptFile(self, 'zpt/ChangeECHO_resourceStartPageFolder.zpt')
+ pt.content_type="text/html"
+ return pt()
+
+ def setStartpageFolder(self,startpage=None,RESPONSE=None):
+ """change the templates"""
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1)
+
+ for resource in resources:
+
+ resource[1].setStartPage(startpage)
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def copyTitleToInfoXMLFolder(self,RESPONSE=None):
+ """copy title into the title field of info.xml
+ author and date werden leer!!!
+ """
+
+
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1)
+
+
+ for resource in resources:
+ ret,txt=resource[1].copyTitleToInfoXML()
+ if (not ret) and RESPONSE:
+ RESPONSE.write("error: %s\n"%txt)
+ if ret and RESPONSE:
+ RESPONSE.write("ok: %s\n"%txt)
+
+ #zLOG.LOG("ECHO (copyTitleToInfoXMLFolder)",zLOG.INFO,txt)
+ if RESPONSE is not None:
+ RESPONSE.write("done!\n")
+ RESPONSE.close()
+ RESPONSE.redirect('manage_main')
+
+ def copySearchFields(self,RESPONSE=None):
+ """copys < metadatafields to the object"""
+ resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1)
+
+ for resource in resources:
+
+ resource[1].copySearchFields()
+
+ if RESPONSE is not None:
+ RESPONSE.redirect('manage_main')
+
+ def reloadMetaDataFromStorageWarning(self,RESPONSE=None):
+ """warning"""
+ pt=zptFile(self, 'zpt/reloadMetaDataFromStorageWarning.zpt')
+ pt.content_type="text/html"
+ return pt()
+
+ def reloadMetaDataFromStorage(self,RESPONSE=None):
+ """copy metadata from the storage to ECHO"""
+
+ return reloadMetaDataFromStorage(self,RESPONSE)
+
+
+ def getPartnerCopyright(self,name,sonst="generic"):
+ """gibt generisches copyright eines partners aus, sonst behalte jetzige einsteillung"""
+ #print "hi",name,sonst
+ #print getattr(self.partners,name).copyrightType
+ try:
+ partner=getattr(self.partners,name)
+ return partner.copyrightType
+ except:
+ print "error"
+ return sonst
+
+ def partnerSelector_HTML(self,selected=None):
+ """give type selector"""
+ if not selected:
+ retStr="