--- ECHO_content/ECHO_helpers.py 2005/06/08 07:07:27 1.48 +++ ECHO_content/ECHO_helpers.py 2005/06/08 10:23:16 1.49 @@ -6,6 +6,7 @@ import string import xml.dom.minidom import types from Products.PageTemplates.PageTemplateFile import PageTemplateFile +from Products.PageTemplates.ZopePageTemplate import ZopePageTemplate from OFS.SimpleItem import SimpleItem from Globals import package_home import Globals @@ -973,3 +974,64 @@ class MapArea(SimpleItem): # 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()), + 'zpt', '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)