Library of conversion functions, implemented as static methods.
The methods are all of the form (format)2(format), where the format is one
of
raw: A UTF8 string attr: A UTF8 string suitable for inclusion in an HTML
attribute js: A UTF8 string suitable for inclusion in a double-quoted javascript
string.
array: A PHP associative array json: JavaScript object notation
html: HTML source suitable for use in a page or email text: Plain-text content,
suitable for display to a user as-is, or insertion in a plaintext email.
Objects of type ViewableData can have an "escaping type", which
determines if they are automatically escaped before output by SSViewer.
public static
array|string
|
#
raw2att( array|string $val )
Convert a value to be suitable for an XML attribute.
Convert a value to be suitable for an XML attribute.
Parameters
- $val
- array|string $val String to escape, or array of strings
Returns
array|string array|string
Used by
|
public static
array|string
|
#
raw2htmlatt( array|string $val )
Convert a value to be suitable for an HTML attribute.
Convert a value to be suitable for an HTML attribute.
This is useful for converting human readable values into a value suitable for
an ID or NAME attribute.
Parameters
- $val
- array|string $val String to escape, or array of strings
Returns
array|string array|string
See
Uses
|
public static
array|string
|
#
raw2xml( array|string $val )
Ensure that text is properly escaped for XML.
Ensure that text is properly escaped for XML.
Parameters
- $val
- array|string $val String to escape, or array of strings
Returns
array|string array|string
See
|
public static
array|string
|
#
raw2js( array|string $val )
Ensure that text is properly escaped for Javascript.
Ensure that text is properly escaped for Javascript.
Parameters
- $val
- array|string $val String to escape, or array of strings
Returns
array|string array|string
|
public static
string
|
#
raw2json( mixed $val )
Uses the PHP 5.2 native json_encode function if available, otherwise falls
back to the Services_JSON class.
Uses the PHP 5.2 native json_encode function if available, otherwise falls
back to the Services_JSON class.
Parameters
Returns
string JSON safe string
See
Uses
|
public static
|
|
public static
|
#
xml2raw( mixed $val )
Convert XML to raw text.
Uses
|
public static
string
|
#
array2json( array $val )
Convert an array into a JSON encoded string.
Convert an array into a JSON encoded string.
Parameters
- $val
- array $val Array to convert
Returns
string JSON encoded string
See
Uses
|
public static
mixed
|
#
json2obj( string $val )
Convert a JSON encoded string into an object.
Convert a JSON encoded string into an object.
Parameters
Returns
mixed JSON safe string
See
Uses
Used by
|
public static
array|boolean
|
#
json2array( string $val )
Convert a JSON string into an array.
Convert a JSON string into an array.
Parameters
- $val
- string $val JSON string to convert
Returns
array|boolean array|boolean
Uses
|
public static
|
|
protected static
|
|
public static
A
|
#
linkIfMatch( string $string )
Create a link if the string is a valid URL
Create a link if the string is a valid URL
Parameters
- $string
- string The string to linkify
Returns
A link to the URL if string is a URL
|
public static
|
#
html2raw( mixed $data, mixed $preserveLinks = false, mixed $wordWrap = 0, mixed $config = null )
Simple conversion of HTML to plaintext.
Simple conversion of HTML to plaintext.
Parameters
- $data
- $data string
- $preserveLinks
- $preserveLinks boolean
- $wordWrap
- $wordwrap array
- $config
Used by
|
public static
string
|
#
raw2mailto( mixed $data )
There are no real specifications on correctly encoding mailto-links, but this
seems to be compatible with most of the user-agents. Does nearly the same as
rawurlencode(). Please only encode the values, not the whole url, e.g.
"mailto:test@test.com?subject=" . Convert::raw2mailto($subject)
There are no real specifications on correctly encoding mailto-links, but this
seems to be compatible with most of the user-agents. Does nearly the same as
rawurlencode(). Please only encode the values, not the whole url, e.g.
"mailto:test@test.com?subject=" . Convert::raw2mailto($subject)
Parameters
Returns
string string
See
|
public static
|
|
public static
string
|
#
number2name( mixed $num, mixed $name1, mixed $name2_4, mixed $nameOther )
Generate correct name of object for integer number of object
Generate correct name of object for integer number of object
Parameters
- $num
- $num int number of object
- $name1
- $name1 string name for *[1] object
- $name2_4
- $name2_4 string name for *[2-4] objects
- $nameOther
- $nameOther string name for 11-19, *[0,5-9] objects
Returns
string string
|