TextFormatter class

The TextFormatter class eases text formatting.

Class Overview

The TextFormatter class eases text formatting.

It provides 4 formatter methods to format the input text: textile, entities, specialchars and raw. The 'textile' formatter formats the text using the rich Textile formatting language. The 'entities' and 'specialchars' formatters escape HTML entities so that the result can safely be displayed in a web browser. The 'raw' formatter returns the unchanged input text (this is useful if the formatter type comes from a database column). Additionally, there's the 'auto' formatter that chooses between textile and raw, depending on the input looking like XHTML (using a very simple heuristic).

Public Static Methods

format($text, $formatter=null) [static]

Formats text using the given formatter.

This method is useful if you don't want to instantiate a TextFormatter object. If you want to reuse the textformatter instance, don't use this method.

Parameters

$text

String with text to format

$formatter

The name of the formatter to use (optional)

Return value

String containing the formatted text

Public Methods

TextFormatter($text=null, $formatter=null)

Initialize a new text formatter instance.

Both the text and formatter parameters are optional and can be set later using the 'text' and 'formatter' container properties.

Parameters

$text

String with text to format (optional).

$formatter

The name of the formatter to use (optional).

render()

Return the formatted text.

Return value

The formatted text

Public Attributes

$default_formatter

The default formatter.

Private Attributes

$formatters [private]

List of all available formatters.

Inheritance

Base Classes

Inherited members