--- ECHO_content/ECHO_helpers.py 2005/06/08 10:23:16 1.49
+++ ECHO_content/ECHO_helpers.py 2005/06/09 08:34:49 1.50
@@ -186,10 +186,23 @@ class ECHO_basis:
"""add a map area to this object"""
if (newarea.id is None):
# create new id
- areas = self.getMapAreas()
- newarea.id = "a%02d"%len(areas)
+ ids = [a.id for a in self.getMapAreas()]
+ i = len(ids)
+ while ("a%02d"%i in ids):
+ # if it exists, try the next one
+ i += 1
+ newarea.id = "a%02d"%i
self._setObject(newarea.id, newarea)
+ def getMapText(self):
+ """returns the MapText"""
+ # get (the first) contained MapText
+ res = self.ZopeFind(self, obj_metatypes=('ECHO_mapText'))
+ if len(res) > 0:
+ text = res[0][1]
+ return text
+ return None
+
def ECHO_graphicEntry(self):
"""change map coordinates"""
if self.hasParentOverview():
@@ -238,10 +251,7 @@ class ECHO_basis:
"""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())
+ dynamical+="""addArea('%s', 'overview', %s, '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType())
return dynamical
def createMapHead(self):
@@ -275,7 +285,7 @@ class ECHO_basis:
text = ob.getLabel()
if text is None:
text = "link"
- tiptext = ob.getText()
+ tiptext = ob.getTip()
tag = ""
if bt.isN4:
# N4 needs layer for highlighting
@@ -294,7 +304,7 @@ class ECHO_basis:
bt = BrowserCheck(self)
id = ob.getFullId()
link = ob.getLinkId()
- tiptext = ob.getText()
+ tiptext = ob.getTip()
tag = ""
if bt.isN4:
@@ -320,6 +330,14 @@ class ECHO_basis:
else:
# arrow image
tag += ''%(id,arrowsrc,rot)
+ elif ob.isTypeText():
+ # div for area
+ tag += '
'%(id)
+ tag += ob.getText()
+ tag += '
'
else:
if bt.isIE:
# IE needs transparent img for area
@@ -328,7 +346,7 @@ class ECHO_basis:
tag += ' title="%s"'%tiptext
tag += " />"
else:
- # div for area
+ # empty div for area
tag += ' 4:
@@ -887,7 +905,8 @@ class MapArea(SimpleItem):
self.id = id
self.label = label
self.setType(type)
- self.text = text
+ self.tip = tip
+ self.volatile = volatile
def setCoords(self, coords):
"""sets the coords"""
@@ -922,6 +941,8 @@ class MapArea(SimpleItem):
self.type = MapArea.TYPE_ARROW
elif type == MapArea.TYPE_AREA:
self.type = MapArea.TYPE_AREA
+ elif type == MapArea.TYPE_TEXT:
+ self.type = MapArea.TYPE_TEXT
else:
self.type = MapArea.TYPE_AREA
@@ -933,6 +954,10 @@ class MapArea(SimpleItem):
"""returns if the type is arrow"""
return self.type == MapArea.TYPE_ARROW
+ def isTypeText(self):
+ """returns if the type is text"""
+ return self.type == MapArea.TYPE_TEXT
+
def getAngle(self):
"""returns the angle"""
return self.angle
@@ -941,18 +966,31 @@ class MapArea(SimpleItem):
"""sets the angle"""
self.angle = angle
- def getText(self):
+ def getTip(self):
"""returns the popup text"""
- if self.text is None:
+ # patch old version
+ if not hasattr(self, 'tip'):
+ self.tip = self.text
+
+ if self.tip is None:
if hasattr(self, 'aq_parent'):
parent = self.aq_parent
if parent.contentType == 'text-popup':
return parent.description
- return self.text
+ return self.tip
- def setText(self, text):
+ def setTip(self, text):
"""sets the text"""
- self.text = text
+ self.tiptext = text
+
+ def getText(self):
+ """returns the text fpr the area"""
+ if hasattr(self, 'aq_parent'):
+ parent = self.aq_parent
+ text = parent.getMapText()
+ if text is not None:
+ return text.document_src()
+ return ""
def getLabel(self):
"""returns the link label"""
@@ -970,7 +1008,6 @@ class MapArea(SimpleItem):
return self.aq_parent.id
return self.id
-
# call this to initialize framework classes, which
# does the right thing with the security assertions.
Globals.InitializeClass(MapArea)
@@ -985,7 +1022,7 @@ class MapText(ZopePageTemplate):
security.setDefaultAccess("allow")
_default_content_fn = os.path.join(package_home(globals()),
- 'zpt', 'ECHO_mapText_default.html')
+ 'html', 'ECHO_mapText_default.html')
def __init__(self, id, text=None, content_type=None):
self.id = str(id)