From 54a403acdbd626445c3a7cabd82573576c810cd8 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Tue, 11 Nov 2008 15:46:25 -0700 Subject: [PATCH] Update enriched Viewer. --- imp/lib/Mime/Viewer/enriched.php | 55 ++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/imp/lib/Mime/Viewer/enriched.php b/imp/lib/Mime/Viewer/enriched.php index d3e4cc1b9..9e2299eff 100644 --- a/imp/lib/Mime/Viewer/enriched.php +++ b/imp/lib/Mime/Viewer/enriched.php @@ -14,41 +14,50 @@ class IMP_Horde_Mime_Viewer_enriched extends Horde_Mime_Viewer_enriched { /** - * Render out the currently set contents. + * Return the full rendered version of the Horde_Mime_Part object. * - * @param array $params An array with a reference to a MIME_Contents - * object. - * - * @return string The rendered text in HTML. + * @return array See Horde_Mime_Viewer_Driver::render(). */ - public function render($params) + protected function _render() { - $contents = &$params[0]; - - global $prefs; - - if (($text = $this->mime_part->getContents()) === false) { - return $this->formatPartError(_("There was an error displaying this message part")); - } - - if (trim($text) == '') { - return $text; - } + $ret = parent::_render(); + $ret['data'] = $this->_IMPformat($ret['data']); + return $ret; + } - $text = parent::render(); + /** + * Return the rendered inline version of the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInline() + { + $ret = parent::_renderInline(); + $ret['data'] = $this->_IMPformat($ret['data']); + return $ret; + } + /** + * Format output text with IMP additions. + * + * @param string $text The HTML text. + * + * @return string The text with extra IMP formatting applied. + */ + protected function _IMPformat($text) + { // Highlight quoted parts of an email. - if ($prefs->getValue('highlight_text')) { + if ($GLOBALS['prefs']->getValue('highlight_text')) { $text = implode("\n", preg_replace('|^(\s*>.+)$|', '\1', explode("\n", $text))); $indent = 1; while (preg_match('|>(\s?>){' . $indent . '}|', $text)) { $text = implode("\n", preg_replace('|^(\s*>(\s?>){' . $indent . '}.+)$|', '\1', explode("\n", $text))); - $indent++; + ++$indent; } } // Dim signatures. - if ($prefs->getValue('dim_signature')) { + if ($GLOBALS['prefs']->getValue('dim_signature')) { $parts = preg_split('|(\n--\s*\n)|', $text, 2, PREG_SPLIT_DELIM_CAPTURE); $text = array_shift($parts); if (count($parts)) { @@ -59,8 +68,6 @@ class IMP_Horde_Mime_Viewer_enriched extends Horde_Mime_Viewer_enriched } // Filter bad language. - $text = IMP::filterText($text); - - return $text; + return IMP::filterText($text); } } -- 2.11.0