From: Michael M Slusarz Date: Tue, 8 Sep 2009 02:38:25 +0000 (-0600) Subject: Improvements if HTML is not displayed inline. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=df76454c4d762ea3e0b23bc6e84c1328b2965d90;p=horde.git Improvements if HTML is not displayed inline. If HTML is only part (i.e. not a multipart/alternative part), show mime info box allowing viewing HTML in separate window or allowing conversion to a text/plain representation. --- diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index 1a1be0f66..fb0374128 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -717,7 +717,7 @@ class IMP_Contents * 'dload' - (boolean) Should we generate a download link? * 'jstext' - (string) The JS text to use. * 'params' - (array) A list of any additional parameters that need to be - * passed to view.php. + * passed to view.php. * * * @return string A HTML href link to view.php. diff --git a/imp/lib/Mime/Viewer/Html.php b/imp/lib/Mime/Viewer/Html.php index a060b00f4..a30d2d8f7 100644 --- a/imp/lib/Mime/Viewer/Html.php +++ b/imp/lib/Mime/Viewer/Html.php @@ -16,6 +16,19 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html { /** + * Can this driver render various views? + * + * @var boolean + */ + protected $_capability = array( + 'embedded' => false, + 'forceinline' => false, + 'full' => true, + 'info' => true, + 'inline' => true + ); + + /** * Cached block image. * * @var string @@ -69,15 +82,7 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html */ protected function _render() { - $render = $this->_IMPrender(false); - - return array( - $this->_mimepart->getMimeId() => array( - 'data' => $render['html'], - 'status' => $render['status'], - 'type' => $this->_mimepart->getType(true) - ) - ); + return $this->_IMPrender(false); } /** @@ -87,15 +92,39 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html */ protected function _renderInline() { - $render = $this->_IMPrender(true); + return $this->_IMPrender(true); + } + + /** + * Return the rendered information about the Horde_Mime_Part object. + * + * @return array See Horde_Mime_Viewer_Driver::render(). + */ + protected function _renderInfo() + { + if ($this->canRender('inline')) { + return array(); + } + + $status = array( + _("This message part contains HTML data, but inline HTML display is disabled."), + $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("View HTML data in new window.")), + $this->_params['contents']->linkViewJS($this->_mimepart, 'view_attach', _("Convert HTML data to plain text and view in new window."), array('params' => array('convert_text' => 1))) + ); return array( $this->_mimepart->getMimeId() => array( - 'data' => $render['html'], - 'status' => $render['status'], + 'data' => '', + 'status' => array( + array( + 'icon' => Horde::img('mime/html.png', _("HTML data")), + 'text' => $status + ) + ), 'type' => 'text/html; charset=' . Horde_Nls::getCharset() ) ); + } /** @@ -120,12 +149,20 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html $cleanhtml = $this->_cleanHTML($data, $inline, $msg_charset); $data = $cleanhtml['html']; - /* We are done processing if in mimp mode. */ - if ($_SESSION['imp']['view'] == 'mimp') { + /* We are done processing if in mimp mode, or we are converting to + * text. */ + if (($_SESSION['imp']['view'] == 'mimp') || + (!$inline && Horde_Util::getFormData('convert_text'))) { $data = Horde_Text_Filter::filter($data, 'html2text'); // Filter bad language. - return array('html' => IMP::filterText($data), 'status' => array()); + return array( + $this->_mimepart->getMimeId() => array( + 'data' => IMP::filterText($data), + 'status' => array(), + 'type' => 'text/plain; charset=' . Horde_Nls::getCharset() + ) + ); } /* Reset absolutely positioned elements. */ @@ -219,8 +256,11 @@ class IMP_Horde_Mime_Viewer_Html extends Horde_Mime_Viewer_Html } return array( - 'html' => $data, - 'status' => $cleanhtml['status'] + $this->_mimepart->getMimeId() => array( + 'data' => $data, + 'status' => $cleanhtml['status'], + 'type' => ($inline ? 'text/html; charset=' . Horde_Nls::getCharset() : $this->_mimepart->getType(true)) + ) ); }