--- ECHO_content/ECHO_collection.py 2004/12/02 12:01:08 1.195
+++ ECHO_content/ECHO_collection.py 2004/12/06 17:48:39 1.200
@@ -61,7 +61,6 @@ import xml.dom.minidom
import urllib
import xml.dom.minidom
-from ECHO_graphicalOverview import javaHandler,javaScriptMain
import ECHO_helpers
from ECHO_helpers import *
from ECHO_language import *
@@ -75,12 +74,10 @@ regexpPage = re.compile(patternPage, re.
-def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs,viewClassification=""):
+def setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordstrs="",viewClassification=""):
"""Allegemeine Informationen zu einer ECHO Collection"""
- self.viewClassification=viewClassification
-
self.label = label
self.title=title
self.description=description
@@ -89,22 +86,6 @@ def setECHO_collectionInformation(self,t
self.credits=toList(credits)
self.weight=weight
- coords=[]
- #coordinates of for rectangles
-
-
- if coordstrs:
- for coordstr in coordstrs:
-
- try:
- temco=coordstr.split(",")
- except:
- temco=[]
-
- coords.append(temco)
-
-
- self.coords=coords[0:]
class ECHO_copyright(Folder,ECHO_basis):
"""Copyright informationen"""
@@ -1027,14 +1008,7 @@ class ECHO_resource(Folder,Persistent,EC
def changeECHO_resource(self,metalink,link,title,label,description,contentType,responsible,weight,viewClassification="",coords=None,credits=None,RESPONSE=None):
"""Aenderung der Properties"""
- try:
- coordsnew=[ string.split(x,",") for x in coords]
- except:
- coordsnew=[]
-
- setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight,coordsnew)
- self.viewClassification=viewClassification
- self.coords=coordsnew[0:]
+ setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)
self.link=link
self.metalink=metalink
@@ -1045,39 +1019,13 @@ class ECHO_resource(Folder,Persistent,EC
manage_options = Folder.manage_options+(
{'label':'Main Config','action':'ECHO_resource_config_main'},
{'label':'Change Metadata','action':'ECHO_resource_config_metadata'},
- {'label':'Edit Coords','action':'ECHO_resource_config_coords'},
- {'label':'Change Coords','action':'ECHO_graphicEntry'},
+ {'label':'Graphic Coords','action':'ECHO_graphicEntry'},
{'label':'Sync Metadata','action':'ECHO_getResourceMD'},
{'label':'Change TemplateSets and Image Viewer','action':'changeViewerTemplateSetForm'},
{'label':'set/change startpage','action':'setStartPageForm'},
{'label':'Copy MD for indexing and search','action':'copySearchFields'},
)
- def getOverview(self):
- """overview graphics"""
- return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1]
-
- def ECHO_graphicEntry(self):
- """DO nothing"""
- overview = self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])
- if overview:
- pt=zptFile(self, 'zpt/ECHO_draw.zpt')
- return pt()
- else:
- return "NO OVERVIEW GRAPHICS"
-
- def ECHO_enterCoords(self,coordstr,angle="",RESPONSE=None):
- """Enter coords"""
- coords=self.coords
- temco=coordstr.split(",")
- temco.append(angle)
- coords.append(temco)
-
- self.coords=coords[0:]
-
- if RESPONSE is not None:
- RESPONSE.redirect('ECHO_graphicEntry')
-
def isDefinedInThisSet(self,fields,field):
"""checks if field is defined in fields"""
@@ -1297,7 +1245,7 @@ class ECHO_resource(Folder,Persistent,EC
pdf=self.checkRDF(self.link)
if pdf:
fh=file(pdf,'r').read()
- self.REQUEST.RESPONSE.setHeader('Content-Type','x-Application/pdf')
+ self.REQUEST.RESPONSE.setHeader('Content-Type','application/pdf')
self.REQUEST.RESPONSE.write(fh)
self.REQUEST.RESPONSE.close()
return
@@ -1411,16 +1359,9 @@ class ECHO_externalLink(Folder,ECHO_basi
def changeECHO_externalLink(self,link,title,label,description,contentType,responsible,weight,coords=None,credits=None,RESPONSE=None):
-
"""Aenderung der Properties"""
- try:
- 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)
- self.coords=coordsnew[0:]
self.link=link
if RESPONSE is not None:
RESPONSE.redirect('manage_main')
@@ -1552,7 +1493,7 @@ class ECHO_collection(Folder, Persistent
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
resource[1].changeAccessRightMD(argv[resource[1].getId()])
except:
- """not"""
+ pass
return ret
def changeMetaDataLinkInCollection(self):
@@ -1567,7 +1508,7 @@ class ECHO_collection(Folder, Persistent
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
resource[1].metalink=argv[resource[1].getId()][0:]
except:
- """not"""
+ pass
return ret
def changeMetaDataLinkInCollection(self):
@@ -1582,7 +1523,7 @@ class ECHO_collection(Folder, Persistent
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
resource[1].metalink=argv[resource[1].getId()][0:]
except:
- """not"""
+ pass
return ret
def changeWeightsInCollection(self):
@@ -1597,7 +1538,7 @@ class ECHO_collection(Folder, Persistent
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
resource[1].weight=argv[resource[1].getId()][0:]
except:
- """not"""
+ pass
return ret
def changeTitlesInCollection(self):
@@ -1612,7 +1553,7 @@ class ECHO_collection(Folder, Persistent
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
resource[1].title=argv[resource[1].getId()][0:]
except:
- """not"""
+ pass
return ret
def updateCollection(self,RESPONSE=None):
@@ -1880,116 +1821,11 @@ class ECHO_collection(Folder, Persistent
ret=""""""
return ret+""+getCollection(self)+""
- def createJavaScript(self):
- """OLD CreateJava"""
- ret=javaScriptMain
-
- dynamical="\n"
- for ob in self.getGraphicCoords():
- if ob[4][4] == "":
- 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
- return ret
-
- def newMapArea(self, id, coords=None):
- """returns a new MapArea"""
- if coords is None:
- coords = [0,0,0,0]
- return MapArea(id, coords)
-
- def createJSAreas(self, areas):
- """create area calls for JavaScript"""
- dynamical="\n"
- for ob in areas:
- if ob.isTypeArrow():
- dynamical+="""addArea('%s', 'overview', %s, 'arrow');\n"""%(ob.getFullId(),ob.getCoordString())
- else:
- dynamical+="""addArea('%s', 'overview', %s, 'area');\n"""%(ob.getFullId(),ob.getCoordString())
- return dynamical
-
def createAllJSAreas(self):
"""create area calls for JavaScript"""
areas = self.getAllMapAreas()
return self.createJSAreas(areas)
- def createMapHead(self):
- """create javascript include and script tags for head"""
- pt=zptFile(self, 'zpt/ECHO_content_map_frag_js')
- return pt()
-
- def createMapImg(self):
- """generate img-tag for map"""
- bt = BrowserCheck(self)
- tag = ""
- src = self.REQUEST['URL1'] + "/overview"
- if bt.isN4:
- tag += ''%src
- else:
- tag += ''%src
- return tag
-
- def createMapLink(self, ob, text=None):
- """generate map link"""
- bt = BrowserCheck(self)
- id = ob.getFullId()
- link = ob.getLinkId()
- if text is None:
- text = ob.getLabel()
- if text is None:
- text = "link"
- tag = ""
- if bt.isN4:
- tag += '" + text + ""
- else:
- tag = '" + text + ""
- 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"""
- bt = BrowserCheck(self)
- id = ob.getFullId()
- link = ob.getLinkId()
- tiptext = ob.getText()
- tag = ""
-
- if bt.isN4:
- tag += ''%(id,id,id)
- if ob.isTypeArrow():
- rot = ob.angle
- tag += ''%(link,arrowsrc,rot)
- else:
- tag += ''
- tag += ''
- else:
- tag = ''%(id,id,id,link)
- if ob.isTypeArrow():
- rot = ob.angle
- if bt.isIEWin and bt.versIE > 5:
- tag += ''%(id,arrowsrc,rot,arrowsrc,rot)
- else:
- tag += ''%(id,arrowsrc,rot)
- else:
- if bt.isIEWin:
- tag += '
'
- tag += ''
- return tag
-
-
security.declarePublic('getCreditObject')
def getCreditObject(self,name):
"""credit id to credititem"""
@@ -2058,7 +1894,7 @@ class ECHO_collection(Folder, Persistent
{'label':'Change Titles','action':'changeTitles'},
{'label':'Change Weights','action':'changeWeights'},
{'label':'Rerender Labels and Titles','action':'ECHO_rerenderLinksMDWarning'},
- {'label':'Graphics','action':'ECHO_graphicEntry'},
+ {'label':'Graphic Coords','action':'ECHO_graphicEntry'},
{'label':'create resources from XML','action':'createRessourcesFromXMLForm'},
{'label':'Set Startpage','action':'setStartpageFolderForm'},
{'label':'Change Viewer Templates and Image Viewer','action':'changeViewerTemplateSetsForm'},
@@ -2067,20 +1903,6 @@ class ECHO_collection(Folder, Persistent
{'label':'Copy MD for indexing and search','action':'copySearchFields'},
)
- def getOverview(self):
- """overview graphics"""
- return self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])[0][1]
-
-
- def ECHO_graphicEntry(self):
- """DO nothing"""
- overview = self.aq_parent.ZopeFind(self.aq_parent,obj_ids=['overview'])
- if overview:
- pt=zptFile(self, 'zpt/ECHO_draw.zpt')
- return pt()
- else:
- return "NO OVERVIEW GRAPHICS"
-
security.declarePublic('ECHO_collection_config')
def ECHO_collection_config(self):
@@ -2092,9 +1914,6 @@ class ECHO_collection(Folder, Persistent
if not hasattr(self,'sortfield'):
self.sortfield="weight"
- if not hasattr(self,'coords'):
- self.coords=[]
-
pt=zptFile(self, 'zpt/ChangeECHO_collection.zpt')
return pt()
@@ -2115,22 +1934,10 @@ class ECHO_collection(Folder, Persistent
self.secondaryLinkTitle=secondaryLinkTitle
self.imageTag=imageTag
self.bgcolour=bgcolour
- self.viewClassification=viewClassification
self.location=location
self.isAlwaysClickable=isAlwaysClickable
-
- 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)
- try:
- self.coords=coordsnew[0:] # HACK fehler in setECHO_collection
- except:
- """none"""
+ setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)
self.sortfield=sortfield
@@ -2241,46 +2048,6 @@ class ECHO_collection(Folder, Persistent
parent._delObject(id)
return "Done"
- def repairCoords(self):
- """updates map coordinates to new class objects"""
- msg = ""
- for cols in self.ZopeFind(self, obj_metatypes=['ECHO_collection','ECHO_resource'], search_sub=1):
- col = cols[1]
- if not hasattr(col, 'coords'):
- continue
- print "fixing: ", col.id
- msg += "fixing: "+col.id+"\n"
- coords = col.coords
- if len(coords) > 0:
- # delete old MapAreas
- for areas in self.ZopeFind(col, obj_metatypes=['MapArea']):
- #area = areas[1]
- id = areas[0]
- print " deleting: ", id
- msg += " deleting: "+id+"\n"
- col._delObject(id)
- # add new MapAreas
- areacnt = 0
- for coord in coords:
- if len(coord) < 4:
- continue
- type = col.viewClassification
- if type == 'view point':
- type = 'arrow'
- if type is None:
- if len(coord) > 4:
- type = 'arrow'
- else:
- type = 'area'
- newid = "a%02d"%areacnt
- areacnt += 1
- area = MapArea(newid, coord, type=type)
- print " adding: ", newid
- msg += " adding: "+newid+"\n"
- col.addMapArea(area) print "added"
-
- msg += "\nDone!"
- return msg
getSubCols = ECHO_helpers.getSubCols
@@ -2311,7 +2078,7 @@ class ECHO_group(ECHO_collection):
manage_options = Folder.manage_options+(
{'label':'Main Config','action':'ECHO_group_config'},
{'label':'Rerender Links','action':'ECHO_rerenderLinksMDWarning'},
- {'label':'Graphics','action':'ECHO_graphicEntry'},
+ {'label':'Graphic Coords','action':'ECHO_graphicEntry'},
)
security.declareProtected('View','index_html')
@@ -2384,14 +2151,7 @@ class ECHO_group(ECHO_collection):
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)
+ setECHO_collectionInformation(self,title,label,description,contentType,responsible,credits,weight)
@@ -2601,6 +2361,11 @@ class ECHO_root(Folder,Persistent,Implic
###END CDLI add
+ def URLquote(self, text):
+ """urllib.quote fuer Michael"""
+ return urllib.quote(text)
+
+
def checkResource(self,id):
"""checks if a resource is in the tree, gives back none or list of resources"""
if hasattr(self,"_v_checkResource") and self._v_checkResource.has_key(id): #existiert ein cache und id ist bereits drin?
@@ -2743,7 +2508,7 @@ class ECHO_root(Folder,Persistent,Implic
ret+=resource[1].getId()+" "+argv[resource[1].getId()]+""
resource[1].weight=argv[resource[1].getId()][0:]
except:
- """not"""
+ pass
return ret
def changeWeights(self):
@@ -2984,6 +2749,11 @@ class ECHO_root(Folder,Persistent,Implic
return "changed all contenttypes in: "+self.title
+ def repairAllCoords(self):
+ """updates map coordinates on the same and sublevels"""
+ return repairCoords(self)
+
+
def patchViewClassification(self,obj=None):
"""setze viewClassification heuristisch"""
@@ -3018,23 +2788,15 @@ class ECHO_root(Folder,Persistent,Implic
def deleteCache(self,obj=None,RESPONSE=None):
"""setze alle collections auf cache = CacheManager"""
-
-
if not obj:
obj = self
-
entries=obj.ZopeFind(obj,search_sub=1)
-
for entry in entries:
if hasattr(entry[1],'_v_hash'):
entry[1]._v_hash=None
-
-
-
return "changed all CM in: "+self.title
-
security.declarePublic('ECHO_newViewerLink')
def ECHO_newViewerLink(self,obj=None):
@@ -3750,3 +3512,42 @@ def manage_addECHO_institution(self, id,
REQUEST.RESPONSE.redirect('%s/manage_main' % url)
return id
+def repairCoords(self):
+ """updates map coordinates to new MapArea objects"""
+ msg = ""
+ for cols in self.ZopeFind(self, obj_metatypes=['ECHO_collection','ECHO_resource'], search_sub=1):
+ col = cols[1]
+ if not hasattr(col, 'coords'):
+ continue
+ print "fixing: ", col.id
+ msg += "fixing: "+col.id+"\n"
+ coords = col.coords
+ if len(coords) > 0:
+ # delete old MapAreas
+ for areas in self.ZopeFind(col, obj_metatypes=['MapArea']):
+ #area = areas[1]
+ id = areas[0]
+ print " deleting: ", id
+ msg += " deleting: "+id+"\n"
+ col._delObject(id)
+ # add new MapAreas
+ areacnt = 0
+ for coord in coords:
+ if len(coord) < 4:
+ continue
+ type = col.viewClassification
+ if type == 'view point':
+ type = 'arrow'
+ if type is None:
+ if len(coord) > 4:
+ type = 'arrow'
+ else:
+ type = 'area'
+ newid = "a%02d"%areacnt
+ areacnt += 1
+ area = MapArea(newid, coord, type=type)
+ print " adding: ", newid
+ msg += " adding: "+newid+"\n"
+ col.addMapArea(area)
+ msg += "\nDone!"
+ return msg