\Horde_Text_Flowed

The Text_Flowed:: class provides common methods for manipulating text using the encoding described in RFC 3676 ('flowed' text).

This class is based on the Text::Flowed perl module (Version 0.14) found in the CPAN perl repository. This module is released under the Perl license, which is compatible with the LGPL.

Copyright 2002-2003 Philip Mak 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()
setMaxLength()
setOptLength()
setDelSp()
toFixed()
toFixedArray()
toFlowed()
No public properties found
No constants found
_reformat()
_numquotes()
_stuff()
_unstuff()
$_maxlength
$_optlength
$_text
$_output
$_formattype
$_charset
$_delsp
N/A
No private methods found
No private properties found
N/A

Properties

$_maxlength

$_maxlength : integer

The maximum length that a line is allowed to be (unless faced with with a word that is unreasonably long). This class will re-wrap a line if it exceeds this length.

Type

integer

$_optlength

$_optlength : integer

When this class wraps a line, the newly created lines will be split at this length.

Type

integer

$_text

$_text : string

The text to be formatted.

Type

string

$_output

$_output : array

The cached output of the formatting.

Type

array

$_formattype

$_formattype : string

The format of the data in $_output.

Type

string

$_charset

$_charset : string

The character set of the text.

Type

string

$_delsp

$_delsp : boolean

Convert text using DelSp?

Type

boolean

Methods

__construct()

__construct(string  $text, string  $charset = 'UTF-8') 

Constructor.

Parameters

string $text

The text to process.

string $charset

The character set of $text.

setMaxLength()

setMaxLength(integer  $max) 

Set the maximum length of a line of text.

Parameters

integer $max

A new value for $_maxlength.

setOptLength()

setOptLength(  $opt) 

Set the optimal length of a line of text.

Parameters

$opt

setDelSp()

setDelSp(boolean  $delsp) 

Set whether to format text using DelSp.

Parameters

boolean $delsp

Use DelSp?

toFixed()

toFixed(boolean  $quote = false) : string

Reformats the input string, where the string is 'format=flowed' plain text as described in RFC 2646.

Parameters

boolean $quote

Add level of quoting to each line?

Returns

string —

The text converted to RFC 2646 'fixed' format.

toFixedArray()

toFixedArray(boolean  $quote = false) : array

Reformats the input string, and returns the output in an array format with quote level information.

Parameters

boolean $quote

Add level of quoting to each line?

Returns

array —

An array of arrays with the following elements:

'level' - The quote level of the current line.
'text'  - The text for the current line.

toFlowed()

toFlowed(boolean  $quote = false, array  $opts = array()) : string

Reformats the input string, where the string is 'format=fixed' plain text as described in RFC 2646.

Parameters

boolean $quote

Add level of quoting to each line?

array $opts

Additional options:

'nowrap' - (boolean) If true, does not wrap unquoted lines.
           DEFAULT: false

Returns

string —

The text converted to RFC 2646 'flowed' format.

_reformat()

_reformat(boolean  $toflowed, boolean  $quote, boolean  $wrap = true) 

Reformats the input string, where the string is 'format=flowed' plain text as described in RFC 2646.

Parameters

boolean $toflowed

Convert to flowed?

boolean $quote

Add level of quoting to each line?

boolean $wrap

Wrap unquoted lines?

_numquotes()

_numquotes(string  $text) : integer

Returns the number of leading '>' characters in the text input.

'>' characters are defined by RFC 2646 to indicate a quoted line.

Parameters

string $text

The text to analyze.

Returns

integer —

The number of leading quote characters.

_stuff()

_stuff(string  $text, string  $num_quotes, boolean  $toflowed) : string

Space-stuffs if it starts with ' ' or '>' or 'From ', or if quote depth is non-zero (for aesthetic reasons so that there is a space after the '>').

Parameters

string $text

The text to stuff.

string $num_quotes

The quote-level of this line.

boolean $toflowed

Are we converting to flowed text?

Returns

string —

The stuffed text.

_unstuff()

_unstuff(string  $text) : string

Unstuffs a space stuffed line.

Parameters

string $text

The text to unstuff.

Returns

string —

The unstuffed text.