TextProcessor
abstract
TextProcessor

Base class for text processors

Properties
text

(string) The original, unformatted text.

formatted

(string) The final, formatted text.

entry

(Entry) The entry used to resolve URIs.

filter_id

(int) The ID fo the text filter.

filter_name

(string) The human-readable name of the filter.

no_surround

(boolean) Skip the surrounding markup, i.e. don't wrap in <P> tags.

Functions
get
static public function get(
$markup_type,
Entry $entry null,
$text ''
)

Factory method to get a processor based on a markup type.

Parameter
markup_type

A constant denoting the markup type, such as MARKUP_BBCODE.

entry

The entry object against which relative URIs should be resolved.

text

The data to format.

Returns

The instantiated TextProcessor

getFilterList
static public function getFilterList()

Convenience function that returns a map of filter IDs to names.

Returns An associative array mapping filter IDs to filter names.

getAvailableFilters
static public function getAvailableFilters()

Gets an array of instances of the available textprocessors.

Returns

An array of TextProcessor objects.

setText
public function setText(
$text
)

Set the initia text to process

Parameters
text

(string) The text to format

getRawText
public function getRawText()

Get the initial text passed for processing.

Returns

(string) The raw text

setEntry
public function setEntry(
Entry $entry null
)

Set the entry object against which URIs will be resolved.

Parameters
entry

(Entry) The entry object for resolution

getHTML
public function getHTML(
$text null
)

Get the formatted HTML text.

Parameters
text

(string) Optional text to translate.  Convenience parameter used for multiple calls on the same processor instance.

Returns

(string) The formatted HTML

fixIndividualURI
protected function fixIndividualURI(
$uri
)

Fixes a relative URI to be absolute.

If the formatter is passed a null entry, then relative URIs will not be resolved.

Parameters
uri

(string) The relative URI to fix

Returns

(string) The absolute URI.

sanitizeText
protected function sanitizeText(
$data
)

Strip HTML code out of a string.  Note that the UNICODE_ESCAPE_HACK configuration constant can be used to switch between using the PHP htmlentities() and htmlspecialchars() functions to sanitize input.  This is because htmlentities() has a nasty habit of mangling Unicode.

Parameters
data

(string) The data to clear

Returns

A copy of data with HTML special characters such as angle brackets and ampersands converted into their corresponding HTML entities.  This will cause them to display in a web page as characters, not HTML markup.