class FreeTextBlock(Block): """ FreeTextBlock can render and process FreeTextIdevices as XHTML GenericBlock will replace it..... one day """ def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) if idevice.content.idevice is None: # due to the loading process's timing, idevice wasn't yet set; # set it here for the TextAreaElement's tinyMCE editor idevice.content.idevice = idevice self.contentElement = TextAreaElement(idevice.content) self.contentElement.height = 250 if not hasattr(self.idevice, 'undo'): self.idevice.undo = True def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ is_cancel = common.requestHasCancel(request) if is_cancel: self.idevice.edit = False # but double-check for first-edits, and ensure proper attributes: if not hasattr(self.idevice.content, 'content_w_resourcePaths'): self.idevice.content.content_w_resourcePaths = "" if not hasattr(self.idevice.content, 'content_wo_resourcePaths'): self.idevice.content.content_wo_resourcePaths = "" return Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): content = self.contentElement.process(request) if content: self.idevice.content = content def renderEdit(self, style): """ Returns an XHTML string with the form element for editing this block """ html = u"<div style=\"position: relative\">\n" html += self.contentElement.renderEdit() html += self.renderEditButtons() html += u"</div>\n" return html def renderPreview(self, style): """ Returns an XHTML string for previewing this block """ if hasattr(self.idevice, 'parent' ) and self.idevice.parent and not self.idevice.parent.edit: return u"" html = common.ideviceHeader(self, style, "preview") html += self.contentElement.renderPreview() html += common.ideviceFooter(self, style, "preview") return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u"<div class=\"iDevice " html += u"emphasis" + unicode(self.idevice.emphasis) + "\">\n" html += self.contentElement.renderView() html += u"</div>\n" return html def renderXML(self, style): xml = u"" """ If we are effectively just one large image then make just an img tag and sound tag if appropriate. If not output all the html """ xmlStr = self.contentElement.renderXML(None, "idevice", self.idevice.id) return xmlStr
class FreeTextBlock(Block): """ FreeTextBlock can render and process FreeTextIdevices as XHTML GenericBlock will replace it..... one day """ def __init__(self, parent, idevice): Block.__init__(self, parent, idevice) if idevice.content.idevice is None: # due to the loading process's timing, idevice wasn't yet set; # set it here for the TextAreaElement's tinyMCE editor idevice.content.idevice = idevice self.contentElement = TextAreaElement(idevice.content) self.contentElement.height = 250 if not hasattr(self.idevice,'undo'): self.idevice.undo = True def process(self, request): """ Process the request arguments from the web server to see if any apply to this block """ is_cancel = common.requestHasCancel(request) if is_cancel: self.idevice.edit = False # but double-check for first-edits, and ensure proper attributes: if not hasattr(self.idevice.content, 'content_w_resourcePaths'): self.idevice.content.content_w_resourcePaths = "" if not hasattr(self.idevice.content, 'content_wo_resourcePaths'): self.idevice.content.content_wo_resourcePaths = "" return Block.process(self, request) if (u"action" not in request.args or request.args[u"action"][0] != u"delete"): content = self.contentElement.process(request) if content: self.idevice.content = content def renderEdit(self, style): """ Returns an XHTML string with the form element for editing this block """ html = u"<div style=\"position: relative\">\n" html += self.contentElement.renderEdit() html += self.renderEditButtons() html += u"</div>\n" return html def renderPreview(self, style): """ Returns an XHTML string for previewing this block """ if hasattr(self.idevice, 'parent') and self.idevice.parent and not self.idevice.parent.edit: return u"" html = common.ideviceHeader(self, style, "preview") html += self.contentElement.renderPreview() html += common.ideviceFooter(self, style, "preview") return html def renderView(self, style): """ Returns an XHTML string for viewing this block """ html = u"<div class=\"iDevice " html += u"emphasis"+unicode(self.idevice.emphasis)+"\">\n" html += self.contentElement.renderView() html += u"</div>\n" return html def renderXML(self, style): xml = u"" """ If we are effectively just one large image then make just an img tag and sound tag if appropriate. If not output all the html """ xmlStr = self.contentElement.renderXML(None, "idevice", self.idevice.id) return xmlStr