class Text (View source)

Methods

static string
encodePath(string $path)

URL-encodes collection path.

static bool
match(string $pattern, string $value)

Determine if a given string matches a given pattern.

string
slugSafeString(string $handle, int $maxlength = 128)

Remove unsafe characters for URL slug.

string
sanitize(string $string, int $max_length, string $allowed = '')

Strips tags and optionally reduces string to specified length.

string
email(string $email)

Leaves only characters that are valid in email addresses (RFC).

string
alphanum(string $string)

Leaves only characters that are alpha-numeric.

string
entities(string $v)

always use in place of htmlentites(), so it works with different languages.

string
decodeEntities(string $v)

Decodes html-encoded entities (for instance: from '>' to '>').

string
specialchars($v)

A concrete5 specific version of htmlspecialchars(). Double encoding is OFF, and the character set is set to your site's.

string
shorten(string $textStr, int $numChars = 255, string $tail = '…')

An alias for shorten().

string
shortText(string $textStr, int $numChars = 255, string $tail = '…')

Like sanitize, but requiring a certain number characters, and assuming a tail.

string
camelcase(string $string)

Takes a string and turns it into the CamelCase or StudlyCaps version.

string
twitterAutolink(string $input, int $newWindow, int $withSearch)

automatically add hyperlinks to any twitter style @usernames in a string.

string
makenice(string $input)

Runs a number of text functions, including autolink, nl2br, strip_tags. Assumes that you want simple text comments but with a few niceties.

prettyStripTags($input, $allowedTags = null)

Runs strip_tags but ensures that spaces are kept between the stripped tags.

string
autolink(string $input, bool $newWindow = false, string $defaultProtocol = 'http://')

Scans passed text and automatically hyperlinks any URL inside it.

bool
fnmatch(string $pattern, string $string)

A wrapper for PHP's fnmatch() function, which some installations don't have.

string
uncamelcase(string $string)

Takes a CamelCase string and turns it into camel_case.

string
unhandle(string $string)

Takes a handle-based string like "blah_blah" or "blah-blah" or "blah/blah" and turns it into "Blah Blah".

string
handle($handle, bool $leaveSlashes = false)

Takes a string and turns it into a handle.

string
sanitizeFileSystem(string $handle)

No description

string
urlify(string $handle, int $max_length = null, string $locale = '', bool $removeExcludedWords = true)

Takes text and returns it in the "lowercase-and-dashed-with-no-punctuation" format.

string
asciify(string $text, string $locale = '')

Takes text and converts it to an ASCII-only string (characters with code between 32 and 127, plus \t, \n and \r).

string
wordSafeShortText(string $textStr, int $numChars = 255, string $tail = '…')

alias of shortenTextWord().

string
shortenTextWord($textStr, int $numChars = 255, string $tail = '…')

Shortens and sanitizes a string but only cuts at word boundaries.

string
filterNonAlphaNum(string $val)

Strips out non-alpha-numeric characters.

string
highlightSearch(string $value, string $searchString)

Highlights a string within a string with the class ccm-highlight-search.

string
formatXML($xml)

Formats a passed XML string nicely.

appendXML(SimpleXMLElement $root, SimpleXMLElement $new)

Appends a SimpleXMLElement to a SimpleXMLElement.

Details

static string encodePath(string $path)

URL-encodes collection path.

Parameters

string $path

Return Value

string $path

static bool match(string $pattern, string $value)

Determine if a given string matches a given pattern.

Parameters

string $pattern
string $value

Return Value

bool

string slugSafeString(string $handle, int $maxlength = 128)

Remove unsafe characters for URL slug.

Parameters

string $handle
int $maxlength = Max number of characters of the return value

Return Value

string $handle

string sanitize(string $string, int $max_length, string $allowed = '')

Strips tags and optionally reduces string to specified length.

Parameters

string $string
int $max_length
string $allowed

Return Value

string

string email(string $email)

Leaves only characters that are valid in email addresses (RFC).

Parameters

string $email

Return Value

string

string alphanum(string $string)

Leaves only characters that are alpha-numeric.

Parameters

string $string

Return Value

string

string entities(string $v)

always use in place of htmlentites(), so it works with different languages.

Parameters

string $v

Return Value

string

string decodeEntities(string $v)

Decodes html-encoded entities (for instance: from '>' to '>').

Parameters

string $v

Return Value

string

string specialchars($v)

A concrete5 specific version of htmlspecialchars(). Double encoding is OFF, and the character set is set to your site's.

Parameters

$v

Return Value

string

string shorten(string $textStr, int $numChars = 255, string $tail = '…')

An alias for shorten().

Parameters

string $textStr
int $numChars
string $tail

Return Value

string

string shortText(string $textStr, int $numChars = 255, string $tail = '…')

Like sanitize, but requiring a certain number characters, and assuming a tail.

Parameters

string $textStr
int $numChars
string $tail

Return Value

string $textStr

string camelcase(string $string)

Takes a string and turns it into the CamelCase or StudlyCaps version.

Parameters

string $string

Return Value

string

automatically add hyperlinks to any twitter style @usernames in a string.

Parameters

string $input
int $newWindow
int $withSearch

Return Value

string $output

string makenice(string $input)

Runs a number of text functions, including autolink, nl2br, strip_tags. Assumes that you want simple text comments but with a few niceties.

Parameters

string $input

Return Value

string $output

prettyStripTags($input, $allowedTags = null)

Runs strip_tags but ensures that spaces are kept between the stripped tags.

Parameters

$input
$allowedTags

Scans passed text and automatically hyperlinks any URL inside it.

Parameters

string $input
bool $newWindow
string $defaultProtocol

Return Value

string $output

bool fnmatch(string $pattern, string $string)

A wrapper for PHP's fnmatch() function, which some installations don't have.

Parameters

string $pattern
string $string

Return Value

bool

string uncamelcase(string $string)

Takes a CamelCase string and turns it into camel_case.

Parameters

string $string

Return Value

string

string unhandle(string $string)

Takes a handle-based string like "blah_blah" or "blah-blah" or "blah/blah" and turns it into "Blah Blah".

Parameters

string $string

Return Value

string $r1

string handle($handle, bool $leaveSlashes = false)

Takes a string and turns it into a handle.

Parameters

$handle
bool $leaveSlashes

Return Value

string

string sanitizeFileSystem(string $handle)

Parameters

string $handle

Return Value

string $handle

string urlify(string $handle, int $max_length = null, string $locale = '', bool $removeExcludedWords = true)

Takes text and returns it in the "lowercase-and-dashed-with-no-punctuation" format.

Parameters

string $handle
int $max_length Max number of characters of the return value
string $locale Language code of the language rules that should be priorized
bool $removeExcludedWords Set to true to remove excluded words, false to allow them.

Return Value

string

string asciify(string $text, string $locale = '')

Takes text and converts it to an ASCII-only string (characters with code between 32 and 127, plus \t, \n and \r).

Parameters

string $text The text to be converted.
string $locale ='' The locale for the string. If not specified we consider the current locale.

Return Value

string

string wordSafeShortText(string $textStr, int $numChars = 255, string $tail = '…')

alias of shortenTextWord().

Parameters

string $textStr
int $numChars
string $tail

Return Value

string

string shortenTextWord($textStr, int $numChars = 255, string $tail = '…')

Shortens and sanitizes a string but only cuts at word boundaries.

Parameters

$textStr
int $numChars
string $tail

Return Value

string

string filterNonAlphaNum(string $val)

Strips out non-alpha-numeric characters.

Parameters

string $val

Return Value

string

string highlightSearch(string $value, string $searchString)

Highlights a string within a string with the class ccm-highlight-search.

Parameters

string $value
string $searchString

Return Value

string

string formatXML($xml)

Formats a passed XML string nicely.

Parameters

$xml

Return Value

string

appendXML(SimpleXMLElement $root, SimpleXMLElement $new)

Appends a SimpleXMLElement to a SimpleXMLElement.

Parameters

SimpleXMLElement $root
SimpleXMLElement $new