'%(id,id,id,link,target)
if ob.isTypeArrow():
+ # DOM - Arrow
rot = ob.angle
+ marksrc = arrowsrc
+ if float(rot) < 0:
+ marksrc = circlesrc
if bt.isIEWin and bt.versIE > 5:
# IE/Win 5.5 has "feature" for PNG transparency
- tag += ''%(id,arrowsrc,rot,arrowsrc,rot)
+ tag += ''%(id,marksrc,rot,marksrc,rot)
else:
# arrow image
- tag += ''%(id,arrowsrc,rot)
+ tag += ''%(id,marksrc,rot)
+ elif ob.isTypeText():
+ # DOM - Text
+ tag += ''
+ tag += ob.getText()
+ tag += '
'
else:
+ # DOM - Area
if bt.isIE:
# IE needs transparent img for area
tag += '"
else:
- # div for area
+ # empty div for area
tag += '"
ret+=x
- #print x
-
if RESPONSE is not None:
#RESPONSE.redirect('./manage_main')
@@ -603,6 +705,7 @@ def findObjectPath(startobject, filename
paths = filename.split('/')
object = startobject
for path in paths:
+
if hasattr(object, path):
object = getattr(object, path)
else:
@@ -665,7 +768,7 @@ def writeMetadata(url,metadict,project=N
"""Einlesen der Metadaten und und erstellen des geaenderten XML file"""
def updateTextToolNode(tag,value):
- #print dom,tag,value
+
metanode=dom.getElementsByTagName('texttool')[0]
try:
nodeOld=metanode.getElementsByTagName(tag)
@@ -809,7 +912,9 @@ def readMetadata(url):
for node in metacontent:
try:
#print urllib.unquote(getText(node.childNodes)),getText(node.childNodes)
- metadict[re.sub('-','_',node.tagName.lower())]=urllib.unquote(getText(node.childNodes))
+ #metadict[re.sub('-','_',node.tagName.lower())]=urllib.unquote(getText(node.childNodes))
+ metadict[re.sub('-','_',node.tagName.lower())]=getText(node.childNodes)
+
except:
"""nothing"""
@@ -827,8 +932,9 @@ class MapArea(SimpleItem):
# type constants
TYPE_AREA = 'area'
TYPE_ARROW = 'arrow'
+ TYPE_TEXT = 'text'
- def __init__(self, id, coords, label=None, type=None, text=None):
+ def __init__(self, id, coords, label=None, type=None, tip=None, permanent=False):
"""init"""
self.coords = coords[0:4]
if len(coords) > 4:
@@ -838,7 +944,8 @@ class MapArea(SimpleItem):
self.id = id
self.label = label
self.setType(type)
- self.text = text
+ self.tip = tip
+ self.permanent = permanent
def setCoords(self, coords):
"""sets the coords"""
@@ -873,6 +980,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
@@ -884,6 +993,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
@@ -892,18 +1005,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"""
@@ -916,12 +1042,86 @@ 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
return self.id
-
# call this to initialize framework classes, which
# does the right thing with the security assertions.
Globals.InitializeClass(MapArea)
+
+
+class MapText(ZopePageTemplate):
+ """class to hold text for map areas"""
+
+ meta_type = 'ECHO_mapText'
+ # Create a SecurityInfo for this class.
+ security = ClassSecurityInfo()
+ security.setDefaultAccess("allow")
+
+ _default_content_fn = os.path.join(package_home(globals()),
+ 'html', 'ECHO_mapText_default.html')
+
+ def __init__(self, id, text=None, content_type=None):
+ self.id = str(id)
+ self.ZBindings_edit(self._default_bindings)
+ if text is None:
+ text = open(self._default_content_fn).read()
+ self.pt_edit(text, content_type)
+
+# Product registration and Add support
+manage_addMapTextForm = PageTemplateFile(
+ 'zpt/AddECHO_mapText', globals(), __name__='manage_addMapTextForm')
+
+def manage_addMapText(self, id, title=None, text=None,
+ REQUEST=None, submit=None):
+ "Add a Map Text with optional file content."
+
+ id = str(id)
+ if REQUEST is None:
+ self._setObject(id, MapText(id, text))
+ ob = getattr(self, id)
+ if title:
+ ob.pt_setTitle(title)
+ return ob
+ else:
+ file = REQUEST.form.get('file')
+ headers = getattr(file, 'headers', None)
+ if headers is None or not file.filename:
+ zpt = MapText(id, text)
+ else:
+ zpt = MapText(id, file, headers.get('content_type'))
+
+ self._setObject(id, zpt)
+ if title:
+ ob = getattr(self, id)
+ ob.pt_setTitle(title)
+
+ try:
+ u = self.DestinationURL()
+ except AttributeError:
+ u = REQUEST['URL1']
+
+ if submit == " Add and Edit ":
+ u = "%s/%s" % (u, urllib.quote(id))
+ REQUEST.RESPONSE.redirect(u+'/manage_main')
+ return ''
+
+# call this to initialize framework classes, which
+# does the right thing with the security assertions.
+Globals.InitializeClass(MapText)