Elgg
Version 3.0
|
Go to the source code of this file.
Namespaces | |
Elgg | |
Configuration exception. | |
Functions | |
elgg_format_html ($html, array $options=[]) | |
Prepare HTML output. More... | |
parse_urls ($text) | |
Takes a string and turns any URLs into formatted links. More... | |
elgg_parse_emails ($text) | |
Takes a string and turns any email addresses into formatted links. More... | |
elgg_autop ($string) | |
Create paragraphs from text with line spacing. More... | |
elgg_get_excerpt ($text, $num_chars=250) | |
Returns an excerpt. More... | |
elgg_format_bytes ($size, $precision=2) | |
Format bytes to a human readable format. More... | |
elgg_format_attributes (array $attrs=[]) | |
Converts an associative array into a string of well-formed HTML/XML attributes Returns a concatenated string of HTML attributes to be inserted into a tag (e.g., <tag $attrs>) More... | |
elgg_format_element ($tag_name, array $attributes=[], $text= '', array $options=[]) | |
Format an HTML element. More... | |
elgg_normalize_url ($url) | |
elgg_normalize_site_url ($unsafe_url) | |
From untrusted input, get a site URL safe for forwarding. More... | |
elgg_get_friendly_title ($title) | |
When given a title, returns a version suitable for inclusion in a URL. More... | |
elgg_get_friendly_time ($time, $current_time=null) | |
Formats a UNIX timestamp in a friendly way (eg "less than a minute ago") More... | |
elgg_get_friendly_upload_error ($error_code) | |
Returns a human-readable message for PHP's upload error codes. More... | |
elgg_strip_tags ($string, $allowable_tags=null) | |
Strip tags and offer plugins the chance. More... | |
elgg_html_decode ($string) | |
Decode HTML markup into a raw text string. More... | |
_elgg_get_display_query ($string) | |
Prepares query string for output to prevent CSRF attacks. More... | |
_elgg_sane_validate_url ($url) | |
Use a "fixed" filter_var() with FILTER_VALIDATE_URL that handles multi-byte chars. More... | |
_elgg_get_display_query | ( | $string | ) |
Prepares query string for output to prevent CSRF attacks.
string | $string | string to prepare |
Definition at line 431 of file output.php.
_elgg_sane_validate_url | ( | $url | ) |
Use a "fixed" filter_var() with FILTER_VALIDATE_URL that handles multi-byte chars.
string | $url | URL to validate |
Definition at line 449 of file output.php.
elgg_autop | ( | $string | ) |
Create paragraphs from text with line spacing.
string | $string | The string |
Definition at line 58 of file output.php.
elgg_format_attributes | ( | array | $attrs = [] | ) |
Converts an associative array into a string of well-formed HTML/XML attributes Returns a concatenated string of HTML attributes to be inserted into a tag (e.g., <tag $attrs>)
array | $attrs | Attributes An array of attribute => value pairs Attribute value can be a scalar value, an array of scalar values, or true $attrs = array( 'class' => ['elgg-input', 'elgg-input-text'], // will be imploded with spaces 'style' => ['margin-left:10px;', 'color: #666;'], // will be imploded with spaces 'alt' => 'Alt text', // will be left as is 'disabled' => true, // will be converted to disabled="disabled" 'data-options' => json_encode(['foo' => 'bar']), // will be output as an escaped JSON string 'batch' => <>, // will be ignored 'items' => [<>], // will be ignored ); |
Definition at line 134 of file output.php.
elgg_format_bytes | ( | $size, | |
$precision = 2 |
|||
) |
Format bytes to a human readable format.
int | $size | File size in bytes to format |
int | $precision | Precision to round formatting bytes to |
Definition at line 94 of file output.php.
elgg_format_element | ( | $tag_name, | |
array | $attributes = [] , |
||
$text = '' , |
|||
array | $options = [] |
||
) |
Format an HTML element.
string | array | $tag_name | The element tagName. e.g. "div". This will not be validated. All function arguments can be given as a single array: The array will be used as $attributes, except for the keys "#tag_name", "#text", and "#options", which will be extracted as the other arguments. |
array | $attributes | The element attributes. This is passed to elgg_format_attributes(). |
string | $text | The contents of the element. Assumed to be HTML unless encode_text is true. |
array | $options | Options array with keys: |
encode_text => (bool, default false) If true, $text will be HTML-escaped. Already-escaped entities will not be double-escaped.
double_encode => (bool, default false) If true, the $text HTML escaping will be allowed to double encode HTML entities: '×' will become '×'
is_void => (bool) If given, this determines whether the function will return just the open tag. Otherwise this will be determined by the tag name according to this list: http://www.w3.org/html/wg/drafts/html/master/single-page.html#void-elements
is_xml => (bool, default false) If true, void elements will be formatted like "<tag />"
InvalidArgumentException |
Definition at line 168 of file output.php.
elgg_format_html | ( | $html, | |
array | $options = [] |
||
) |
Prepare HTML output.
string | $html | HTML string |
array | $options | Formatting options |
bool $parse_urls Replace URLs with anchor tags bool $parse_emails Replace email addresses with anchor tags bool $sanitize Sanitize HTML tags bool $autop Add paragraphs instead of new lines
Definition at line 23 of file output.php.
elgg_get_excerpt | ( | $text, | |
$num_chars = 250 |
|||
) |
Returns an excerpt.
Will return up to n chars stopping at the nearest space. If no spaces are found (like in Japanese) will crop off at the n char mark. Adds ... if any text was chopped.
string | $text | The full text to excerpt |
int | $num_chars | Return a string up to $num_chars long |
Definition at line 74 of file output.php.
elgg_get_friendly_time | ( | $time, | |
$current_time = null |
|||
) |
Formats a UNIX timestamp in a friendly way (eg "less than a minute ago")
int | $time | A UNIX epoch timestamp |
int | $current_time | Current UNIX epoch timestamp (optional) |
Definition at line 286 of file output.php.
elgg_get_friendly_title | ( | $title | ) |
When given a title, returns a version suitable for inclusion in a URL.
string | $title | The title |
Definition at line 258 of file output.php.
elgg_get_friendly_upload_error | ( | $error_code | ) |
Returns a human-readable message for PHP's upload error codes.
int | $error_code | The code as stored in $_FILES['name']['error'] |
Definition at line 336 of file output.php.
elgg_html_decode | ( | $string | ) |
Decode HTML markup into a raw text string.
This applies html_entity_decode() to a string while re-entitising HTML special char entities to prevent them from being decoded back to their unsafe original forms.
This relies on html_entity_decode() not translating entities when doing so leaves behind another entity, e.g. > if decoded would create > which is another entity itself. This seems to escape the usual behaviour where any two paired entities creating a HTML tag are usually decoded, i.e. a lone > is not decoded, but <foo> would be decoded to <foo> since it creates a full tag.
Note: html_entity_decode() is poorly explained in the manual - which is really bad given its potential for misuse on user input already escaped elsewhere. Stackoverflow is littered with advice to use this function in the precise way that would lead to user input being capable of injecting arbitrary HTML.
string | $string | Encoded HTML |
Definition at line 419 of file output.php.
elgg_normalize_site_url | ( | $unsafe_url | ) |
From untrusted input, get a site URL safe for forwarding.
string | $unsafe_url | URL from untrusted input |
Definition at line 237 of file output.php.
elgg_normalize_url | ( | $url | ) |
Definition at line 186 of file output.php.
elgg_parse_emails | ( | $text | ) |
Takes a string and turns any email addresses into formatted links.
string | $text | The input string |
Definition at line 47 of file output.php.
elgg_strip_tags | ( | $string, | |
$allowable_tags = null |
|||
) |
Strip tags and offer plugins the chance.
Plugins register for output:strip_tags plugin hook. Original string included in $params['original_string']
string | $string | Formatted string |
string | $allowable_tags | Optional parameter to specify tags which should not be stripped |
Definition at line 388 of file output.php.
parse_urls | ( | $text | ) |
Takes a string and turns any URLs into formatted links.
string | $text | The input string |
Definition at line 34 of file output.php.