SproutCMS

This is the code documentation for the SproutCMS project

Page options:

Inherited members

class Text

Various text helpers such as limiting.

Functions

NameVisibilityDescription
alternatepublic (static)Alternates between two or more strings.
autoLinkpublic (static)Converts text email addresses and anchors into links.
autoLinkEmailspublic (static)Converts text email addresses into links.
autoLinkUrlspublic (static)Converts text anchors into links.
autoPpublic (static)Automatically applies and markup to text. Basically nl2br() on steroids.
bytespublic (static)Returns human readable sizes.
camel2lcpublic (static)Convert a CamelCaps or camelCase name into a lower_case names
censorpublic (static)Replaces the given words with a string.
containsFormTagpublic (static)Determines whether given HTML contains a FORM tag, which can cause nested-forms issues
copyrightpublic (static)Returns current year or original year and current year of copyright
lc2camelcapspublic (static)Convert a lower_case names into CamelCaps names
lc2camelcasepublic (static)Convert a lower_case names into camelCase names
limitCharspublic (static)Limits a plain-text phrase to a given number of characters.
limitWordspublic (static)Limits a plain-text phrase to a given number of words.
limitWordsHtmlpublic (static)Limits HTML to a certain number of words.
limitedSubsetHtmlpublic (static)Encode HTML so it's suitable for direct output, but allow some HTML tags to be left as-is
ordinalizepublic (static)Returns a number with an english suffix appended (e.g. 1st, 5th, 12th, 123rd)
plainpublic (static)Make a chunk of valid HTML into plain text, and (optionally) limit the number of words.
reduceSlashespublic (static)Reduces multiple slashes in a string to single slashes.
richtextpublic (static)Make a chunk of plain text into HTML rich text
similarpublic (static)Finds the text that is similar between a set of words.
widontpublic (static)Prevents widow words by inserting a non-breaking space between the last two words.

public alternate

string Text::alternate ( );

Alternates between two or more strings.

public autoLink

string Text::autoLink ( string $text );

Converts text email addresses and anchors into links.

public autoLinkEmails

string Text::autoLinkEmails ( string $text );

Converts text email addresses into links.

public autoLinkUrls

string Text::autoLinkUrls ( string $text );

Converts text anchors into links.

public autoP

string Text::autoP ( string $str );

Automatically applies

and
markup to text. Basically nl2br() on steroids.

public bytes

string Text::bytes ( integer $bytes [, string $force_unit [, string $format [, boolean $si ]]] );

Returns human readable sizes.

public camel2lc

string Text::camel2lc ( string $name );

Convert a CamelCaps or camelCase name into a lower_case names

public censor

string Text::censor ( string $str , array $badwords [, string $replacement [, boolean $replace_partial_words ]] );

Replaces the given words with a string.

public containsFormTag

bool Text::containsFormTag ( string $html );

Determines whether given HTML contains a FORM tag, which can cause nested-forms issues

Not tested with malformed input - should not be used as an XSS filter

public copyright

string Text::copyright ( string $year );

Returns current year or original year and current year of copyright

public lc2camelcaps

string Text::lc2camelcaps ( string $name );

Convert a lower_case names into CamelCaps names

public lc2camelcase

string Text::lc2camelcase ( string $name );

Convert a lower_case names into camelCase names

public limitChars

string Text::limitChars ( string $str [, int $limit [, string $end_char [, boolean $preserve_words ]]] );

Limits a plain-text phrase to a given number of characters.

public limitWords

string Text::limitWords ( string $str [, int $limit [, string $end_char ]] );

Limits a plain-text phrase to a given number of words.

public limitWordsHtml

unknown Text::limitWordsHtml ( mixed $text [, mixed $limit ] );

Limits HTML to a certain number of words.
Is aware of tags etc and will not count them in the word-count, as well as closing them properly.

This doesn't actually pass all unit tests at the moment - an exact match in num words will still put in ... part.

public limitedSubsetHtml

string Text::limitedSubsetHtml ( string $html );

Encode HTML so it's suitable for direct output, but allow some HTML tags to be left as-is

Only a limited subset of tags are left alone, all other tags are stripped.
Allowed tags: A, B, I, STRONG, EM, BR, IMG, SPAN, ABBR, SUP, SUB

The algorithm used in this method is quite simple, so this method should not be used
as a defence against XSS attacks; it should only be used on trusted input such as Form helptext.

public ordinalize

unknown Text::ordinalize ( mixed $number );

Returns a number with an english suffix appended (e.g. 1st, 5th, 12th, 123rd)

public plain

string Text::plain ( string $html [, int $max_words ] );

Make a chunk of valid HTML into plain text, and (optionally) limit the number of words.

public reduceSlashes

string Text::reduceSlashes ( string $str );

Reduces multiple slashes in a string to single slashes.

public richtext

string Text::richtext ( string $text [, string $block_elem ] );

Make a chunk of plain text into HTML rich text
The text will be wrapped within a block element (default is a P tag)

public similar

string Text::similar ( array $words );

Finds the text that is similar between a set of words.

public widont

string Text::widont ( string $str );

Prevents widow words by inserting a non-breaking space between the last two words.