version 1.35, 2004/04/08 08:44:47
|
version 1.141, 2004/07/17 10:19:06
|
Line 19 from Globals import DTMLFile
|
Line 19 from Globals import DTMLFile
|
from OFS.Folder import Folder |
from OFS.Folder import Folder |
from OFS.SimpleItem import SimpleItem |
from OFS.SimpleItem import SimpleItem |
from AccessControl import ClassSecurityInfo |
from AccessControl import ClassSecurityInfo |
|
from AccessControl.User import UserFolder |
from Globals import InitializeClass |
from Globals import InitializeClass |
from Globals import DTMLFile |
from Globals import DTMLFile |
|
import Globals |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.PageTemplate import PageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
from Globals import Persistent, package_home |
from Globals import Persistent, package_home |
from Acquisition import Implicit |
from Acquisition import Implicit |
|
from ECHO_helpers import displayTypes |
|
import urllib |
|
|
|
try: |
|
from psycopg import libpq |
|
except: |
|
try: |
|
from pyPgSQL import libpq |
|
except: |
|
print "ECHO_collection: Warning - No libpq imported!" |
|
|
#from psycopg import libpq |
|
#from pyPgSQL import libpq |
|
import xml.dom.minidom |
import xml.dom.minidom |
|
|
import urllib |
import urllib |
import xml.dom.minidom |
import xml.dom.minidom |
from ECHO_graphicalOverview import javaHandler,javaScriptMain |
from ECHO_graphicalOverview import javaHandler,javaScriptMain |
|
import ECHO_helpers |
|
|
|
def getCopyrightsFromForm(self,argv): |
|
medias={} |
|
partners={} |
|
copyrights={} |
|
|
|
copyrightsFinal=[] |
|
for arg in argv.keys(): |
|
|
|
if arg[0:5]=='media': |
|
nm=int(arg[5:]) |
|
medias[nm]=argv[arg] |
|
elif arg[0:5]=='partn': |
|
nm=int(arg[5:]) |
|
partners[nm]=argv[arg] |
|
elif arg[0:5]=='copyr': |
|
nm=int(arg[5:]) |
|
copyrights[nm]=argv[arg] |
|
|
|
|
|
|
|
copyrightsList=[(medias[nm],partners[nm],copyrights[nm]) for nm in medias.keys()] |
|
for copyright in copyrightsList: |
|
|
|
if copyright[2]=='institution0000': |
|
copyrightsFinal.append((copyright[0],copyright[1],self.getPartnerCopyright(copyright[1],''))) |
|
else: |
|
if not copyright[0]=='': |
|
copyrightsFinal.append(copyright) |
|
|
|
|
|
return copyrightsFinal |
|
|
#List of different types for the graphical linking viewer |
#List of different types for the graphical linking viewer |
viewClassificationListMaster=['view point','area'] |
viewClassificationListMaster=['view point','area'] |
|
|
|
|
|
def checkDiffs(self,metadict): |
|
"""check differences""" |
|
|
|
|
|
|
|
|
|
def NoneToEmpty(obj): |
|
if obj: |
|
return obj |
|
else: |
|
return "" |
|
|
|
|
|
|
|
diffs={} |
|
|
|
tags=self.findTagsFromMapping(self.contentType) |
|
self.referencetypes=tags[2] |
|
self.fields=tags[3] |
|
|
|
|
|
for field in tags[1]: |
|
try: |
|
if (NoneToEmpty(self.getFieldValue(self.getFieldTag(tags,field)))==metadict[self.getFieldTag(tags,field)]): |
|
diffs[self.getFieldTag(tags,field)]=1 |
|
else: |
|
|
|
diffs[self.getFieldTag(tags,field)]=0 |
|
except: |
|
diffs[self.getFieldTag(tags,field)]=0 |
|
|
|
return diffs |
|
|
def content_html(self,type): |
def content_html(self,type): |
"""template fuer content""" |
"""template fuer content""" |
#templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) |
#templates = self.ZopeFind(self.aq_parent,obj_ids=[type+"_template"]) |
Line 45 def content_html(self,type):
|
Line 122 def content_html(self,type):
|
#if templates: |
#if templates: |
# return templates[0][1]() |
# return templates[0][1]() |
|
|
try: |
if hasattr(self,type+"_template"): |
obj=getattr(self,type+"_template") |
obj=getattr(self,type+"_template") |
return obj() |
return obj() |
except: |
else: |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_%s_template_standard.zpt'%type).__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_%s_template_standard.zpt'%type).__of__(self) |
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
return pt() |
Line 69 def getText(nodelist):
|
Line 146 def getText(nodelist):
|
return rc |
return rc |
|
|
|
|
|
def sendFile(self, filename, type): |
|
"""sends an object or a local file (in the product) as response""" |
|
paths = filename.split('/') |
|
object = self |
|
# look for an object called filename |
|
for path in paths: |
|
if hasattr(object, path): |
|
object = getattr(object, path) |
|
else: |
|
object = None |
|
break |
|
if object: |
|
# if the object exists then send it |
|
return object.index_html(self.REQUEST.REQUEST, self.REQUEST.RESPONSE) |
|
else: |
|
# send a local file with the given content-type |
|
fn = os.path.join(package_home(globals()), filename) |
|
self.REQUEST.RESPONSE.setHeader("Content-Type", type) |
|
self.REQUEST.RESPONSE.write(file(fn).read()) |
|
return |
|
|
|
class BrowserCheck: |
|
"""check the browsers request to find out the browser type""" |
|
|
|
def __init__(self, zope): |
|
self.ua = zope.REQUEST.get_header("HTTP_USER_AGENT") |
|
self.isN4 = (string.find(self.ua, 'Mozilla/4.') > -1) and (string.find(self.ua, 'MSIE') < 0) |
|
self.isIE = string.find(self.ua, 'MSIE') > -1 |
|
self.nav = self.ua[string.find(self.ua, '('):] |
|
ie = string.split(self.nav, "; ")[1] |
|
if string.find(ie, "MSIE") > -1: |
|
self.versIE = string.split(ie, " ")[1] |
|
self.isMac = string.find(self.ua, 'Macintosh') > -1 |
|
self.isWin = string.find(self.ua, 'Windows') > -1 |
|
self.isIEWin = self.isIE and self.isWin |
|
self.isIEMac = self.isIE and self.isMac |
|
|
|
|
|
|
|
|
|
def writeMetadata(url,metadict,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=None): |
|
"""Einlesen der Metadaten und und erstellen des geaenderten XML file""" |
|
def updateTextToolNode(tag,value): |
|
#print dom,tag,value |
|
metanode=dom.getElementsByTagName('texttool')[0] |
|
try: |
|
nodeOld=metanode.getElementsByTagName(tag) |
|
except: |
|
nodeOld=None |
|
|
|
if nodeOld: |
|
metanode.removeChild(nodeOld[0]).unlink() |
|
|
|
node=dom.createElement(tag) |
|
nodetext=dom.createTextNode(value) |
|
node.appendChild(nodetext) |
|
metanode.appendChild(node) |
|
|
|
|
|
try: |
|
geturl="" |
|
for line in urllib.urlopen(url).readlines(): |
|
geturl=geturl+line |
|
|
|
|
|
except: |
|
return (None,"Cannot open: "+url) |
|
|
|
try: |
|
dom=xml.dom.minidom.parseString(geturl) |
|
except: |
|
return (None,"Cannot parse: "+url+"<br>"+geturl) |
|
|
|
metanodes=dom.getElementsByTagName('bib') |
|
|
|
if not metanodes: |
|
metanodes=dom.getElementsByTagName('archimedes') |
|
|
|
metanode=metanodes[0] |
|
|
|
for metaData in metadict.keys(): |
|
|
|
try: |
|
nodeOld=metanode.getElementsByTagName(metaData) |
|
except: |
|
nodeOld=None |
|
|
|
if nodeOld: |
|
metanode.removeChild(nodeOld[0]).unlink() |
|
else: |
|
# try also old writing rule - instead of _: |
|
try: |
|
nodeOld=metanode.getElementsByTagName(re.sub('_','-',metaData)) |
|
except: |
|
nodeOld=None |
|
|
|
if nodeOld: |
|
metanode.removeChild(nodeOld[0]).unlink() |
|
|
|
metanodeneu=dom.createElement(metaData) |
|
try: |
|
metanodetext=dom.createTextNode(unicode(metadict[metaData],"utf-8")) |
|
except: |
|
metanodetext=dom.createTextNode(metadict[metaData].encode('utf-8')) |
|
metanodeneu.appendChild(metanodetext) |
|
metanode.appendChild(metanodeneu) |
|
|
|
|
|
|
|
|
|
|
|
if project: |
|
updateTextToolNode('project',project) |
|
|
|
if startpage: |
|
updateTextToolNode('startpage',startpage) |
|
|
|
if topbar: |
|
updateTextToolNode('toptemplate',topbar) |
|
|
|
if thumbtemplate: |
|
updateTextToolNode('thumbtemplate',thumbtemplate) |
|
|
|
if xslt: |
|
updateTextToolNode('xslt',xslt) |
|
|
|
|
|
|
|
return dom.toxml().encode('utf-8') |
|
|
|
|
|
|
def readMetadata(url): |
def readMetadata(url): |
"""Methoden zum Auslesen der Metadateninformation zu einer Resource |
"""Methode zum Auslesen der Metadateninformation zu einer Resource |
Vorerst noch Typ bib""" |
Vorerst noch Typ bib""" |
|
|
metadict={} |
metadict={} |
Line 93 def readMetadata(url):
|
Line 302 def readMetadata(url):
|
if len(metanode)==0: |
if len(metanode)==0: |
metanode=dom.getElementsByTagName('archimedes') |
metanode=dom.getElementsByTagName('archimedes') |
metadict['bib_type']='Archimedes' |
metadict['bib_type']='Archimedes' |
#print "HELLO" |
|
|
|
if not len(metanode)==0: |
if not len(metanode)==0: |
metacontent=metanode[0].childNodes |
metacontent=metanode[0].childNodes |
Line 105 def readMetadata(url):
|
Line 314 def readMetadata(url):
|
|
|
for node in metacontent: |
for node in metacontent: |
try: |
try: |
metadict[node.tagName.lower()]=getText(node.childNodes) |
#print urllib.unquote(getText(node.childNodes)),getText(node.childNodes) |
|
metadict[re.sub('-','_',node.tagName.lower())]=urllib.unquote(getText(node.childNodes)) |
except: |
except: |
"""nothing""" |
"""nothing""" |
|
|
#print metadict |
|
return metadict,"" |
return metadict,"" |
|
|
|
|
Line 130 def setECHO_collectionInformation(self,t
|
Line 340 def setECHO_collectionInformation(self,t
|
coords=[] |
coords=[] |
#coordinates of for rectangles |
#coordinates of for rectangles |
|
|
#print "cs", coordstrs |
|
if coordstrs: |
if coordstrs: |
for coordstr in coordstrs: |
for coordstr in coordstrs: |
#print "cs", coordstr |
|
try: |
try: |
temco=coordstr.split(",") |
temco=coordstr.split(",") |
except: |
except: |
temco=[] |
temco=[] |
#temco.append(angle) |
|
coords.append(temco) |
coords.append(temco) |
|
|
|
|
self.coords=coords[0:] |
self.coords=coords[0:] |
|
|
|
class ECHO_copyright(Folder): |
|
"""Copyright informationen""" |
|
meta_type="ECHO_copyright" |
|
|
class scientificClassification(SimpleItem,Persistent,Implicit): |
|
"""outdated will be deleeted in the next versions: subclass""" |
|
security=ClassSecurityInfo() |
|
|
|
def __init__(self,context,science,practice): |
|
self.context=context |
|
self.science=science |
|
self.practice=practice |
|
self.id="scientific_Classification" |
|
|
|
security.declarePublic('get_context') |
|
def get_context(self): |
|
return self.context |
|
|
|
security.declarePublic('get_science') |
|
def get_science(self): |
|
return self.science |
|
|
|
security.declarePublic('get_practice') |
|
def get_practice(self): |
|
return self.practice |
|
|
|
|
def __init__(self,id,title,copyrights): |
|
"""init""" |
|
self.title=title |
|
self.id=id |
|
self.copyrights=copyrights[0:] |
|
|
class scientificInformation(Folder,Persistent,Implicit): |
def getCopyrights(self): |
"""outdated will be deleted in the next versions: subclass scientificInformation""" |
"""return coyprights""" |
security=ClassSecurityInfo() |
return self.copyrights |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_copyright_configForm'}, |
|
) |
|
|
|
def ECHO_copyright_configForm(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyright').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_copyright_config(self,title,RESPONSE=None): |
|
"""change""" |
|
self.title=title |
|
self.copyrights=[] |
|
self.copyrights=getCopyrightsFromForm(self,self.REQUEST.form)[0:] |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
def __init__(self,source_type,period): |
def manage_addECHO_copyrightForm(self): |
|
"""Form for adding""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_copyright.zpt').__of__(self) |
|
return pt() |
|
|
self.id="scientific_Information" |
def manage_addECHO_copyright(self, id,title,RESPONSE=None): |
self.source_type=source_type |
"""add the copyright""" |
self.period=period |
|
|
|
|
meta_type="ECHO_copyright" |
|
|
|
#first generate copyrights as list of tripels (mediaType,partner,copyrightType) |
|
|
security.declarePublic('get_source_type') |
|
def get_source_type(self): |
|
return self.source_type |
|
|
|
security.declarePublic('get_period') |
|
def get_period(self): |
self._setObject(id, ECHO_copyright(id, title,getCopyrightsFromForm(self,self.REQUEST.form))) |
return self.period |
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
class ECHO_layoutTemplate(ZopePageTemplate): |
class ECHO_layoutTemplate(ZopePageTemplate): |
"""Create a layout Template for different purposes""" |
"""Create a layout Template for different purposes""" |
|
|
meta_type="ECHO_layoutTemplate" |
meta_type="ECHO_layoutTemplate" |
|
|
#manage_options=ZopePageTemplate.manage_options+( |
|
# {'label':'Set back to Standard','action':'changeECHO_layoutTemplateToStandardForm'}, |
|
# ) |
|
|
|
|
|
def __init__(self, id, text=None, content_type=None,EchoType=None): |
def __init__(self, id, text=None, content_type=None,EchoType=None): |
self.id = str(id) |
self.id = str(id) |
|
|
Line 212 class ECHO_layoutTemplate(ZopePageTempla
|
Line 426 class ECHO_layoutTemplate(ZopePageTempla
|
text = open(self._default_content_fn).read() |
text = open(self._default_content_fn).read() |
self.pt_edit(text, content_type) |
self.pt_edit(text, content_type) |
|
|
## def changeECHO_layoutTemplateToStandardForm(self): |
|
## """change form""" |
|
## pt=PageTemplateFile('Products/ECHO_content/zpt/changeECHO_pageTemplateWeightForm.zpt').__of__(self) |
|
## return pt() |
|
|
|
|
|
"""change form""" |
"""change form""" |
|
|
Line 268 def manage_addECHO_layoutTemplate(self,
|
Line 477 def manage_addECHO_layoutTemplate(self,
|
REQUEST.RESPONSE.redirect(u+'/manage_main') |
REQUEST.RESPONSE.redirect(u+'/manage_main') |
return '' |
return '' |
|
|
class ECHO_resource(Folder): |
class ECHO_resource(Folder,Persistent): |
"""ECHO Ressource""" |
"""ECHO Ressource""" |
|
security=ClassSecurityInfo() |
meta_type='ECHO_resource' |
meta_type='ECHO_resource' |
|
|
viewClassificationList=viewClassificationListMaster |
viewClassificationList=viewClassificationListMaster |
|
|
|
getSubCols = ECHO_helpers.getSubCols |
|
|
|
security.declareProtected('View','index_html') |
|
def getRDF(self): |
|
"""rdf""" |
|
ret="" |
|
about="""<RDF:Description about="%s">""" |
|
name="""<ECHONAVIGATION:name>%s</ECHONAVIGATION:name>""" |
|
link="""<ECHONAVIGATION:link>%s</ECHONAVIGATION:link>""" |
|
urn="urn:"+re.sub('/',':',self.absolute_url()) |
|
|
|
about2=about%urn |
|
name2=name%self.getId() |
|
link2=link%urllib.quote(self.link) |
|
|
|
ret=about2+"\n"+name2+"\n"+link2+"\n"+"</RDF:Description>" |
|
return ret |
|
|
|
|
|
def getAccessRightSelectorHTML(self,outlook="select"): |
|
"""htmlselector""" |
|
values=['free','mpiwg'] |
|
|
|
if outlook=="select": |
|
ret="""<select name="%s">"""%self.getId() |
|
|
|
for value in values: |
|
if value==self.getAccessRightMD(): |
|
ret+="<option selected>%s</option>"%value |
|
else: |
|
ret+="<option>%s</option>"%value |
|
return ret+"</select>" |
|
|
|
else: |
|
ret="" |
|
for value in values: |
|
print |
|
if value==self.getAccessRightMD(): |
|
ret+="""<input type="radio" name="%s" value="%s" checked>%s"""%(self.getId(),value,value) |
|
else: |
|
ret+="""<input type="radio" name="%s" value="%s">%s"""%(self.getId(),value,value) |
|
return ret |
|
|
|
|
|
|
|
def getAccessRightMD(self): |
|
"""set accessright""" |
|
url=self.metalink |
|
|
|
try: |
|
geturl="" |
|
for line in urllib.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+"<br>"+geturl) |
|
|
|
internal=dom.getElementsByTagName('internal') |
|
if internal: |
|
institution=dom.getElementsByTagName('institution') |
|
return getText(institution[0].childNodes) |
|
|
|
free=dom.getElementsByTagName('free') |
|
if free: |
|
return "free" |
|
|
|
return "free" #default free |
|
|
|
def changeAccessRightMD(self,accessright,RESPONSE=None): |
|
"""change the rights""" |
|
|
|
params="accessright=%s"%accessright |
|
|
|
|
|
#print urllib.urlopen(self.absolute_url()+'/setAccessRightXML'+'?'+params).read() |
|
|
|
|
|
urllib.urlopen('http://xserve02.mpiwg-berlin.mpg.de:18880/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 |
|
|
|
try: |
|
geturl="" |
|
for line in urllib.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+"<br>"+geturl) |
|
|
|
metanodes=dom.getElementsByTagName('access-conditions') |
|
|
|
if not metanodes: |
|
nodenew=dom.createElement('access-conditions') |
|
root.appendChild(nodenew) |
|
metanode=nodenew |
|
else: |
|
metanode=metanodes[0] |
|
|
|
accesses=metanode.getElementsByTagName('access') |
|
|
|
if not accesses: |
|
nodenew2=dom.createElement('access') |
|
metanode.appendChild(nodenew2) |
|
metanode2=nodenew2 |
|
else: |
|
metanode2=accesses[0] |
|
|
|
internal=metanode.getElementsByTagName('internal') |
|
|
|
if internal: |
|
metanode2.removeChild(internal[0]).unlink() |
|
|
|
free=metanode.getElementsByTagName('free') |
|
|
|
if free: |
|
metanode2.removeChild(internal[0]).unlink() |
|
|
|
|
|
if accessright=='free': |
|
nodenew3=dom.createElement('free') |
|
metanode2.appendChild(nodenew3) |
|
elif accessright=='mpiwg': |
|
nodenew3=dom.createElement('internal') |
|
nodenew4=dom.createElement('institution') |
|
metanodetext=dom.createTextNode('mpiwg') |
|
nodenew4.appendChild(metanodetext) |
|
nodenew3.appendChild(nodenew4) |
|
metanode2.appendChild(nodenew3) |
|
|
|
return dom.toxml().encode('utf-8') |
|
|
|
def setStartPageForm(self): |
|
"""Form for changing the startpage""" |
|
|
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resourceStartPage.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
|
|
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)) and ("__generic" in startpage): # checke ob generic in der liste |
|
startpage=self.absolute_url()+"/startpage_html" |
|
|
|
if (not startpage) or (startpage=="__generic"): |
|
startpage=self.absolute_url()+"/startpage_html" |
|
|
|
|
|
params="startpage=%s"%startpage |
|
|
|
urllib.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://foxridge.rz-berlin.mpg.de','',path) # falls foxridge als server |
|
path=re.sub('/index.meta','',path) |
|
|
|
|
|
urllib.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=PageTemplateFile('Products/ECHO_content/zpt/changeResourceViewerTemplateSet').__of__(self) |
|
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,RESPONSE=None): |
|
"""changeit""" |
|
|
|
paramList=['project','startpage','xslt','thumbtemplate','topbar','digiLibTemplate'] |
|
|
|
|
|
#writeMetadata(self.metalink,self.metaDataHash,project,None,xslt,thumbtemplate,topbar,digiLibTemplate) |
|
|
|
params="project=%s&xslt=%s&thumbtemplate=%s&topbar=%s&digiLibTemplate=%s"%(project,xslt,thumbtemplate,topbar,digiLibTemplate) |
|
|
|
|
|
urllib.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() |
|
|
|
# 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 |
|
|
|
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: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def getTitle(self): |
|
"""title""" |
|
try: |
|
return self.title.encode('utf-8','ignore') |
|
except: |
|
self.title=self.title.decode('iso-8859-1','ignore')[0:] #correnct conding error |
|
return self.title.encode('utf-8','ignore') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
try: |
|
return self.label.encode('utf-8','ignore') |
|
except: |
|
self.label=self.label.decode('iso-8859-1','ignore')[0:] #correnct conding error |
|
return self.label.encode('utf-8','ignore') |
|
|
def content_html(self): |
def content_html(self): |
"""template fuer content""" |
"""template fuer content""" |
return content_html(self,'resource') |
return content_html(self,'resource') |
Line 284 class ECHO_resource(Folder):
|
Line 763 class ECHO_resource(Folder):
|
else: |
else: |
return "" |
return "" |
|
|
|
def getFullTextXML(self,noredirect=None): |
|
"""getFullTextXML; gives the FullText as an XML Document, and <error></error> if somthing goes wrong.""" |
|
try: |
|
fh=urllib.urlopen(self.metalink) |
|
dom=xml.dom.minidom.parse(fh) |
|
texttools=dom.getElementsByTagName('texttool') |
|
text=texttools[0].getElementsByTagName('text') |
|
texturl=getText(text[0].childNodes) |
|
|
|
if not noredirect: |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
self.REQUEST.RESPONSE.redirect(texturl) |
|
else: |
|
return texturl |
|
except: |
|
|
|
if not noredirect: |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
self.REQUEST.RESPONSE.write("<error>no fulltext available</error>") |
|
else: |
|
return "<error>no fulltext available</error>" |
|
|
|
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(): |
|
|
|
link="copyrightTypes/"+copyright[2]+'/copyright.html' |
|
|
|
try: |
|
copyrightTypeObj=getattr(self.copyrightTypes,copyright[2]) |
|
label=copyrightTypeObj.label |
|
url=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 getCredits(self): |
def getCredits(self): |
"""Ausgabe der credits""" |
"""Ausgabe der credits""" |
if self.credits: |
if self.credits: |
Line 291 class ECHO_resource(Folder):
|
Line 823 class ECHO_resource(Folder):
|
else: |
else: |
return [] |
return [] |
|
|
def __init__(self,id,link,metalink,title,label,description,contentType,responsible,credits,weight,coords): |
def __init__(self,id,link,metalink,resourceID,title,label,description,contentType,renderingType,copyrightType,responsible,credits,weight,coords): |
|
|
self.id = id |
self.id = id |
"""Festlegen der ID""" |
"""Festlegen der ID""" |
Line 304 class ECHO_resource(Folder):
|
Line 836 class ECHO_resource(Folder):
|
self.credits=toList(credits) |
self.credits=toList(credits) |
self.description=description |
self.description=description |
self.contentType=contentType |
self.contentType=contentType |
|
self.copyrightType=copyrightType |
|
self.renderingType=renderingType |
self.responsible=responsible |
self.responsible=responsible |
|
self.resourceID=resourceID |
|
|
if coords: |
if coords: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
Line 315 class ECHO_resource(Folder):
|
Line 850 class ECHO_resource(Folder):
|
|
|
|
|
def getCoords(self): |
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""" |
|
retList=[] |
|
if hasattr(self,'coords'): |
|
for x in self.coords: |
|
if len(x)>1: |
|
retList.append(string.join(x,",")) |
|
return retList |
|
|
|
|
|
|
|
def getContentType(self): |
try: |
try: |
return [string.join(x,",") for x in self.coords] |
return self.contentType |
except: |
except: |
return [] |
return "" |
|
|
|
def getCopyrightType(self): |
|
try: |
|
return self.copyrightType |
|
except: |
|
return "" |
|
|
|
def getRenderingType(self): |
|
try: |
|
return self.renderingType |
|
except: |
|
return "" |
|
|
def ECHO_resource_config(self): |
def ECHO_resource_config(self): |
"""Main configuration""" |
"""Main configuration""" |
|
|
if not hasattr(self,'weight'): |
if not hasattr(self,'weight'): |
self.weight="" |
self.weight="" |
if not hasattr(self,'coords'): |
|
self.coords=[] |
|
|
|
print "vorher",self.coords |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource.zpt').__of__(self) |
return pt() |
return pt() |
|
|
|
|
|
def ECHO_resource_config_main(self): |
|
"""Main configuration""" |
|
|
|
if not hasattr(self,'weight'): |
|
self.weight="" |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource_main.zpt').__of__(self) |
|
return pt() |
|
|
|
def ECHO_resource_config_coords(self): |
|
"""Coords configuration """ |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource_coords.zpt').__of__(self) |
|
return pt() |
|
|
|
def ECHO_resource_config_credits(self): |
|
"""Main configuration""" |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource_credits.zpt').__of__(self) |
|
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.meta |
|
DataHash[data_neu]=getattr(self,data)[0:] |
|
|
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_resource_metadata.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
|
|
|
|
def changeECHO_resource_main(self,metalink,link,title,label,description,contentType,renderingType,weight,resourceID,RESPONSE=None): |
|
"""Änderung 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,coords,viewClassification,RESPONSE=None): |
|
"""Änderung der Properties - coords""" |
|
|
|
if type(coords)==StringType: |
|
coords=[coords] |
|
|
|
try: |
|
coordsnew=[ string.split(x,",") for x in coords] |
|
except: |
|
coordsnew=[] |
|
|
|
self.coords=coordsnew[0:] |
|
self.viewClassification=viewClassification |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def changeECHO_resource_credits(self,credits,responsible,copyrightType,RESPONSE=None): |
|
"""Änderung der Properties""" |
|
self.credits=credits |
|
self.responsible=responsible |
|
self.copyrightType=copyrightType |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
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: |
|
"""nothing""" |
|
|
|
urllib.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 getMDValue(self,fieldName): |
|
return self.metaDataHash.get(fieldName,'!!NOT USED HERE in Type: %s'%self.contentType) |
|
|
|
def newMetaXML(self,project=None,startpage=None,xslt=None,thumbtemplate=None,topbar=None,digiLibTemplate=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) |
|
except: |
|
return writeMetadata(self.metalink,self.metaDataHash,project,startpage,xslt,thumbtemplate,topbar,digiLibTemplate) |
|
|
|
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,viewClassification="",coords=None,credits=None,RESPONSE=None): |
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""" |
|
|
Line 343 class ECHO_resource(Folder):
|
Line 1030 class ECHO_resource(Folder):
|
coordsnew=[] |
coordsnew=[] |
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) |
|
self.viewClassification=viewClassification |
self.coords=coordsnew[0:] |
self.coords=coordsnew[0:] |
self.link=link |
self.link=link |
self.metalink=metalink |
self.metalink=metalink |
Line 353 class ECHO_resource(Folder):
|
Line 1040 class ECHO_resource(Folder):
|
|
|
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Main Config','action':'ECHO_resource_config'}, |
{'label':'Main Config','action':'ECHO_resource_config_main'}, |
{'label':'Metadata','action':'ECHO_getResourceMD'}, |
{'label':'Change Metadata','action':'ECHO_resource_config_metadata'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'label':'Change Coords','action':'ECHO_resource_config_coords'}, |
|
{'label':'Add coords','action':'ECHO_graphicEntry'}, |
|
{'label':'Sync Metadata','action':'ECHO_getResourceMD'}, |
|
{'label':'Change TemplateSets','action':'changeViewerTemplateSetForm'}, |
|
{'label':'set/change startpage','action':'setStartPageForm'}, |
|
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
) |
) |
|
|
def getOverview(self): |
def getOverview(self): |
Line 384 class ECHO_resource(Folder):
|
Line 1076 class ECHO_resource(Folder):
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('ECHO_graphicEntry') |
RESPONSE.redirect('ECHO_graphicEntry') |
|
|
def ECHO_getResourceMD(self,template="yes"): |
|
"""Einlesen der Metadaten und Anlegen dieser Metadaten als Informationen zur Resource""" |
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 getFieldValue(self,field): |
|
"""get value""" |
|
|
|
try: |
|
|
|
ret=self.metaDataHash[field] |
|
if ret == "": |
|
return None |
|
else: |
|
return ret |
|
except: |
|
return None |
|
|
|
def getMetaDataHash(self): |
|
"""md hash""" |
|
return self.metaDataHash |
|
|
|
def setFieldValue(self,field,value): |
|
"""get value""" |
|
|
|
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.getFieldValue(field)) |
|
|
|
|
|
def findLabelsFromMapping(self,referenceType): |
|
"""gib hash mit label -> generic zurueck""" |
|
#return {},[] |
|
|
|
temp=self.ZopeFind(self.standardMD) |
|
|
|
if referenceType=="": |
|
referenceType="book" |
|
|
|
|
|
bibdata={} |
|
retdata={} |
|
fields=[] |
|
fieldlist=self.standardMD.fieldList |
|
|
|
for referenceTypeF in self.referencetypes: |
|
|
|
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] |
|
|
|
return retdata,fieldlist,temp,fields |
|
|
|
def findTagsFromMapping(self,referenceType): |
|
"""gib hash mit label -> generic zurueck""" |
|
|
|
|
|
if referenceType=="": |
|
referenceType="book" |
|
|
|
temp = self.ZopeFind(self.standardMD)[0:] |
|
|
|
|
|
#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) |
(metadict, error)=readMetadata(self.metalink) |
|
|
|
|
|
|
|
self.metaDataHash={} |
if not error=="": #Fehler beim Auslesen des Metafiles |
if not error=="": #Fehler beim Auslesen des Metafiles |
|
|
return "ERROR:",error |
return "ERROR:",error |
for key in metadict.keys():#Hinzufügen der Felder |
|
|
|
setattr(self,key,metadict[key].encode('ascii','replace')) |
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') |
|
|
|
def ECHO_getResourceMD(self,template="yes",back=None): |
|
"""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 (metadict['bib_type'].lower()==self.contentType.lower()): |
|
self.REQUEST.SESSION['contentStorage']=metadict['bib_type'] |
|
self.REQUEST.SESSION['contentZope']=self.contentType |
|
|
|
return PageTemplateFile('Products/ECHO_content/zpt/ECHO_getResourceMDErrorContentType.zpt').__of__(self)() |
|
|
|
self.REQUEST.SESSION['metadict']=metadict |
|
|
|
|
|
|
|
self.REQUEST.SESSION['diffs']=checkDiffs(self,self.REQUEST.SESSION['metadict']) |
|
|
self.metadata=metadict.keys() |
|
|
|
self.label=self.generate_label() |
|
|
|
if template=="yes": |
if template=="yes": |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_resourceMD.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_resourceMD.zpt').__of__(self) |
return pt() |
return pt() |
|
|
|
|
|
|
|
|
|
|
def ECHO_getMD(self,item): |
def ECHO_getMD(self,item): |
"""Ausgabe der MD""" |
"""Ausgabe der MD""" |
return getattr(self,item) |
return getattr(self,item) |
Line 414 class ECHO_resource(Folder):
|
Line 1284 class ECHO_resource(Folder):
|
|
|
return self.REQUEST.RESPONSE.redirect(self.link) |
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]() |
|
|
|
#prüfen ob irgendwo ein template |
|
if hasattr(self,'startpage_index_template'): |
|
return self.startpage_index_template() |
|
|
|
#generisches template ausgeben |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_startpage_index_template_standard.zpt').__of__(self) |
|
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): |
def generate_label(self): |
"""Erzeugt_standard_Label aus Template""" |
"""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() |
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): |
def manage_addECHO_resourceForm(self): |
"""Form for adding a ressource""" |
"""Form for adding a ressource""" |
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_resourceForm.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_resourceForm.zpt').__of__(self) |
Line 427 def manage_addECHO_resourceForm(self):
|
Line 1340 def manage_addECHO_resourceForm(self):
|
|
|
|
|
|
|
def manage_addECHO_resource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
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): |
"""addaresource""" |
"""addaresource""" |
|
|
newObj=ECHO_resource(id,link,metalink,title,label,description,contentType,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) |
self._setObject(id,newObj) |
|
|
Line 443 class ECHO_externalLink(Folder):
|
Line 1356 class ECHO_externalLink(Folder):
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_externalLink' |
meta_type='ECHO_externalLink' |
|
|
|
def getTitle(self): |
|
"""title""" |
|
try: |
|
return self.title.encode('utf-8','ignore') |
|
except: |
|
self.title=self.title.decode('iso-8859-1','ignore')[0:] #correnct conding error |
|
return self.title.encode('utf-8','ignore') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
try: |
|
return self.label.encode('utf-8','ignore') |
|
except: |
|
self.label=self.label.decode('iso-8859-1','ignore')[0:] #correnct conding error |
|
return self.label.encode('utf-8','ignore') |
|
|
def content_html(self): |
def content_html(self): |
"""template fuer content""" |
"""template fuer content""" |
return content_html(self,'externalLink') |
return content_html(self,'externalLink') |
Line 471 class ECHO_externalLink(Folder):
|
Line 1400 class ECHO_externalLink(Folder):
|
if not hasattr(self,'coords'): |
if not hasattr(self,'coords'): |
|
|
self.coords=[''] |
self.coords=[''] |
#print "G",self.coords |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_externalLink.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_externalLink.zpt').__of__(self) |
return pt() |
return pt() |
Line 480 class ECHO_externalLink(Folder):
|
Line 1409 class ECHO_externalLink(Folder):
|
def changeECHO_externalLink(self,link,title,label,description,contentType,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): |
|
|
"""Änderung der Properties""" |
"""Änderung der Properties""" |
|
try: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
|
except: |
|
coordsnew=[] |
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coords) |
|
|
Line 494 class ECHO_externalLink(Folder):
|
Line 1426 class ECHO_externalLink(Folder):
|
{'label':'Main Config','action':'ECHO_externalLink_config'}, |
{'label':'Main Config','action':'ECHO_externalLink_config'}, |
) |
) |
|
|
def getCredits(self): |
|
"""Ausgabe der credits""" |
|
if self.credits: |
|
return self.credits |
|
else: |
|
return [] |
|
|
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
Line 523 def manage_addECHO_externalLink(self,id,
|
Line 1449 def manage_addECHO_externalLink(self,id,
|
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
|
|
class ECHO_link(ECHO_externalLink): |
|
"""external_link""" |
|
|
|
meta_type="ECHO_link" |
|
|
|
|
|
def content_html(self): |
|
"""template fuer link""" |
|
if hasattr(self,"link_template"): |
|
return content_html(self,'link') |
|
else: |
|
return content_html(self,'collection') |
|
|
|
def manage_addECHO_linkForm(self): |
|
"""Form for external Links""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_linkForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
def manage_addECHO_link(self,id,title,label,description,contentType,responsible,link,weight,coords=None,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) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
class ECHO_collection(Folder, Persistent, Implicit): |
class ECHO_collection(Folder, Persistent, Implicit): |
"""ECHO Collection""" |
"""ECHO Collection""" |
|
|
security=ClassSecurityInfo() |
security=ClassSecurityInfo() |
meta_type='ECHO_collection' |
meta_type='ECHO_collection' |
|
viewClassificationList=viewClassificationListMaster |
|
displayTypes=displayTypes |
|
|
|
path="/mpiwg/online/permanent/shipbuilding" |
|
|
|
def showRDF(self): |
|
"""showrdf""" |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
ret="""<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ECHONAVIGATION="http://www.echo.eu/rdf#">\n""" |
|
ret+=self.getRDF()+"\n" |
|
ret+="""</RDF:RDF>""" |
|
return ret |
|
|
|
def getRDF(self): |
|
"""rdf of the collection""" |
|
contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) |
|
|
|
about="""<RDF:Description about="%s">""" |
|
name="""<ECHONAVIGATION:name>%s</ECHONAVIGATION:name>""" |
|
link="""<ECHONAVIGATION:link>%s</ECHONAVIGATION:link>""" |
|
urn="urn:"+re.sub('/',':',self.absolute_url()) |
|
|
|
about2=about%urn |
|
name2=name%self.getId() |
|
link2=link%urllib.quote(self.absolute_url()) |
|
|
|
ret=about2+"\n"+name2+"\n"+link2+"\n"+"</RDF:Description>" |
|
|
|
|
|
|
|
li="""<RDF:li resource="%s" />\n""" |
|
|
|
|
|
for content in contents: |
|
ret+=content[1].getRDF()+"\n" |
|
|
|
ret+="""<RDF:Seq about="%s">\n"""%urn |
|
for content in contents: |
|
nurn="urn:"+re.sub('/',':',content[1].absolute_url()) |
|
ret+=li%nurn |
|
return ret+"</RDF:Seq>" |
|
|
|
|
|
def changeLabels(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeLabelsForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def changeTitles(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeTitleForm').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def changeAccessRightsCollection(self): |
|
"""change""" |
|
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()]+"</br>" |
|
resource[1].changeAccessRightMD(argv[resource[1].getId()]) |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeLabelsInCollection(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()]+"</br>" |
|
resource[1].label=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def changeTitlesInCollection(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()]+"</br>" |
|
resource[1].title=argv[resource[1].getId()][0:] |
|
except: |
|
"""not""" |
|
return ret |
|
|
|
def updateCollection(self,RESPONSE=None): |
|
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
|
files=os.listdir(self.path) |
|
ret="" |
|
for fileName in files: |
|
|
|
if fileName: |
|
|
|
tempPath=re.sub("/mpiwg/online","",self.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+"<br/>" |
|
except: |
|
print "ERROR" |
|
ret+="ERROR:"+fileName+"<br/>" |
|
|
|
return ret |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def updateCollectionMD(self,RESPONSE=None): |
|
"""updateMD""" |
|
files=os.listdir(self.path) |
|
for fileName in files: |
|
if fileName: |
|
genObj=getattr(self,fileName) |
|
genObj.copyIndex_meta2echo_resource() |
|
genObj.generate_title() |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
def changeViewerTemplateSetsForm(self): |
|
"""change the viewer template set""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/changeViewerTemplateSet').__of__(self) |
|
return pt() |
|
|
|
def getViewerTemplateSets(self,obj_ids=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 ausgewählt""" |
|
|
|
if self.REQUEST['viewerTemplateSet']==id: |
|
return 1 |
|
else: |
|
return None |
|
|
|
def changeViewerTemplateSets(self,project,xslt,thumbtemplate,topbar,digiLibTemplate,RESPONSE=None): |
|
"""change the templates""" |
|
|
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
|
|
for resource in resources: |
|
|
|
resource[1].changeViewerTemplateSet(project,xslt,thumbtemplate,topbar,digiLibTemplate) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def copySearchFields(self,RESPONSE=None): |
|
"""copys import metadatafields to the object""" |
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
|
|
for resource in resources: |
|
|
|
resource[1].copySearchFields() |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def reloadMetaDataFromStorage(self,RESPONSE=None): |
|
"""copy metadata from the storage to ECHO""" |
|
ret="" |
|
resources=self.ZopeFind(self,obj_metatypes=['ECHO_resource']) |
|
|
|
for resource in resources: |
|
|
|
ret+=str(resource[1].copyIndex_meta2echo_resource())+"<br>" |
|
|
|
|
|
if RESPONSE is not None: |
|
# RESPONSE.redirect('manage_main') |
|
return ret |
|
|
|
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="<option selected>\n" |
|
else: |
|
retStr="<option>\n" |
|
|
|
try: # erste version copyrightTypes exists |
|
for partner in self.credits: |
|
if selected and (partner==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(partner,partner) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(partner,partner) |
|
except: |
|
"""nothing""" |
|
return retStr |
|
|
|
def getViewClassification(self): |
|
if hasattr(self,'viewClassification'): |
|
return self.viewClassification |
|
else: |
|
return "" |
|
|
|
def getTitle(self): |
|
"""title""" |
|
try: |
|
return self.title.encode('utf-8','ignore') |
|
except: |
|
self.title=self.title.decode('iso-8859-1','ignore')[0:] #correnct conding error |
|
return self.title.encode('utf-8','ignore') |
|
|
|
def getLabel(self): |
|
"""title""" |
|
try: |
|
return self.label.encode('utf-8','ignore') |
|
except: |
|
self.label=self.label.decode('iso-8859-1','ignore')[0:] #correnct conding error |
|
return self.label.encode('utf-8','ignore') |
|
|
|
def createRessourcesFromXMLForm(self): |
|
"""form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/createRessourcesFromXMLForm.zpt').__of__(self) |
|
return pt() |
|
|
|
def createRessourcesFromXML(self,fileupload): |
|
"""read an XML file for generating resources""" |
|
dom=xml.dom.minidom.parse(fileupload) |
|
ret="<h2>Added</h2>" |
|
for resource in dom.getElementsByTagName('resource'): |
|
link=getText(resource.getElementsByTagName('link')[0].childNodes) |
|
label=getText(resource.getElementsByTagName('label')[0].childNodes) |
|
#splitted=link.split("?")[0].split("/") |
|
#id=splitted[len(splitted)-1].encode('ascii') |
|
id=re.sub(" ","_",label).encode('ascii') |
|
|
|
ret+="<p>"+label+"</p>" |
|
manage_addECHO_resource(self,id,label.encode('ascii'),label.encode('ascii'),"","","",link.encode('ascii'),"","") |
|
return ret |
|
|
def getImageTag(self): |
def getImageTag(self): |
"""GetTag""" |
"""GetTag""" |
Line 539 class ECHO_collection(Folder, Persistent
|
Line 1781 class ECHO_collection(Folder, Persistent
|
def addResource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
def addResource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None): |
"""SSS""" |
"""SSS""" |
try: |
try: |
manage_addECHO_resource(self,id,title,label,description,contentType,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
manage_addECHO_resource(self,id,title,label,description,responsible,link,metalink,weight,credits=None,coords=None,RESPONSE=None) |
return "done" |
return "done" |
except: |
except: |
return None |
return None |
Line 567 class ECHO_collection(Folder, Persistent
|
Line 1809 class ECHO_collection(Folder, Persistent
|
for entry in object.__dict__.keys(): |
for entry in object.__dict__.keys(): |
element=getattr(object,entry) |
element=getattr(object,entry) |
try: |
try: |
if element.meta_type=="ECHO_collection": |
if element.meta_type in ["ECHO_collection","ECHO_group"]: |
collections+="<element name=\""+element.title+"\" url=\""+element.absolute_url()+"\">" |
collections+="<element name=\""+quote(element.title)+"\" url=\""+element.absolute_url()+"\">" |
collections+=getCollection(element,depth)+"</element>\n" |
collections+=getCollection(element,depth)+"</element>\n" |
except: |
except: |
"""nothing""" |
"""nothing""" |
return collections |
return collections |
|
|
|
ret="""<?xml version="1.0" encoding="utf-8" ?>""" |
return "<collection>"+getCollection(self)+"</collection>" |
return ret+"<collection>"+getCollection(self)+"</collection>" |
|
|
def createJavaScript(self): |
def createJavaScript(self): |
"""CreateJava""" |
"""OLD CreateJava""" |
ret=javaScriptMain |
ret=javaScriptMain |
|
|
dynamical="" |
dynamical="\n" |
for ob in self.getGraphicCoords(): |
for ob in self.getGraphicCoords(): |
|
if ob[4][4] == "": |
dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) |
dynamical+="""Coords.push(new Coord('%s', Img, %s));\n"""%(ob[1],ob[0]) |
|
else: |
|
dynamical+="""Coords.push(new Coord('%s', Img, %s));//%s\n"""%(ob[1],ob[0],ob[4][4]) |
|
dynamical+="ShowArrow(new getObj('i.%s'),Img,%s);\n"%(ob[1],ob[0]) |
ret+=javaHandler%dynamical |
ret+=javaHandler%dynamical |
return ret |
return ret |
|
|
|
def createJSAreas(self): |
|
"""create area calls for JavaScript""" |
|
dynamical="\n" |
|
for ob in self.getGraphicCoords(): |
|
if ob[5] == "area": |
|
dynamical+="""addArea('%s', 'overview', %s, 'area');\n"""%(ob[1],ob[0]) |
|
else: |
|
dynamical+="""addArea('%s', 'overview', %s, 'arrow');\n"""%(ob[1],ob[0]) |
|
return dynamical |
|
|
|
def createMapHead(self): |
|
"""create javascript include and script tags for head""" |
|
pt=PageTemplateFile(os.path.join(package_home(globals()), 'zpt/ECHO_content_map_frag_js')).__of__(self) |
|
return pt() |
|
|
|
def createMapImg(self): |
|
"""generate img-tag for map""" |
|
bt = BrowserCheck(self) |
|
tag = "" |
|
src = self.REQUEST['URL1'] + "/overview" |
|
if bt.isN4: |
|
tag += '<ilayer id="overview" visibility="show"><img src="%s"></ilayer>'%src |
|
else: |
|
tag += '<img id="overview" src="%s" />'%src |
|
return tag |
|
|
|
def createMapLink(self, ob, text=None): |
|
"""generate map link""" |
|
bt = BrowserCheck(self) |
|
id = ob[1] |
|
link = ob[1] |
|
if text == None: |
|
text = ob[2] |
|
tag = "" |
|
if bt.isN4: |
|
tag += '<ilayer id="a.%s"><a onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank"'%(id,id,id,link) |
|
tag += ">" + text + "</a></ilayer>" |
|
else: |
|
tag = '<a id="a.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank"'%(id,id,id,link) |
|
if ob[3].contentType == 'text-popup': |
|
tag += ' title="%s"'%ob[3].description |
|
tag += ">" + text + "</a>" |
|
return tag |
|
|
|
def createMapAux(self, ob, arrowsrc="http://nausikaa2.rz-berlin.mpg.de/digitallibrary/servlet/Scaler/?dw=15&fn=icons/pfeil"): |
|
"""generate map link image, text and other stuff""" |
|
id = ob[1] |
|
link = ob[1] |
|
vtype = ob[5] |
|
ctype = ob[3].contentType |
|
bt = BrowserCheck(self) |
|
tag = "" |
|
|
|
if bt.isN4: |
|
tag += '<layer id="i.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)">'%(id,id,id) |
|
if vtype == "view point": |
|
rot = ob[4][4] |
|
tag += '<a href="%s"><img border="0" src="%s&rot=%s" /></a>'%(link,arrowsrc,rot) |
|
else: |
|
tag += '<a href="%s"><img border="0" width="1000" height="1000" src="trans_img"'%(link) |
|
if ctype == "text-popup": |
|
desc = ob[3].description |
|
tag += ' alt="%s"'%desc |
|
tag += ' /></a>' |
|
tag += '</layer>' |
|
else: |
|
tag = '<a id="b.%s" onmouseover="highlightPair(\'%s\', true)" onmouseout="highlightPair(\'%s\', false)" href="%s" target="_blank">'%(id,id,id,link) |
|
if vtype == "view point": |
|
rot = ob[4][4] |
|
if bt.isIEWin and bt.versIE > 5: |
|
tag += '<span id="i.%s" style="position:absolute; top:-100px; left:-100px; border-style:none; border-width=1px; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src=\'%s&rot=%s\');"><img style="visibility:hidden" src="%s&rot=%s" /></span>'%(id,arrowsrc,rot,arrowsrc,rot) |
|
else: |
|
tag += '<img id="i.%s" src="%s&rot=%s" border="1" style="position:absolute; top:-100px; left:-100px; border-style:none;" />'%(id,arrowsrc,rot) |
|
else: |
|
if bt.isIEWin: |
|
tag += '<div id="i.%s" style="position:absolute; top:-100px; left:-100px;background:url(area_img)"'%(id) |
|
else: |
|
tag += '<div id="i.%s" style="position:absolute; top:-100px; left:-100px;"'%(id) |
|
if ctype == "text-popup": |
|
desc = ob[3].description |
|
tag += ' title="%s"'%desc |
|
tag += '> </div>' |
|
tag += '</a>' |
|
return tag |
|
|
|
|
security.declarePublic('getCreditObject') |
security.declarePublic('getCreditObject') |
def getCreditObject(self,name): |
def getCreditObject(self,name): |
"""credit id to credititem""" |
"""credit id to credititem""" |
Line 615 class ECHO_collection(Folder, Persistent
|
Line 1947 class ECHO_collection(Folder, Persistent
|
return ret |
return ret |
|
|
security.declarePublic('ECHO_rerenderLinksMD') |
security.declarePublic('ECHO_rerenderLinksMD') |
def ECHO_rerenderLinksMD(self): |
|
|
def ECHO_rerenderLinksMD(self,obj=None,types=['title','label']): |
"""Rerender all Links""" |
"""Rerender all Links""" |
|
ret="" |
|
|
for entry in self.__dict__.keys(): |
if not obj: |
object=getattr(self,entry) |
obj = self |
|
|
|
entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection']) |
|
|
|
for entry in entries: |
|
if entry[1].meta_type == 'ECHO_resource': |
try: |
try: |
|
entry[1].ECHO_getResourceMD(template="no") |
|
if "title" in types: |
|
entry[1].generate_title() |
|
if "label" in types: |
|
entry[1].generate_label() |
|
ret+="OK:"+entry[0]+"-- "+entry[1].getTitle().decode('utf-8')+"-- "+entry[1].getTitle().decode('utf-8')+"<br>" |
|
except: |
|
ret+="Error:"+entry[0]+"<br>" |
|
|
if object.meta_type == 'ECHO_resource': |
else: |
|
self.ECHO_rerenderLinksMD(entry[1]) |
|
|
object.ECHO_getResourceMD(template="no") |
|
|
|
except: |
|
"""nothing""" |
|
|
|
return "Rerenderd all links to resources in: "+self.title |
return ret+"Rerenderd all links to resources in: "+self.title |
|
|
security.declarePublic('ECHO_newViewerLink') |
security.declarePublic('ECHO_newViewerLink') |
|
|
Line 647 class ECHO_collection(Folder, Persistent
|
Line 1990 class ECHO_collection(Folder, Persistent
|
return [] |
return [] |
|
|
def __init__(self,id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle,secondaryLink,imageTag="",bgcolour=""): |
def __init__(self,id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle,secondaryLink,imageTag="",bgcolour=""): |
#print "CO",coords |
|
|
|
self.id = id |
self.id = id |
"""Festlegen der ID""" |
"""Festlegen der ID""" |
Line 669 class ECHO_collection(Folder, Persistent
|
Line 2012 class ECHO_collection(Folder, Persistent
|
|
|
manage_options = Folder.manage_options+( |
manage_options = Folder.manage_options+( |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Main Config','action':'ECHO_collection_config'}, |
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
{'label':'Change Labels','action':'changeLabels'}, |
|
{'label':'Change Titles','action':'changeTitles'}, |
|
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMD'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
|
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'}, |
|
{'label':'Change Viewer Templates','action':'changeViewerTemplateSetsForm'}, |
|
{'label':'Reload Metadata','action':'reloadMetaDataFromStorage'}, |
|
{'label':'ImportCollection','action':'updateCollection'}, |
|
{'label':'Copy MD for indexing and search','action':'copySearchFields'}, |
) |
) |
|
|
def getOverview(self): |
def getOverview(self): |
Line 730 class ECHO_collection(Folder, Persistent
|
Line 2079 class ECHO_collection(Folder, Persistent
|
else: |
else: |
return "#dddddd" |
return "#dddddd" |
|
|
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour=""): |
def changeECHO_collection(self,title,label,description,contentType,responsible,weight,secondaryLink,secondaryLinkTitle,credits=None,sortfield="weight",coords=None,RESPONSE=None,imageTag="",bgcolour="",viewClassification=None,location=None): |
"""Änderung der Properties""" |
"""Aenderung der Properties""" |
|
|
self.secondaryLink=secondaryLink |
self.secondaryLink=secondaryLink |
self.secondaryLinkTitle=secondaryLinkTitle |
self.secondaryLinkTitle=secondaryLinkTitle |
self.imageTag=imageTag |
self.imageTag=imageTag |
self.bgcolour=bgcolour |
self.bgcolour=bgcolour |
|
self.viewClassification=viewClassification |
|
self.location=location |
|
|
if coords: |
if coords: |
coordsnew=[ string.split(x,",") for x in coords] |
coordsnew=[ string.split(x,",") for x in coords] |
Line 746 class ECHO_collection(Folder, Persistent
|
Line 2097 class ECHO_collection(Folder, Persistent
|
self.coords=None |
self.coords=None |
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) |
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) |
|
try: |
|
self.coords=coordsnew[0:] # HACK fehler in setECHO_collection |
|
except: |
|
"""none""" |
|
|
self.sortfield=sortfield |
self.sortfield=sortfield |
|
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
security.declarePublic('index_html') |
|
|
|
|
|
def showOverview(self): |
def showOverview(self): |
"""overview""" |
"""overview""" |
Line 764 class ECHO_collection(Folder, Persistent
|
Line 2115 class ECHO_collection(Folder, Persistent
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_overview.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_overview.zpt').__of__(self) |
return pt() |
return pt() |
|
|
|
security.declareProtected('View','index_html') |
|
|
def index_html(self): |
def index_html(self): |
"""standard page""" |
"""standard page""" |
Line 775 class ECHO_collection(Folder, Persistent
|
Line 2127 class ECHO_collection(Folder, Persistent
|
return self.showOverview() |
return self.showOverview() |
elif hasattr(self,'collection_index_template'): |
elif hasattr(self,'collection_index_template'): |
return self.collection_index_template() |
return self.collection_index_template() |
|
elif hasattr(self,'main_index_template'): |
|
return self.main_index_template() |
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_content_standard.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
pt.content_type="text/html" |
pt.content_type="text/html" |
return pt() |
return pt() |
|
|
Line 791 class ECHO_collection(Folder, Persistent
|
Line 2145 class ECHO_collection(Folder, Persistent
|
else: |
else: |
return [] |
return [] |
|
|
|
def area_img(self): |
|
"""area image""" |
|
bt = BrowserCheck(self) |
|
if bt.isIE or bt.isN4: |
|
return sendFile(self, 'images/red.gif', 'image/gif') |
|
else: |
|
return sendFile(self, 'images/reda.png', 'image/png') |
|
|
|
def trans_img(self): |
|
"""empty image""" |
|
return sendFile(self, 'images/trans.gif', 'image/gif') |
|
|
|
def hl_lib_js(self): |
|
"""javascript""" |
|
return sendFile(self, 'js/hl_lib.js', 'text/plain') |
|
|
|
def js_lib_js(self): |
|
"""javascript""" |
|
return sendFile(self, 'js/js_lib.js', 'text/plain') |
|
|
def getGraphicCoords(self): |
def getGraphicCoords(self): |
"""Give list of coordinates""" |
"""Give list of coordinates""" |
subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] |
subColTypes=['ECHO_collection','ECHO_resource'] |
ids=[] |
ids=[] |
for entry in self.__dict__.keys(): |
for entrySearch in self.ZopeFind(self,obj_metatypes=subColTypes): |
object=getattr(self,entry) |
object=entrySearch[1] |
try: |
if hasattr(object,'coords'): |
if object.meta_type in subColTypes: |
|
for coordtemp in object.coords: |
for coordtemp in object.coords: |
if len(coordtemp)>3: |
if len(coordtemp)>3: |
coord=coordtemp[0:4] |
coord=coordtemp[0:4] |
|
label="" |
|
vc="" |
if hasattr(object,'label') and not object.label=="": |
if hasattr(object,'label') and not object.label=="": |
ids.append([string.join(coord,", "),object.getId(),object.label,object]) |
label=object.label |
elif hasattr(object,'title'): |
elif hasattr(object,'title') and not object.title=="": |
if not object.title=="": |
label=object.title |
ids.append([string.join(coord,", "),object.getId(),object.title,object]) |
else: |
|
label=object.getId() |
|
if object.viewClassification != "": |
|
vc=object.viewClassification |
else: |
else: |
ids.append([string.join(coord,", "),object.getId(),object.getId(),object]) |
if len(coordtemp) > 4 and coordtemp[4] != "": |
|
vc="view point" |
else: |
else: |
ids.append([string.join(coord,", "),object.getId(),object.getId(),object]) |
vc="area" |
|
ids.append([string.join(coord,", "),object.getId(),label,object,coordtemp,vc]) |
except: |
|
"""nothing""" |
|
|
|
return ids |
return ids |
|
|
def getSubCols(self,sortfield="weight"): |
|
|
|
subColTypes=['ECHO_collection','ECHO_externalLink','ECHO_resource'] |
|
ids=[] |
|
for entry in self.__dict__.keys(): |
|
object=getattr(self,entry) |
|
try: |
|
if object.meta_type in subColTypes: |
|
ids.append(object) |
|
|
|
except: |
|
"""nothing""" |
|
try: |
|
sortfield=self.sortfield |
|
except: |
|
"""nothing""" |
|
|
|
tmplist=[] |
|
for x in ids: |
|
if hasattr(x,sortfield): |
|
try: |
|
x=int(x) |
|
except: |
|
"""nothing""" |
|
tmp=getattr(x,sortfield) |
|
else: |
|
tmp=10000000 |
|
tmplist.append((tmp,x)) |
|
tmplist.sort() |
|
return [x for (key,x) in tmplist] |
|
|
|
|
|
|
|
|
|
|
getSubCols = ECHO_helpers.getSubCols |
|
|
|
Globals.InitializeClass(ECHO_collection) |
|
|
def manage_addECHO_collectionForm(self): |
def manage_addECHO_collectionForm(self): |
"""Add collection form""" |
"""Add collection form""" |
Line 872 def manage_addECHO_collection(self,id,ti
|
Line 2217 def manage_addECHO_collection(self,id,ti
|
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
|
class ECHO_group(ECHO_collection): |
|
"""ECHO Gruppe""" |
|
security=ClassSecurityInfo() |
|
meta_type="ECHO_group" |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_group_config'}, |
|
{'label':'Rerender Links','action':'ECHO_rerenderLinksMD'}, |
|
{'label':'Graphics','action':'ECHO_graphicEntry'}, |
|
) |
|
|
|
security.declareProtected('View','index_html') |
|
|
|
def getRDF(self): |
|
"""rdf of the collection""" |
|
contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) |
|
about="""<RDF:Description about="%s">""" |
|
name="""<ECHONAVIGATION:name>%s</ECHONAVIGATION:name>""" |
|
|
|
|
|
|
|
link="""<ECHONAVIGATION:link>%s</ECHONAVIGATION:link>""" |
|
urn="urn:"+re.sub('/',':',self.absolute_url()) |
|
|
|
about2=about%urn |
|
name2=name%self.getId() |
|
link2=link%urllib.quote(self.absolute_url()) |
|
|
|
ret=about2+"\n"+name2+"\n"+link2+"\n"+"</RDF:Description>" |
|
|
|
|
|
|
|
|
|
urn="urn:"+re.sub('/',':',self.absolute_url()) |
|
li="""<RDF:li resource="%s" />\n""" |
|
|
|
|
|
for content in contents: |
|
ret+=content[1].getRDF()+"\n" |
|
|
|
ret+="""<RDF:Seq about="%s">\n"""%urn |
|
for content in contents: |
|
nurn="urn:"+re.sub('/',':',content[1].absolute_url()) |
|
ret+=li%nurn |
|
return ret+"</RDF:Seq>" |
|
|
|
def index_html(self): |
|
"""standard page""" |
|
displayedObjects=self.ZopeFind(self,obj_metatypes=displayTypes) |
|
#if (len(displayedObjects)==1) and (displayedObjects[0][1].meta_type=="ECHO_collection"): # nur ein Object dann redirect auf dieses Object |
|
# return self.REQUEST.RESPONSE.redirect(displayedObjects[0][1].absolute_url()) |
|
|
|
if 'index.html' in self.__dict__.keys(): |
|
return getattr(self,'index.html')() |
|
|
|
elif 'overview' in self.__dict__.keys(): |
|
return self.showOverview() |
|
elif hasattr(self,'group_index_template'): |
|
return self.group_index_template() |
|
elif hasattr(self,'collection_index_template'): |
|
return self.collection_index_template() |
|
elif hasattr(self,'main_index_template'): |
|
return self.main_index_template() |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ECHO_main_index_template_standard.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_group_config(self): |
|
"""Main configuration""" |
|
|
|
if not hasattr(self,'weight'): |
|
self.weight="" |
|
|
|
if not hasattr(self,'sortfield'): |
|
self.sortfield="weight" |
|
|
|
if not hasattr(self,'coords'): |
|
self.coords=[] |
|
|
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_group.zpt').__of__(self) |
|
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""" |
|
|
|
self.secondaryLink=secondaryLink |
|
self.secondaryLinkTitle=secondaryLinkTitle |
|
self.imageTag=imageTag |
|
self.bgcolour=bgcolour |
|
self.logo=logo |
|
|
|
if coords: |
|
coordsnew=[ string.split(x,",") for x in coords] |
|
self.coords=coordsnew[0:] |
|
else: |
|
coordsnew=None |
|
self.coords=None |
|
|
|
setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew) |
|
|
|
|
|
|
|
self.sortfield=sortfield |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def getLogo(self): |
|
"""logo ausgeben""" |
|
try: |
|
return self.logo |
|
except: |
|
return "ECHO_groups" |
|
|
|
def content_html(self): |
|
"""template fuer content""" |
|
return content_html(self,'group') |
|
|
|
|
|
|
|
def manage_addECHO_groupForm(self): |
|
"""Add group form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_groupForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
def manage_addECHO_group(self,id,title,label,description,contentType,responsible,weight,sortfield,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour="",logo=""): |
|
"""add a echo group""" |
|
|
|
|
|
newObj=ECHO_group(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") |
|
|
|
setattr(newObj,'logo',logo) |
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
Globals.InitializeClass(ECHO_group) |
|
|
|
|
|
class ECHO_userFolder(UserFolder): |
|
"""User folder for Intranet""" |
|
_domain_auth_mode=1 # Identification via domain |
|
meta_type="ECHO_userFolder" |
|
|
|
def authenticate(self, name, password, request): |
|
emergency = self._emergency_user |
|
if name is None: |
|
return None |
|
if emergency and name==emergency.getUserName(): |
|
user = emergency |
|
else: |
|
user = self.getUser(name) |
|
if user is not None and user.authenticate(password, request): |
|
return user |
|
else: |
|
return None |
|
|
|
def domainSpecMatch(self,spec, request): |
|
host='' |
|
addr='' |
|
|
|
# Fast exit for the match-all case |
|
if len(spec) == 1 and spec[0] == '*': |
|
return 1 |
|
|
|
if request.has_key('REMOTE_HOST'): |
|
host=request['REMOTE_HOST'] |
|
|
|
if request.has_key('REMOTE_ADDR'): |
|
addr=request['REMOTE_ADDR'] |
|
|
|
if request.has_key('HTTP_X_FORWARDED_FOR'): |
|
addr=request['HTTP_X_FORWARDED_FOR'] |
|
|
|
|
|
if not host and not addr: |
|
return 0 |
|
|
|
if not host: |
|
try: host=socket.gethostbyaddr(addr)[0] |
|
except: pass |
|
if not addr: |
|
try: addr=socket.gethostbyname(host) |
|
except: pass |
|
|
|
|
|
_host=host.split('.') |
|
_addr=addr.split('.') |
|
_hlen=len(_host) |
|
_alen=len(_addr) |
|
|
|
for ob in spec: |
|
sz=len(ob) |
|
_ob=ob.split('.') |
|
_sz=len(_ob) |
|
|
|
mo = addr_match(ob) |
|
if mo is not None: |
|
if mo.end(0)==sz: |
|
fail=0 |
|
for i in range(_sz): |
|
a=_addr[i] |
|
o=_ob[i] |
|
if (o != a) and (o != '*'): |
|
fail=1 |
|
break |
|
if fail: |
|
continue |
|
return 1 |
|
|
|
mo = host_match(ob) |
|
if mo is not None: |
|
if mo.end(0)==sz: |
|
if _hlen < _sz: |
|
continue |
|
elif _hlen > _sz: |
|
_item=_host[-_sz:] |
|
else: |
|
_item=_host |
|
fail=0 |
|
for i in range(_sz): |
|
h=_item[i] |
|
o=_ob[i] |
|
if (o != h) and (o != '*'): |
|
fail=1 |
|
break |
|
if fail: |
|
continue |
|
return 1 |
|
return 0 |
|
|
|
Globals.default__class_init__(ECHO_userFolder) |
|
|
|
|
|
|
|
def manage_addECHO_userFolder(self,dtself=None,REQUEST=None,**ignored): |
|
"""add a user folder """ |
|
f=ECHO_userFolder() |
|
self=self.this() |
|
try: self._setObject('acl_users', f) |
|
except: return MessageDialog( |
|
title ='Item Exists', |
|
message='This object already contains a User Folder', |
|
action ='%s/manage_main' % REQUEST['URL1']) |
|
self.__allow_groups__=f |
|
if REQUEST is not None: |
|
REQUEST['RESPONSE'].redirect(self.absolute_url()+'/manage_main') |
|
|
|
def manage_addECHO_userFolderForm(self): |
|
"""add a user folder form""" |
|
return manage_addECHO_userFolder(self) |
|
|
class ECHO_root(Folder,Persistent,Implicit): |
class ECHO_root(Folder,Persistent,Implicit): |
"""ECHO Root Folder""" |
"""ECHO Root Folder""" |
|
|
|
security=ClassSecurityInfo() |
|
|
meta_type="ECHO_root" |
meta_type="ECHO_root" |
|
|
|
def showRDF(self): |
|
"""showrdf""" |
|
self.REQUEST.RESPONSE.setHeader('Content-Type','text/xml') |
|
ret="""<RDF:RDF xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:ECHONAVIGATION="http://www.echo.eu/rdf#">\n""" |
|
ret+=self.getRDF()+"\n" |
|
ret+="""</RDF:RDF>""" |
|
return ret |
|
|
|
def getRDF(self): |
|
"""rdf of the collection""" |
|
contents=self.ZopeFind(self,obj_metatypes=['ECHO_group','ECHO_resource','ECHO_collection']) |
|
|
|
about="""<RDF:Description about="%s">""" |
|
name="""<ECHONAVIGATION:name>%s</ECHONAVIGATION:name>""" |
|
|
|
urn="urn:"+re.sub('/',':',self.absolute_url()) |
|
|
|
about2=about%urn |
|
name2=name%self.getId() |
|
|
|
|
|
ret=about2+"\n"+name2+"\n"+"</RDF:Description>" |
|
|
|
li="""<RDF:li resource="%s" />\n""" |
|
|
|
|
|
for content in contents: |
|
ret+=content[1].getRDF()+"\n" |
|
|
|
ret+="""<RDF:Seq about="%s">\n"""%urn |
|
for content in contents: |
|
nurn="urn:"+re.sub('/',':',content[1].absolute_url()) |
|
ret+=li%nurn |
|
return ret+"</RDF:Seq>" |
|
|
|
|
|
def showContent(self,path): |
|
"""return content/html""" |
|
|
|
return urllib.urlopen(path+"/content_html").read() |
|
|
|
def getImageViewers(self): |
|
"""images""" |
|
viewers=self.ZopeFind(self.standardImageViewer,obj_metatypes=['OSAS_ViewerObject']) |
|
return viewers |
|
|
|
|
|
def getBibTag(self,tag,content): |
|
"""get field tag für index-meta-generation""" |
|
if not content or content=="": |
|
return "" |
|
ret="<%s>"%tag |
|
#ret+=urllib.quote(content) |
|
ret+=content |
|
|
|
ret+="</%s>"%tag |
|
return ret |
|
|
|
def getValueFromClass(self,field,found): |
|
"""retattribute falss existing""" |
|
try: |
|
|
|
return getattr(found,field).decode('ascii','ignore') |
|
except: |
|
return "" |
|
|
|
def getImageTag(self): |
|
"""needed by main_template""" |
|
return "" |
|
secondaryLink="" #needed by main_template |
|
secondaryLinkTitle="" #needed by main_template |
|
|
def getBgcolour(self): |
def getBgcolour(self): |
"""hack""" |
"""hack""" |
return "#dddddd" |
return "#dddddd" |
Line 887 class ECHO_root(Folder,Persistent,Implic
|
Line 2562 class ECHO_root(Folder,Persistent,Implic
|
else: |
else: |
retStr="<option>\n" |
retStr="<option>\n" |
|
|
|
try: # erste version contentTypes exists |
|
for contentType in self.ZopeFind(self.contentTypes,obj_metatypes=["ECHO_contentType","OSAS_MetadataMapping"]): |
|
if selected and (contentType[0]==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0]) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0]) |
|
except: |
try: |
try: |
for contentType in self.ZopeFind(self.contentTypes,obj_metatypes="ECHO_contentType"): |
for contentType in self.ZopeFind(self.standardMD,obj_metatypes=["OSAS_MetadataMapping"]): |
if selected and (contentType[0]==selected): |
if selected and (contentType[0]==selected): |
retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0]) |
retStr+="""<option selected value="%s">%s\n"""%(contentType[0],contentType[0]) |
else: |
else: |
retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0]) |
retStr+="""<option value="%s">%s\n"""%(contentType[0],contentType[0]) |
except: |
except: |
"""nothing""" |
"""nothing""" |
|
|
|
return retStr |
|
|
|
def renderingTypeSelector_HTML(self,selected=None): |
|
"""give type selector""" |
|
if not selected: |
|
retStr="<option selected>\n" |
|
else: |
|
retStr="<option>\n" |
|
|
|
try: # erste version renderingTypes exists |
|
for renderingType in self.ZopeFind(self.renderingTypes,obj_metatypes=["ECHO_renderingType"]): |
|
if selected and (renderingType[0]==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(renderingType[0],renderingType[0]) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(renderingType[0],renderingType[0]) |
|
except: |
|
"""nothing""" |
|
return retStr |
|
|
|
def renderingTypeSelector_HTML(self,selected=None): |
|
"""give type selector""" |
|
if not selected: |
|
retStr="<option selected>\n" |
|
else: |
|
retStr="<option>\n" |
|
|
|
try: # erste version renderingTypes exists |
|
for renderingType in self.ZopeFind(self.renderingTypes,obj_metatypes=["ECHO_renderingType"]): |
|
if selected and (renderingType[0]==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(renderingType[0],renderingType[0]) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(renderingType[0],renderingType[0]) |
|
except: |
|
"""nothing""" |
|
return retStr |
|
|
|
|
|
def copyrightTypeSelector_HTML(self,selected=None,first=None): |
|
"""give type selector""" |
|
|
|
if not first: |
|
if not selected: |
|
retStr="<option selected>\n" |
|
else: |
|
retStr="<option>\n" |
|
else: |
|
if not selected: |
|
retStr="""<option selected value="%s">%s\n"""%first |
|
else: |
|
retStr="""<option value="%s">%s\n"""%first |
|
|
|
|
|
try: # erste version copyrightTypes exists |
|
for copyrightType in self.ZopeFind(self.copyrightTypes,obj_metatypes=["ECHO_copyrightType"]): |
|
if selected and (copyrightType[0]==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
|
except: |
|
"""nothing""" |
|
return retStr |
|
|
|
def partnerSelector_HTML(self,selected=None): |
|
"""give type selector""" |
|
if not selected: |
|
retStr="<option selected>\n" |
|
else: |
|
retStr="<option>\n" |
|
|
|
try: # erste version copyrightTypes exists |
|
for copyrightType in self.ZopeFind(self.partners,obj_metatypes=["ECHO_partner"]): |
|
if selected and (copyrightType[0]==selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(copyrightType[0],copyrightType[0]) |
|
except: |
|
"""nothing""" |
|
return retStr |
|
|
|
mediaTypes=['all','text','images','sound','video'] # konfigurierbar in neuer version über echoroot?? |
|
|
|
def mediaTypeSelector_HTML(self,selected=None): |
|
"""give type selector""" |
|
if not selected: |
|
retStr="<option selected>\n" |
|
else: |
|
retStr="<option>\n" |
|
|
|
try: # erste version mediatypesTypes exists |
|
for mediaType in self.mediaTypes: |
|
if selected and (mediaType in selected): |
|
retStr+="""<option selected value="%s">%s\n"""%(mediaType,mediaType) |
|
else: |
|
retStr+="""<option value="%s">%s\n"""%(mediaType,mediaType) |
|
except: |
|
"""nothing""" |
return retStr |
return retStr |
|
|
|
|
def patchContentType(self,obj=None): |
def patchContentType(self,obj=None): |
"""austauschen content_type with contentType (patch bei umstieg von alter Version)""" |
"""austauschen content_type with contentType (patch bei umstieg von alter Version)""" |
|
|
Line 914 class ECHO_root(Folder,Persistent,Implic
|
Line 2694 class ECHO_root(Folder,Persistent,Implic
|
entry[1].patchContentType(entry[1]) |
entry[1].patchContentType(entry[1]) |
|
|
|
|
return "Rerenderd all links to resources in: "+self.title |
return "changed all contenttypes in: "+self.title |
|
|
|
|
|
def patchViewClassification(self,obj=None): |
|
"""setze viewClassification heuristisch""" |
|
|
|
def checkIfArrow(obj): |
|
if hasattr(obj,'coords'): |
|
for coordtemp in obj.coords: |
|
|
|
if (len(coordtemp)>4) and not (coordtemp[4]==''): |
|
return 4 |
|
return None |
|
return None |
|
|
|
if not obj: |
|
obj = self |
|
|
|
entries=obj.ZopeFind(obj,obj_metatypes=['ECHO_resource','ECHO_collection','ECHO_group']) |
|
|
|
for entry in entries: |
|
|
|
if checkIfArrow(entry[1]): |
|
setattr(entry[1],'viewClassification','view point') |
|
else: |
|
setattr(entry[1],'viewClassification','area') |
|
|
|
#entry[1].contentType == entry[1].content_type |
|
|
|
if entry[1].meta_type in ['ECHO_collection','ECHO_group']: |
|
entry[1].patchViewClassification(entry[1]) |
|
|
|
|
|
return "changed all contenttypes in: "+self.title |
|
|
def ECHO_newViewerLink(self,obj=None): |
def ECHO_newViewerLink(self,obj=None): |
"""change links (:86 faellt weg)""" |
"""change links (:86 faellt weg)""" |
Line 962 class ECHO_root(Folder,Persistent,Implic
|
Line 2775 class ECHO_root(Folder,Persistent,Implic
|
|
|
for word in words: |
for word in words: |
strUrl=url%word |
strUrl=url%word |
print "str",strUrl |
|
retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word) |
retStr+="""<a href="%s">%s</a><br/>"""%(strUrl,word) |
str=retStr |
str=retStr |
if str: |
if str: |
Line 973 class ECHO_root(Folder,Persistent,Implic
|
Line 2786 class ECHO_root(Folder,Persistent,Implic
|
def link2html(self,str): |
def link2html(self,str): |
"""link2html fuer VLP muss hier noch raus""" |
"""link2html fuer VLP muss hier noch raus""" |
if str: |
if str: |
print str |
|
str=re.sub("\&","&",str) |
str=re.sub("\&","&",str) |
dom=xml.dom.minidom.parseString("<?xml version='1.0' ?><txt>"+str+"</txt>") |
dom=xml.dom.minidom.parseString("<?xml version='1.0' encoding='utf-8'?><txt>"+str+"</txt>") |
links=dom.getElementsByTagName("link") |
links=dom.getElementsByTagName("link") |
|
|
print "link",links |
|
for link in links: |
for link in links: |
link.tagName="a" |
link.tagName="a" |
ref=link.getAttribute("ref") |
ref=link.getAttribute("ref") |
if self.checkRef(ref): |
if self.checkRef(ref): |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
|
|
return dom.toxml('utf-8') |
newxml=dom.toxml('utf-8') |
|
match=re.sub(r'<\?xml version=\"1.0\" encoding=\"utf-8\"\?>\n<txt>','',newxml) |
|
match=re.sub(r'</txt>','',match) |
|
|
|
return match |
|
|
return "" |
return "" |
|
|
|
def xml2html(self,str): |
|
"""link2html fuer VLP muss hier noch raus""" |
|
if str: |
|
|
|
str=re.sub("\&","&",str) |
|
dom=xml.dom.minidom.parseString(str) |
|
links=dom.getElementsByTagName("link") |
|
|
|
|
|
for link in links: |
|
link.tagName="a" |
|
ref=link.getAttribute("ref") |
|
if self.checkRef(ref): |
|
link.setAttribute("href",self.aq_parent.absolute_url()+"/vlp_coll?id="+ref) |
|
|
|
return dom.toxml('utf-8') |
|
return "" |
|
|
def checkRef(self,ref): |
def checkRef(self,ref): |
dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''} |
dbs={'vl_literature':'AND CD LIKE \'%lise%\'','vl_technology':'','vl_people':''} |
res=None |
res=None |
for db in dbs.keys(): |
for db in dbs.keys(): |
#print ref,"select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]) |
|
|
|
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
res=res or self.search(var=str("select reference from %s where reference =\'%s\' %s"%(db,ref,dbs[db]))) |
return res |
return res |
Line 1002 class ECHO_root(Folder,Persistent,Implic
|
Line 2836 class ECHO_root(Folder,Persistent,Implic
|
|
|
def PgQuoteString(self,string): |
def PgQuoteString(self,string): |
"""Quote string""" |
"""Quote string""" |
#print "PG",string |
|
return libpq.PgQuoteString(string) |
return libpq.PgQuoteString(string) |
|
|
def getPartners(self): |
def getPartners(self): |
Line 1017 class ECHO_root(Folder,Persistent,Implic
|
Line 2851 class ECHO_root(Folder,Persistent,Implic
|
def getPartnersXML(self): |
def getPartnersXML(self): |
"""partner liste als xml""" |
"""partner liste als xml""" |
partners=self.getPartners() |
partners=self.getPartners() |
ret="<partners>" |
ret="""<?xml version="1.0" encoding="utf-8" ?> |
|
<partners>""" |
|
|
for partner in partners: |
for partner in partners: |
ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),partner.title) |
ret+="""<partner id="%s" title="%s"/>\n"""%(partner.getId(),unicode(partner.title,'utf-8','replace')) |
|
|
return ret+"\n</partners>" |
return ret+"\n</partners>" |
|
|
Line 1049 class ECHO_root(Folder,Persistent,Implic
|
Line 2885 class ECHO_root(Folder,Persistent,Implic
|
ret.append((collection[0].getId(),collection[1].getId(),collection[2])) |
ret.append((collection[0].getId(),collection[1].getId(),collection[2])) |
return ret |
return ret |
|
|
|
def getResourcesHTML(self,viewerType=None,filter=None): |
|
"""gebe all ressourcen aus""" |
|
|
|
def sortHTML(x,y): |
|
return cmp(x[1].title,y[1].title) |
|
|
|
ret="""<html><body><h2>Resources in ECHO</h3>""" |
|
|
|
resources = self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1) |
|
ret+="""<h3>Found %i resources</h3>"""%len(resources) |
|
resources.sort(sortHTML) |
|
for resource in resources: |
|
echo_url=resource[1].absolute_url() |
|
|
|
if hasattr(resource[1],'title'): |
|
title=resource[1].title |
|
else: |
|
title="None" |
|
if filter: |
|
if re.search(filter,title): |
|
ret+="""\n<p><a href="%s">%s</a></p>"""%(echo_url,title) |
|
else: |
|
ret+="""\n<p><a href="%s">%s</a></p>"""%(echo_url,title) |
|
|
|
ret +="""\n</body></html>""" |
|
|
|
#self.REQUEST.RESPONSE.setHeader("Content-Type", "text/html") |
|
#self.REQUEST.RESPONSE.write(ret) |
|
return ret |
|
|
|
def getResourcesXML(self,viewerType=None,filter=None): |
|
"""gebe all ressourcen aus""" |
|
ret="""<?xml version="1.0" ?> |
|
<index>""" |
|
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
|
|
|
echo_url=resource[1].absolute_url() |
|
if hasattr(resource[1],'link'): |
|
viewer_url=resource[1].link |
|
else: |
|
viewer_url="NO URL" |
|
if filter: |
|
if re.search(filter,viewer_url): |
|
ret+="""\n<resource echoLink="%s" viewerLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(viewer_url,safe='/:?')) |
|
else: |
|
ret+="""\n<resource echoLink="%s" viewerLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(viewer_url,safe='/:?')) |
|
ret +="""\n</index>""" |
|
|
|
self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml") |
|
self.REQUEST.RESPONSE.write(ret) |
|
|
|
def getFullTextsXML(self,viewerType=None,filter=None): |
|
"""gebe all ressourcen aus""" |
|
ret="""<?xml version="1.0" ?> |
|
<index>""" |
|
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
|
|
|
echo_url=resource[1].absolute_url() |
|
if resource[1].getFullTextXML(noredirect="yes"): |
|
if hasattr(resource[1],'link'): |
|
viewer_url=echo_url+"/getFullTextXML" |
|
else: |
|
viewer_url="NO URL" |
|
if filter: |
|
if re.search(filter,viewer_url): |
|
ret+="""\n<resource echoLink="%s" viewerLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(viewer_url,safe='/:?')) |
|
else: |
|
ret+="""\n<resource echoLink="%s" viewerLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(viewer_url,safe='/:?')) |
|
ret +="""\n</index>""" |
|
|
|
|
|
self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml") |
|
self.REQUEST.RESPONSE.write(ret) |
|
|
|
|
|
def getMetaDatasXML(self,viewerType=None,filter=None): |
|
"""gebe all ressourcen aus""" |
|
ret="""<?xml version="1.0" ?> |
|
<index>""" |
|
for resource in self.ZopeFind(self,obj_metatypes=['ECHO_resource'],search_sub=1): |
|
|
|
echo_url=resource[1].absolute_url() |
|
|
|
if hasattr(resource[1],'link'): |
|
meta_url=echo_url+"/getMetaDataXML" |
|
else: |
|
meta_url="NO_URL" |
|
|
|
if filter and not re.search(filter,viewer_url): |
|
continue |
|
|
|
ret+="""\n<resource resourceLink="%s" metaLink="%s"/>"""%(urllib.quote(echo_url,safe='/:?'),urllib.quote(meta_url,safe='/:?')) |
|
|
|
ret +="""\n</index>""" |
|
|
|
|
|
self.REQUEST.RESPONSE.setHeader("Content-Type", "text/xml") |
|
self.REQUEST.RESPONSE.write(ret) |
|
|
|
|
|
def findPartners(self): |
|
"""find all partners in partners""" |
|
par=self.ZopeFind(self.partners, obj_metatypes='ECHO_partner') |
|
return par |
|
|
|
def getPartnerFromID(self): |
|
"""find partner form ID return object""" |
|
pa=self.REQUEST['partner'] |
|
par=self.ZopeFind(self.partners, obj_ids=[pa]) |
|
return par |
|
|
|
def getPartnerFromIDParameter(self, id): |
|
""" find partners from ID""" |
|
par=self.ZopeFind(self.partners, obj_ids=[id]) |
|
return par |
|
|
|
|
|
|
def manage_addECHO_root(self,id,title,RESPONSE=None): |
def manage_addECHO_root(self,id,title,RESPONSE=None): |
Line 1063 def manage_addECHO_rootForm(self):
|
Line 3015 def manage_addECHO_rootForm(self):
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_root.zpt').__of__(self) |
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_root.zpt').__of__(self) |
return pt() |
return pt() |
|
|
|
class ECHO_copyrightType(Folder): |
|
"""copyright typ""" |
|
|
|
meta_type="ECHO_copyrightType" |
|
|
|
def __init__(self,id,title,label,url): |
|
"""init""" |
|
self.id=id |
|
self.title=title |
|
self.label=label |
|
self.url=url |
|
|
|
manage_options = Folder.manage_options+( |
|
{'label':'Main Config','action':'ECHO_copyrightType_config_mainForm'}, |
|
) |
|
|
|
def ECHO_copyrightType_config_mainForm(self): |
|
"""change form""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/ChangeECHO_copyrightType').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
def ECHO_copyrightType_config_main(self,title,label,url,RESPONSE=None): |
|
"""change""" |
|
self.title=title |
|
self.label=label |
|
self.url=url |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def manage_addECHO_copyrightTypeForm(self): |
|
"""Form for adding a ressource""" |
|
pt=PageTemplateFile('Products/ECHO_content/zpt/AddECHO_copyrightTypeForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
def manage_addECHO_copyrightType(self,id,title,label,url,RESPONSE=None): |
|
"""addaresource""" |
|
|
|
newObj=ECHO_copyrightType(id,title,label,url) |
|
|
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
class ECHO_partner(Image,Persistent): |
class ECHO_partner(Image,Persistent): |
"""ECHO Partner""" |
"""ECHO Partner""" |
|
|
meta_type="ECHO_partner" |
meta_type="ECHO_partner" |
|
|
def __init__(self, id, title,url, file, content_type='', precondition=''): |
def __init__(self, id, title,url, file, copyrightType, person, email, country, color, content_type='', precondition=''): |
self.__name__=id |
self.__name__=id |
self.title=title |
self.title=title |
self.url=url |
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.color=color |
self.precondition=precondition |
self.precondition=precondition |
|
self.copyrightType=copyrightType |
data, size = self._read_data(file) |
data, size = self._read_data(file) |
content_type=self._get_content_type(file, data, id, content_type) |
content_type=self._get_content_type(file, data, id, content_type) |
self.update_data(data, content_type, size) |
self.update_data(data, content_type, size) |
Line 1082 class ECHO_partner(Image,Persistent):
|
Line 3087 class ECHO_partner(Image,Persistent):
|
{'label':'Partner Information','action':'ECHO_partner_config'}, |
{'label':'Partner Information','action':'ECHO_partner_config'}, |
) |
) |
|
|
def changeECHO_partner(self,url,RESPONSE=None): |
|
|
def changeECHO_partner(self,url,copyrightType,person, email, country, color, RESPONSE=None): |
"""Change main information""" |
"""Change main information""" |
self.url=url |
self.url=url |
|
self.person=person |
|
self.email=email |
|
self.country=country |
|
self.color=color |
|
self.copyrightType=copyrightType |
if RESPONSE is not None: |
if RESPONSE is not None: |
RESPONSE.redirect('manage_main') |
RESPONSE.redirect('manage_main') |
|
|
Line 1103 manage_addECHO_partnerForm=DTMLFile('dtm
|
Line 3114 manage_addECHO_partnerForm=DTMLFile('dtm
|
|
|
|
|
|
|
def manage_addECHO_partner(self, id, file,url, title='', precondition='', content_type='', |
def manage_addECHO_partner(self, id, url, person, email, country, color, file=None, copyrightType='', title='', precondition='', content_type='', |
REQUEST=None): |
REQUEST=None): |
""" |
""" |
Add a new ECHO_partner object. |
Add a new ECHO_partner object. |
Line 1122 def manage_addECHO_partner(self, id, fil
|
Line 3133 def manage_addECHO_partner(self, id, fil
|
self=self.this() |
self=self.this() |
|
|
# First, we create the image without data: |
# First, we create the image without data: |
self._setObject(id, ECHO_partner(id,title,url,'',content_type, precondition)) |
self._setObject(id, ECHO_partner(id,title,url,'',copyrightType, person, email, country, color, content_type, precondition)) |
|
|
# Now we "upload" the data. By doing this in two steps, we |
# Now we "upload" the data. By doing this in two steps, we |
# can use a database trick to make the upload more efficient. |
# can use a database trick to make the upload more efficient. |