Horde_Text_Flowed
in package
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.
Tags
Table of Contents
- $_charset : string
- The character set of the text.
- $_delsp : bool
- Convert text using DelSp?
- $_formattype : string
- The format of the data in $_output.
- $_maxlength : int
- 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.
- $_optlength : int
- When this class wraps a line, the newly created lines will be split at this length.
- $_output : array<string|int, mixed>
- The cached output of the formatting.
- $_text : string
- The text to be formatted.
- __construct() : mixed
- Constructor.
- setDelSp() : mixed
- Set whether to format text using DelSp.
- setMaxLength() : mixed
- Set the maximum length of a line of text.
- setOptLength() : mixed
- Set the optimal length of a line of text.
- toFixed() : string
- Reformats the input string, where the string is 'format=flowed' plain text as described in RFC 2646.
- toFixedArray() : array<string|int, mixed>
- Reformats the input string, and returns the output in an array format with quote level information.
- toFlowed() : string
- Reformats the input string, where the string is 'format=fixed' plain text as described in RFC 2646.
- _numquotes() : int
- Returns the number of leading '>' characters in the text input.
- _reformat() : mixed
- Reformats the input string, where the string is 'format=flowed' plain text as described in RFC 2646.
- _stuff() : 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 '>').
- _unstuff() : string
- Unstuffs a space stuffed line.
Properties
$_charset
The character set of the text.
protected
string
$_charset
$_delsp
Convert text using DelSp?
protected
bool
$_delsp
= \false
$_formattype
The format of the data in $_output.
protected
string
$_formattype
= \null
$_maxlength
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.
protected
int
$_maxlength
= 78
$_optlength
When this class wraps a line, the newly created lines will be split at this length.
protected
int
$_optlength
= 72
$_output
The cached output of the formatting.
protected
array<string|int, mixed>
$_output
= array()
$_text
The text to be formatted.
protected
string
$_text
Methods
__construct()
Constructor.
public
__construct(string $text[, string $charset = 'UTF-8' ]) : mixed
Parameters
- $text : string
-
The text to process.
- $charset : string = 'UTF-8'
-
The character set of $text.
Return values
mixed —setDelSp()
Set whether to format text using DelSp.
public
setDelSp(bool $delsp) : mixed
Parameters
- $delsp : bool
-
Use DelSp?
Return values
mixed —setMaxLength()
Set the maximum length of a line of text.
public
setMaxLength(int $max) : mixed
Parameters
- $max : int
-
A new value for $_maxlength.
Return values
mixed —setOptLength()
Set the optimal length of a line of text.
public
setOptLength(mixed $opt) : mixed
Parameters
- $opt : mixed
Return values
mixed —toFixed()
Reformats the input string, where the string is 'format=flowed' plain text as described in RFC 2646.
public
toFixed([bool $quote = false ]) : string
Parameters
- $quote : bool = false
-
Add level of quoting to each line?
Return values
string —The text converted to RFC 2646 'fixed' format.
toFixedArray()
Reformats the input string, and returns the output in an array format with quote level information.
public
toFixedArray([bool $quote = false ]) : array<string|int, mixed>
Parameters
- $quote : bool = false
-
Add level of quoting to each line?
Return values
array<string|int, mixed> —An array of arrays with the following elements:
'level' - The quote level of the current line. 'text' - The text for the current line.
toFlowed()
Reformats the input string, where the string is 'format=fixed' plain text as described in RFC 2646.
public
toFlowed([bool $quote = false ][, array<string|int, mixed> $opts = array() ]) : string
Parameters
- $quote : bool = false
-
Add level of quoting to each line?
- $opts : array<string|int, mixed> = array()
-
Additional options:
'nowrap' - (boolean) If true, does not wrap unquoted lines. DEFAULT: false
Return values
string —The text converted to RFC 2646 'flowed' format.
_numquotes()
Returns the number of leading '>' characters in the text input.
protected
_numquotes(string $text) : int
'>' characters are defined by RFC 2646 to indicate a quoted line.
Parameters
- $text : string
-
The text to analyze.
Return values
int —The number of leading quote characters.
_reformat()
Reformats the input string, where the string is 'format=flowed' plain text as described in RFC 2646.
protected
_reformat(bool $toflowed, bool $quote[, bool $wrap = true ]) : mixed
Parameters
- $toflowed : bool
-
Convert to flowed?
- $quote : bool
-
Add level of quoting to each line?
- $wrap : bool = true
-
Wrap unquoted lines?
Return values
mixed —_stuff()
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 '>').
protected
_stuff(string $text, string $num_quotes, bool $toflowed) : string
Parameters
- $text : string
-
The text to stuff.
- $num_quotes : string
-
The quote-level of this line.
- $toflowed : bool
-
Are we converting to flowed text?
Return values
string —The stuffed text.
_unstuff()
Unstuffs a space stuffed line.
protected
_unstuff(string $text) : string
Parameters
- $text : string
-
The text to unstuff.
Return values
string —The unstuffed text.