--- ECHO_content/ECHO_helpers.py 2004/12/02 20:11:49 1.31
+++ ECHO_content/ECHO_helpers.py 2005/01/18 15:40:03 1.33
@@ -221,11 +221,12 @@ class ECHO_basis:
"""generate img-tag for map"""
bt = BrowserCheck(self)
tag = ""
- #src = self.REQUEST['URL1'] + "/overview"
src = self.getOverview().absolute_url()
if bt.isN4:
+ # N4 needs ilayer to create an id
tag += ''%src
else:
+ # img with id
tag += ''%src
return tag
@@ -242,14 +243,17 @@ class ECHO_basis:
text = ob.getLabel()
if text is None:
text = "link"
+ tiptext = ob.getText()
tag = ""
if bt.isN4:
+ # N4 needs layer for highlighting
tag += '" + text + ""
else:
+ # a-element
tag = '" + text + ""
return tag
@@ -262,6 +266,7 @@ class ECHO_basis:
tag = ""
if bt.isN4:
+ # N4 needs layer and img elements
tag += ''%(id,id,id)
if ob.isTypeArrow():
rot = ob.angle
@@ -273,21 +278,29 @@ class ECHO_basis:
tag += ' />'
tag += ''
else:
+ # create a-element
tag = ''%(id,id,id,link)
if ob.isTypeArrow():
rot = ob.angle
if bt.isIEWin and bt.versIE > 5:
+ # IE/Win 5.5 has "feature" for PNG transparency
tag += ''%(id,arrowsrc,rot,arrowsrc,rot)
else:
+ # arrow image
tag += ''%(id,arrowsrc,rot)
else:
- if bt.isIEWin:
- tag += '"
else:
+ # div for area
tag += '
'
+ if tiptext:
+ tag += ' title="%s"'%tiptext
+ tag += '> '
tag += ''
return tag
@@ -370,7 +383,7 @@ def checkOnlyOneInGroup(object):
return displayedObjects[0][1]
else: return object
-def getSubCols(self,sortfield="weight",subColTypes= displayTypes,sortFieldMD=None):
+def getSubCols(self, sortfield="weight", subColTypes=displayTypes, sortFieldMD=None):
def sortfnc(sortfield,x,y):
xa=x[1].getMDValue(sortfield)
@@ -567,23 +580,45 @@ def checkDiffs(self,metadict):
return diffs
-def zptFile(self, path):
+def zptFile(self, path, orphaned=False):
"""returns a page template file from the product"""
- pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self)
+ if orphaned:
+ # unusual case (only for macro templates)
+ pt=PageTemplateFile(os.path.join(package_home(globals()), path))
+ else:
+ pt=PageTemplateFile(os.path.join(package_home(globals()), path)).__of__(self)
return pt
-def sendFile(self, filename, type):
- """sends an object or a local file (in the product) as response"""
+def findObjectPath(startobject, filename):
+ """returns the object with the filename starting at startobject"""
+ if startobject is None:
+ return None
paths = filename.split('/')
- object = self
- # look for an object called filename
+ object = startobject
for path in paths:
if hasattr(object, path):
object = getattr(object, path)
else:
object = None
break
+ return object
+
+
+def zptObjectOrFile(self, filename, localdir='zpt', orphaned=False):
+ """returns a page template instance or a file from the product"""
+ # look for an object called path
+ pt = findObjectPath(self, filename)
+ if pt is None:
+ # get a ZPT file
+ pt = zptFile(self, localdir+'/'+filename, orphaned=orphaned)
+ return pt
+
+
+def sendFile(self, filename, type):
+ """sends an object or a local file (in the product) as response"""
+ # look for an object called filename
+ object = findObjectPath(self, filename)
if object:
# if the object exists then send it
return object.index_html(self.REQUEST.REQUEST, self.REQUEST.RESPONSE)