--- ECHO_content/ECHO_helpers.py 2005/06/09 15:08:01 1.52 +++ ECHO_content/ECHO_helpers.py 2005/06/13 10:35:04 1.56 @@ -178,8 +178,19 @@ class ECHO_basis: def getMapAreas(self): """returns the list of MapAreas""" + forcetypes = self.REQUEST.get('map_force_types', None) + if forcetypes: + typelist = forcetypes.split(',') + else: + typelist = None + areas = [] # get all contained MapAreas - areas = [res[1] for res in self.ZopeFind(self, obj_metatypes=('MapArea'))] + for res in self.ZopeFind(self, obj_metatypes=('MapArea')): + area = res[1] + # check the allowed types + if typelist is not None and area.getType() not in typelist: + continue + areas.append(area) return areas def addMapArea(self, newarea): @@ -229,19 +240,22 @@ class ECHO_basis: coords = string.split(coordstring, ',') angle = self.REQUEST.get('angle.'+id, '0') type = self.REQUEST.get('type.'+id, 'area') + permanent = self.REQUEST.get('permanent.'+id, '') if len(coords) == 4: area.setCoordString(coordstring) area.setAngle(angle) area.setType(type) - # add new area + area.setPermanent(permanent) + # add the "new" area if self.REQUEST.has_key('add'): coordstring = self.REQUEST.get('coords.new', '') coords = string.split(coordstring, ',') angle = self.REQUEST.get('angle.new', '0') type = self.REQUEST.get('type.new', 'area') + permanent = self.REQUEST.get('permanent.new', '') if len(coords) == 4: coords.append(angle) - area = MapArea(None, coords, type=type) + area = MapArea(None, coords, type=type, permanent=permanent) self.addMapArea(area) # return to edit area menu if RESPONSE is not None: @@ -249,10 +263,16 @@ class ECHO_basis: def createJSAreas(self, areas): """create area calls for JavaScript""" - dynamical="\n" + forceperm = self.REQUEST.get('map_force_permanent', None) + js="\n" for ob in areas: - dynamical+="""addArea('%s', 'overview', %s, '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType()) - return dynamical + # check for force-permanent + if forceperm is not None: + perm = forceperm + else: + perm = ob.isPermanent() + js+="""addArea('%s', 'overview', %s, '%s', '%s');\n"""%(ob.getFullId(),ob.getCoordString(),ob.getType(),perm) + return js def createMapHead(self): """create javascript include and script tags for head""" @@ -289,11 +309,11 @@ class ECHO_basis: tag = "" if bt.isN4: # N4 needs layer for highlighting - tag += '" else: # a-element - tag = '" @@ -316,9 +336,15 @@ class ECHO_basis: # N4 - Arrow rot = ob.angle marksrc = arrowsrc - if rot < 0: + if float(rot) < 0: marksrc = circlesrc tag += ''%(link,marksrc,rot) + elif ob.isTypeText(): + # N4 - Text + tag += '
'%(id,id,id,link,target) + tag = ''%(id,id,id,link,target) if ob.isTypeArrow(): # DOM - Arrow rot = ob.angle marksrc = arrowsrc if float(rot) < 0: marksrc = circlesrc - print "ROT: ", rot, " mark: ", marksrc if bt.isIEWin and bt.versIE > 5: # IE/Win 5.5 has "feature" for PNG transparency tag += ''%(id,marksrc,rot,marksrc,rot) @@ -347,9 +372,8 @@ class ECHO_basis: elif ob.isTypeText(): # DOM - Text tag += '
4: @@ -921,7 +945,7 @@ class MapArea(SimpleItem): self.label = label self.setType(type) self.tip = tip - self.volatile = volatile + self.permanent = permanent def setCoords(self, coords): """sets the coords""" @@ -1018,6 +1042,20 @@ class MapArea(SimpleItem): """sets the label""" self.label = label + def isPermanent(self): + """returns the permanent state""" + # patch old objects + if not hasattr(self, 'permanent'): + self.permanent = False + return self.permanent + + def setPermanent(self, state): + """sets the permanent state""" + if state: + self.permanent = True + else: + self.permanent = False + def getLinkId(self): if hasattr(self, 'aq_parent'): return self.aq_parent.id