\Horde_Mime_Viewer_Richtext

The Horde_Mime_Viewer_Richtext class renders out HTML text from text/richtext content tags, (RFC 1896 [7.1.3]).

A minimal richtext implementation is one that simply converts "" to "<", converts CRLFs to SPACE, converts to a newline according to local newline convention, removes everything between a command and the next balancing command, and removes all other formatting commands (all text enclosed in angle brackets).

We implement the following tags:

, , , , , ,
, , , , , , , , , , , The following tags are implemented differently than described in the RFC (due to limitations in HTML output): - Output as centered, bold text. - Output as centered, bold text. - Output as paragraph break. The following tags are NOT implemented: , , , , , , Copyright 2004-2017 Horde LLC (http://www.horde.org/) See the enclosed file LICENSE for license information (LGPL). If you did not receive this file, see http://www.horde.org/licenses/lgpl21.

Summary

Methods
Properties
Constants
__construct()
setMimePart()
render()
canRender()
embeddedMimeParts()
getEmbeddedMimeParts()
getConfigParam()
setConfigParam()
getDriver()
getMetadata()
No public properties found
No constants found
_render()
_renderInline()
_renderInfo()
_renderRaw()
_getEmbeddedMimeParts()
_getViewer()
_renderReturn()
_renderFullReturn()
_getTempFile()
_textFilter()
_toHTML()
$_conf
$_mimepart
$_required
$_capability
$_metadata
N/A
No private methods found
No private properties found
N/A

Properties

$_conf

$_conf : array

Viewer configuration.

Type

array

$_mimepart

$_mimepart : \Horde_Mime_Part

The Horde_Mime_Part object to render.

Type

\Horde_Mime_Part

$_required

$_required : array

Required configuration parameters.

Type

array

$_capability

$_capability : array

This driver's display capabilities.

Type

array

$_metadata

$_metadata : array

Metadata for the current viewer/data.

Type

array

Methods

__construct()

__construct(\Horde_Mime_Part  $part, array  $conf = array()) 

Constructor.

Parameters

\Horde_Mime_Part $part
array $conf

Configuration:

temp_file - (callback) A callback function that returns a temporary
            filename.  Is passed one parameter: a prefix string.
            DEFAULT: Uses Horde_Util::getTempFile().
text_filter - (callback) A callback function used to filter text. Is
              called the same as Horde_Text_Filter::filter().
              DEFAULT: Uses Horde_Text_Filter::filter().

Throws

\InvalidArgumentException

setMimePart()

setMimePart(\Horde_Mime_Part  $mime_part) 

Sets the Horde_Mime_Part object for the class.

Parameters

\Horde_Mime_Part $mime_part

The object with the data to be rendered.

render()

render(string  $mode) : array

Return the rendered version of the Horde_Mime_Part object.

Parameters

string $mode

The mode:

'full' - A full representation of the MIME part, for use in a view
         where the output to the browser can be set to the value
         returned in 'type'. This mode should only return a single
         MIME ID entry for viewing and should not return any status
         information.
'inline' - A representation of the MIME part that can be viewed inline
           on a text/html page that may contain other HTML elements.
'info' - A representation of the MIME part that can be viewed inline
         on an text/html page that may contain other HTML elements.
         This view is not a full view, but rather a condensed view of
         the contents of the MIME part. This view is intended to be
         displayed to the user with the intention that this MIME part's
         subparts may also independently be viewed inline.
'raw' - The raw data of the MIME part, generally useful for downloading
        a part. This view exists in case this raw data needs to be
        altered in any way.

Returns

array —

An array. The keys are the MIME parts that were handled by the driver. The values are either null (which indicates the driver is recommending that this particular MIME ID should not be displayed) or an array with the following keys:

'data' - (string) The rendered data.
'status' - (array) An array of status information to be displayed to
           the user.  Consists of arrays with the following keys:
           'class' - (string) The class to use for display.
           'img' - (string) An image to display.
           'text' - (array) The text to display.
'type' - (string) The MIME type of the rendered data.

canRender()

canRender(string  $mode) : boolean

Can this driver render the the data?

Parameters

string $mode

The mode. Either 'full', 'inline', 'info', or 'raw'.

Returns

boolean —

True if the driver can render the data for the given view.

embeddedMimeParts()

embeddedMimeParts() : boolean

Does this MIME part possibly contain embedded MIME parts?

Returns

boolean —

True if this driver supports parsing embedded MIME parts.

getEmbeddedMimeParts()

getEmbeddedMimeParts() : mixed

If this MIME part can contain embedded MIME part(s), and those part(s) exist, return a representation of that data.

Returns

mixed —

A Horde_Mime_Part object representing the embedded data. Returns null if no embedded MIME part(s) exist.

getConfigParam()

getConfigParam(string  $param) : mixed

Return a configuration parameter for the current viewer.

Parameters

string $param

The parameter name.

Returns

mixed —

The value of the parameter; returns null if the parameter doesn't exist.

setConfigParam()

setConfigParam(string  $param, mixed  $value) 

Sets a configuration parameter for the current viewer.

Parameters

string $param

The parameter name.

mixed $value

The parameter value.

getDriver()

getDriver() : string

Returns the driver name for the current object.

Returns

string —

The driver name.

getMetadata()

getMetadata(string  $data) : mixed

Returns metadata information on the viewer/data.

Parameters

string $data

The metadata key.

Returns

mixed —

The requested information, or null if the key doesn't exist.

_render()

_render() : array

Return the full rendered version of the Horde_Mime_Part object.

This MUST be text/html data.

Returns

array —

See parent::render().

_renderInline()

_renderInline() : array

Return the rendered inline version of the Horde_Mime_Part object.

This MUST be text/html data. This is not a full HTML document - only the HTML necessary to output the part.

Returns

array —

See parent::render().

_renderInfo()

_renderInfo() : array

Return the rendered information about the Horde_Mime_Part object.

Throws

\Horde_Exception

Returns

array —

See render().

_renderRaw()

_renderRaw() : array

Return the raw representation of the Horde_Mime_Part object.

Throws

\Horde_Exception

Returns

array —

See render().

_getEmbeddedMimeParts()

_getEmbeddedMimeParts() : mixed

If this MIME part can contain embedded MIME part(s), and those part(s) exist, return a representation of that data.

Returns

mixed —

A Horde_Mime_Part object representing the embedded data. Returns null if no embedded MIME part(s) exist.

_getViewer()

_getViewer() : mixed

Return the underlying MIME Viewer for this part.

Returns

mixed —

A Horde_Mime_Viewer object, or false if not found.

_renderReturn()

_renderReturn(string  $data = null, string  $type = null) : array

Internal helper function to create render data array for a MIME Part object that only has a single part.

Parameters

string $data

The rendered data.

string $type

The rendered type.

Returns

array —

See render().

_renderFullReturn()

_renderFullReturn(array  $data) : array

Internal helper function to add base HTML tags to a render() return array that contains a single MIME part.

Parameters

array $data

See render().

Returns

array —

See render().

_getTempFile()

_getTempFile() : string

Returns a temporary file name.

Returns

string —

A temp filename.

_textFilter()

_textFilter(string  $text, mixed  $driver, array  $params = array()) : string

Filter text.

Parameters

string $text

TODO

mixed $driver

TODO

array $params

TODO

Returns

string —

The filtered text.

_toHTML()

_toHTML() : string

Convert richtext to HTML.

Returns

string —

The converted HTML string.