version 1.5, 2004/06/04 10:04:16
|
version 1.94.2.1, 2011/10/13 07:48:27
|
Line 1
|
Line 1
|
from ECHO_collection import * |
""" |
from Products.PageTemplates.PageTemplateFile import PageTemplateFile |
DEPRICATED: USED NOW VLPExtension in the Product VLP_extensions |
from Products.PageTemplates.PageTemplate import PageTemplate |
This module contains extensions which where originally made for the VLP. |
from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate |
definiton here are only for compatibility reasons. |
|
""" |
from Products.zogiLib import zogiLib |
#from Products.VLP_extensions.vlp_xmlhelpers import * |
|
#import Products.VLP_extensions |
def getText(nodelist): |
|
|
|
rc = "" |
|
for node in nodelist: |
|
if node.nodeType == node.TEXT_NODE: |
|
rc = rc + node.data |
|
return rc |
|
|
|
class VLP_collection(ECHO_collection): |
|
"""VLP spezifische Erweiterung der Collection""" |
|
|
|
meta_type="VLP_collection" |
|
manage_options=ECHO_collection.manage_options+( |
|
{'label':'Change Path','action':'VLP_path_configForm'}, |
|
{'label':'Update Library','action':'updateCollection'}, |
|
{'label':'Update Metadata','action':'updateCollectionMD'}, |
|
) |
|
|
|
def VLP_path_configForm(self): |
|
"""change pt""" |
|
path=PageTemplateFile('Products/ECHO_content/vlp/ChangeVLPPath.zpt').__of__(self) |
|
return pt() |
|
|
|
def VLP_path_config(self,path,RESPONSE=None): |
|
"""config""" |
|
self.path=path |
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
def updateCollection(self,RESPONSE=None): |
|
"""liest verzeichnisse aus dem pfad und legt sie dann als objekte in den ordner""" |
|
files=os.listdir(self.path) |
|
for fileName in files: |
|
|
|
if fileName[0:3]=="lit": |
|
|
|
metalink=self.REQUEST['URL1']+"/"+fileName+"/index_meta" |
|
newObj=VLP_resource(fileName,'',metalink,fileName,fileName,fileName,'generated','book','','','','','','') |
|
self._setObject(fileName,newObj) |
|
|
|
genObj=getattr(self,fileName) |
|
genObj.createIndexFile() |
|
|
|
|
|
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[0:3]=="lit": |
|
genObj=getattr(self,fileName) |
|
genObj.copyIndex_meta2echo_resource() |
|
genObj.generate_title() |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addVLP_collectionForm(self): |
|
"""Form for adding a ressource""" |
|
pt=PageTemplateFile('Products/ECHO_content/vlp/AddVLP_collectionForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
|
|
def manage_addVLP_collection(self,id,title,label,description,contentType,responsible,weight,sortfield,path,coords="",secondaryLinkTitle="",secondaryLink="",credits=None,RESPONSE=None,imageTag="",bgcolour=""): |
|
"""add a echo collection""" |
|
|
|
|
|
newObj=VLP_collection(id,title,label,description,contentType,responsible,credits,weight,sortfield,coords,secondaryLinkTitle=secondaryLinkTitle,secondaryLink=secondaryLink,imageTag=imageTag,bgcolour="") |
|
|
|
self._setObject(id,newObj) |
|
setattr(newObj,'path',path) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
|
|
class VLP_resource(ECHO_resource): |
|
"""VLP spezifische Erweiterung""" |
|
|
|
meta_type="VLP_resource" |
|
|
|
vlp_basis="/mpiwg/online/permanent/vlp" |
|
|
|
|
|
referencetypes=[] |
|
|
|
manage_options=ECHO_resource.manage_options+( |
|
{'label':'Update Index','action':'createIndexFile'}, |
|
{'label':'Reset MetaLink','action':'resetMetaLink'}, |
|
{'label':'Generate Title','action':'generate_title'}, |
|
) |
|
|
|
|
|
def printDict(self): |
|
"""dict""" |
|
return self.__dict__ |
|
|
|
## def __init__(self,id,link,metalink,resourceID,title,label,description,contentType,renderingType,responsible,credits,weight,coords): |
|
## """angepasstes init""" |
|
|
|
|
|
## return ECHO_resource(id,link,metalink,resourceID,title,label,description,contentType,renderingType,responsible,credits,weight,coords) |
|
|
|
|
|
def resetMetaLink(self,all="no",RESPONSE=None): |
|
"""resets metalink to standard resp. in case of server change it sets to the new server url""" |
|
if all=="yes": |
|
self.metalink=self.absolute_url()+"/index_meta" |
|
else: |
|
splitted=self.metalink.split("/") |
|
if (len(splitted)>1) and (splitted[len(splitted)-1]=="index_meta") and (splitted[len(splitted)-2]==self.getId()): # heuristic nur generische Metadatafiles andern |
|
self.metalink=self.absolute_url()+"/index_meta" |
|
|
|
if RESPONSE: |
|
return "done" |
|
|
|
def show(self): |
|
"""show the rendered file""" |
|
pt=PageTemplateFile('Products/ECHO_content/vlp/library_template.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
index_html=show |
|
|
|
def index_meta(self): |
|
"""index_meta""" |
|
pt=PageTemplateFile('Products/ECHO_content/vlp/index_meta.zpt').__of__(self) |
|
pt.content_type="text/html" |
|
return pt() |
|
|
|
|
|
def dir2index(self): |
|
"""dir to index""" |
|
|
|
def calculateName(str): |
|
ret="%s: %s"%(str[0],str[1:5]) |
|
return ret |
|
|
|
try: |
try: |
ret=os.listdir(os.path.join(self.vlp_basis,self.resourceID,'pageimg')) |
from Products.VLP_extensions.vlp_xmlhelpers import * |
self.imagePath='pageimg' |
import Products.VLP_extensions |
except: |
|
ret=os.listdir(os.path.join(self.vlp_basis,self.resourceID,'pagesHi')) |
|
self.imagePath='pagesHi' |
|
temp=[] |
|
for x in ret: |
|
if not (x[0]=="."): |
|
|
|
temp.append(calculateName(x)) |
|
return temp |
|
|
|
def firstPage(self,url=None): |
|
"""showlink to the first image""" |
|
if self.REQUEST.get('pn')=="1": #erste seinte dann kein a tag |
|
return """<img src="../../images/first.gif" alt="first" width="14" height="14" border="0"><br>first""" |
|
|
|
else: |
|
return """<a href=%s> |
|
<img src="../../images/first.gif" alt="first" width="14" height="14" border="0"><br>first |
|
</a> |
|
"""%(self.REQUEST['URL']+"?pn=1") |
|
|
|
def lastPage(self,url=None): |
|
"""showlink to the first image""" |
|
pages=self.readIndexFile(url) |
|
if pages: |
|
ln=len(pages) |
|
|
|
if self.REQUEST.get('pn')==str(ln): #letzte seite dann kein a tag |
|
return """<img src="../../images/last.gif" alt="last" width="14" height="14" border="0"><br>last""" |
|
|
|
else: |
|
return """<a href=%s> |
|
<img src="../../images/last.gif" alt="last" width="14" height="14" border="0"><br>last |
|
</a> |
|
"""%(self.REQUEST['URL']+"?pn="+str(ln)) |
|
|
|
def prevPage(self,url=None): |
|
"""showlink to the first image""" |
|
|
|
|
|
nn = int(self.REQUEST.get('pn','1'))-1 |
|
if nn < 1: #letzte seite dann kein a tag |
|
return """<img src="../../images/prev.gif" alt="prev" width="14" height="14" border="0"><br>prev""" |
|
|
|
else: |
|
return """<a href=%s> |
|
<img src="../../images/prev.gif" alt="prev" width="14" height="14" border="0"><br>prev |
|
</a> |
|
"""%(self.REQUEST['URL']+"?pn="+str(nn)) |
|
|
|
def nextPage(self,url=None): |
|
"""showlink to the first image""" |
|
pages=self.readIndexFile(url) |
|
if pages: |
|
ln=len(pages) |
|
|
|
nn = int(self.REQUEST.get('pn','1'))+1 |
class sendMailForm(Products.VLP_extensions.VLPExtension.sendMailForm): |
if nn>int(ln): #letzte seite dann kein a tag |
pass |
return """<img src="../../images/next.gif" alt="next" width="14" height="14" border="0"><br>next""" |
|
|
|
else: |
|
return """<a href=%s> |
|
<img src="../../images/next.gif" alt="next" width="14" height="14" border="0"><br>next |
|
</a> |
|
"""%(self.REQUEST['URL']+"?pn="+str(nn)) |
|
|
|
|
class VLP_collectionFolder(Products.VLP_extensions.VLPExtension.VLP_collectionFolder): |
|
pass |
|
|
def readIndexFile(self,url=None): |
class VLP_essay(Products.VLP_extensions.VLPExtension.VLP_essay): |
"""reads the indexfile. presently url not None isn't implemented. In the future url can be defined.""" |
pass |
pagelist=[] |
|
if not url: |
|
url=self.absolute_url()+"/index.xml" |
|
|
|
fh=urllib.urlopen(url) |
class VLP_encyclopaedia(Products.VLP_extensions.VLPExtension.VLP_encyclopaedia): |
dom=xml.dom.minidom.parse(fh) |
pass |
|
|
|
class VLP_subcollection(Products.VLP_extensions.VLPExtension.VLP_subcollection): |
|
pass |
|
class VLP_collection(Products.VLP_extensions.VLPExtension.VLP_collection): |
|
pass |
|
|
for page in dom.getElementsByTagName('page'): |
class VLP_resource(Products.VLP_extensions.VLPExtension.VLP_resource): |
text=getText(page.childNodes) |
pass |
pageNum=page.getAttribute('nr') |
|
pagelist.append((pageNum,text)) |
|
|
|
return pagelist |
except: |
|
print "NO VLP extensions" |
def createIndexFile(self,RESPONSE=None): |
|
"""create index file""" |
|
|
|
|
|
pt=PageTemplateFile('Products/ECHO_content/vlp/index_template.zpt').__of__(self)() |
|
|
|
|
|
|
|
if not hasattr(self,'index.xml'): |
|
zt=ZopePageTemplate('index.xml') |
|
self._setObject('index.xml',zt) |
|
else: |
|
zt=getattr(self,'index.xml') |
|
|
|
|
|
zt.pt_edit(pt, 'text/xml') |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|
|
|
def manage_addVLP_resourceForm(self): |
|
"""Form for adding a ressource""" |
|
pt=PageTemplateFile('Products/ECHO_content/vlp/AddVLP_resourceForm.zpt').__of__(self) |
|
return pt() |
|
|
|
|
|
|
|
def manage_addVLP_resource(self,id,title,label,description,responsible,link,metalink,weight,resourceID=None,contentType=None,renderingType=None,credits=None,coords=None,RESPONSE=None): |
|
"""addaresource""" |
|
|
|
|
|
if metalink=='': |
|
metalink=self.absolute_url()+"/"+id+"/index_meta" |
|
|
|
newObj=VLP_resource(id,link,metalink,resourceID,title,label,description,contentType,renderingType,responsible,credits,weight,coords) |
|
|
|
self._setObject(id,newObj) |
|
|
|
if RESPONSE is not None: |
|
RESPONSE.redirect('manage_main') |
|
|
|