Elgg  Version 1.11
Namespaces | Functions | Variables
output.php File Reference

Go to the source code of this file.

Namespaces

 Elgg
 Save menu items.
 

Functions

 parse_urls ($text)
 Takes a string and turns any URLs 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_url ($url)
 Handles formatting of ampersands in urls. More...
 
 elgg_format_bytes ($size, $precision=2)
 Format bytes to a human readable format. More...
 
 elgg_format_attributes (array $attrs=array())
 Converts an associative array into a string of well-formed attributes. More...
 
 elgg_format_element ($tag_name, array $attributes=array(), $text= '', array $options=array())
 Format an HTML element. More...
 
 _elgg_clean_vars (array $vars=array())
 Preps an associative array for use in elgg_format_attributes(). More...
 
 elgg_normalize_url ($url)
 
 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)
 Apply 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. More...
 
 _elgg_get_display_query ($string)
 Prepares query string for output to prevent CSRF attacks. More...
 
 _elgg_output_unit_test ($hook, $type, $value, $params)
 Unit tests for Output. More...
 
 _elgg_output_init ()
 Initialize the output subsystem. More...
 

Variables

return function (\Elgg\EventsService $events,\Elgg\HooksRegistrationService $hooks)
 

Function Documentation

_elgg_clean_vars ( array  $vars = array())

Preps an associative array for use in elgg_format_attributes().

Removes all the junk that elgg_view() puts into $vars. Maintains backward compatibility with attributes like 'internalname' and 'internalid'

Note
This function is called automatically by elgg_format_attributes(). No need to call it yourself before using elgg_format_attributes().
Parameters
array$varsThe raw $vars array with all it's dirtiness (config, url, etc.)
Returns
array The array, ready to be used in elgg_format_attributes(). private
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 265 of file output.php.

_elgg_get_display_query (   $string)

Prepares query string for output to prevent CSRF attacks.

Parameters
string$string
Returns
string

private

Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 559 of file output.php.

_elgg_html_decode (   $string)

Apply 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. &gt; 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: This function 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.

Parameters
string$string
Returns
string
Author
Pádraic Brady

private

Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 536 of file output.php.

_elgg_output_init ( )

Initialize the output subsystem.

Returns
void private
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 593 of file output.php.

_elgg_output_unit_test (   $hook,
  $type,
  $value,
  $params 
)

Unit tests for Output.

Parameters
string$hookunit_test
string$typesystem
mixed$valueArray of tests
mixed$paramsParams
Returns
array private
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 581 of file output.php.

elgg_autop (   $string)

Create paragraphs from text with line spacing.

Parameters
string$stringThe string
Returns
string
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 56 of file output.php.

elgg_format_attributes ( array  $attrs = array())

Converts an associative array into a string of well-formed attributes.

Note
usually for HTML, but could be useful for XML too...
Parameters
array$attrsAn associative array of attr => val pairs
Returns
string HTML attributes to be inserted into a tag (e.g., <tag $attrs>)

Ignore non-array values and allow attribute values to be an array $attrs = array( 'entity' => <>, // will be ignored 'class' => array('elgg-input', 'elgg-input-text'), // will be imploded with spaces 'style' => array('margin-left:10px;', 'color: #666;'), // will be imploded with spaces 'alt' => 'Alt text', // will be left as is );

Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 139 of file output.php.

elgg_format_bytes (   $size,
  $precision = 2 
)

Format bytes to a human readable format.

Parameters
int$sizeFile size in bytes to format
int$precisionPrecision to round formatting bytes to
Returns
string
Since
1.9.0
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 119 of file output.php.

elgg_format_element (   $tag_name,
array  $attributes = array(),
  $text = '',
array  $options = array() 
)

Format an HTML element.

Parameters
string$tag_nameThe element tagName. e.g. "div". This will not be validated.
array$attributesThe element attributes. This is passed to elgg_format_attributes().
string$textThe contents of the element. Assumed to be HTML unless encode_text is true.
array$optionsOptions 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 '&times;'

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 />"

Returns
string
Exceptions
InvalidArgumentException
Since
1.9.0
Examples:
/root/Elgg/engine/lib/output.php, and /root/Elgg/engine/lib/views.php.

Definition at line 215 of file output.php.

elgg_format_url (   $url)

Handles formatting of ampersands in urls.

Parameters
string$urlThe URL
Returns
string
Since
1.7.1
Examples:
/root/Elgg/engine/lib/output.php, and /root/Elgg/engine/lib/views.php.

Definition at line 105 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.

Parameters
string$textThe full text to excerpt
int$num_charsReturn a string up to $num_chars long
Returns
string
Since
1.7.2
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 72 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")

See also
elgg_view_friendly_time()
Parameters
int$timeA UNIX epoch timestamp
int$current_timeCurrent UNIX epoch timestamp (optional)
Returns
string The friendly time string
Since
1.7.2
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 397 of file output.php.

elgg_get_friendly_title (   $title)

When given a title, returns a version suitable for inclusion in a URL.

Parameters
string$titleThe title
Returns
string The optimized title
Since
1.7.2
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 369 of file output.php.

elgg_get_friendly_upload_error (   $error_code)

Returns a human-readable message for PHP's upload error codes.

Parameters
int$error_codeThe code as stored in $_FILES['name']['error']
Returns
string
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 447 of file output.php.

elgg_normalize_url (   $url)
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']

Parameters
string$stringFormatted string
string$allowable_tagsOptional parameter to specify tags which should not be stripped
Returns
string String run through strip_tags() and any plugin hooks.
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 499 of file output.php.

parse_urls (   $text)

Takes a string and turns any URLs into formatted links.

Parameters
string$textThe input string
Returns
string The output string with formatted links
Examples:
/root/Elgg/engine/lib/output.php.

Definition at line 17 of file output.php.

Variable Documentation

Definition at line 597 of file output.php.