'%(id,id,id,link,target)
if ob.isTypeArrow():
rot = ob.angle
if bt.isIEWin and bt.versIE > 5:
@@ -288,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
@@ -296,7 +346,7 @@ class ECHO_basis:
tag += ' title="%s"'%tiptext
tag += " />"
else:
- # div for area
+ # empty div for area
tag += '"
ret+=x
- #print x
-
if RESPONSE is not None:
#RESPONSE.redirect('./manage_main')
@@ -580,23 +649,47 @@ 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
+ 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 name 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)
+ # the object should also not be a python function
+ if (pt is None) or isinstance(pt, types.FunctionType):
+ # 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)
@@ -636,7 +729,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)
@@ -780,7 +873,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"""
@@ -798,8 +893,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, volatile=True):
"""init"""
self.coords = coords[0:4]
if len(coords) > 4:
@@ -809,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"""
@@ -844,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
@@ -855,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
@@ -863,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"""
@@ -892,7 +1008,67 @@ 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)
+
+
+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)