30 $r = preg_replace_callback(
'/(?<![=\/"\'])((ht|f)tps?:\/\/[^\s\r\n\t<>"\']+)/i',
36 $last = substr($url, -1, 1); 37 if (in_array($last, array(".", "!", ",", "(", ")"))) { 39 $url = rtrim($url, ".!,()"); 41 $urltext = str_replace("/", "/<wbr />", $url); 42 return "<a href=\"$url\" rel=\"nofollow\">$urltext</a>$punc"; 76 if ($string_length <= $num_chars) {
85 if ($space ===
false) {
106 return preg_replace(
'/&(?!amp;)/',
'&',
$url);
124 $base = log(
$size) / log(1024);
125 $suffixes = array(
'B',
'kB',
'MB',
'GB',
'TB');
127 return round(pow(1024, $base - floor($base)), $precision) .
' ' . $suffixes[floor($base)];
147 if (isset(
$attrs[
'js'])) {
150 if (!empty(
$attrs[
'js'])) {
157 foreach (
$attrs as $attr => $val) {
158 $attr = strtolower($attr);
175 if ($val !== NULL && $val !==
false && (is_array($val) || !is_object($val))) {
176 if (is_array($val)) {
177 $val = implode(
' ', $val);
180 $val = htmlspecialchars($val, ENT_QUOTES,
'UTF-8',
false);
216 if (!is_string($tag_name)) {
217 throw new \InvalidArgumentException(
'$tag_name is required');
224 $is_void = in_array(strtolower($tag_name), array(
225 'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'menuitem',
226 'meta',
'param',
'source',
'track',
'wbr' 230 if (!empty(
$options[
'encode_text'])) {
231 $double_encode = empty(
$options[
'double_encode']) ?
false :
true;
232 $text = htmlspecialchars(
$text, ENT_QUOTES,
'UTF-8', $double_encode);
245 return empty(
$options[
'is_xml']) ?
"<{$tag_name}{$attrs}>" :
"<{$tag_name}{$attrs} />";
247 return "<{$tag_name}{$attrs}>$text</$tag_name>";
266 unset(
$vars[
'config']);
268 unset(
$vars[
'user']);
271 if (isset(
$vars[
'internalname'])) {
272 if (!isset(
$vars[
'__ignoreInternalname'])) {
275 unset(
$vars[
'internalname']);
278 if (isset(
$vars[
'internalid'])) {
279 if (!isset(
$vars[
'__ignoreInternalid'])) {
282 unset(
$vars[
'internalid']);
285 if (isset(
$vars[
'__ignoreInternalid'])) {
286 unset(
$vars[
'__ignoreInternalid']);
289 if (isset(
$vars[
'__ignoreInternalname'])) {
290 unset(
$vars[
'__ignoreInternalname']);
314 $php_5_2_13_and_below = version_compare(PHP_VERSION,
'5.2.14',
'<');
315 $php_5_3_0_to_5_3_2 = version_compare(PHP_VERSION,
'5.3.0',
'>=') &&
316 version_compare(PHP_VERSION,
'5.3.3',
'<');
318 if ($php_5_2_13_and_below || $php_5_3_0_to_5_3_2) {
319 $tmp_address = str_replace(
"-",
"",
$url);
320 $validated = filter_var($tmp_address, FILTER_VALIDATE_URL);
322 $validated = filter_var(
$url, FILTER_VALIDATE_URL);
326 if (!$validated && (strpos(
$url,
'http:') === 0) || (strpos(
$url,
'https:') === 0)) {
334 } elseif (preg_match(
"#^(\#|\?|//)#i",
$url)) {
339 } elseif (stripos(
$url,
'javascript:') === 0 || stripos(
$url,
'mailto:') === 0) {
344 } elseif (preg_match(
"#^[^/]*\.php(\?.*)?$#i",
$url)) {
348 } elseif (preg_match(
"#^[^/?]*\.#i",
$url)) {
350 return "http://$url";
379 $title = html_entity_decode(
$title, ENT_QUOTES,
'UTF-8');
399 if (!$current_time) {
400 $current_time = time();
404 $params = array(
'time' => $time,
'current_time' => $current_time);
410 $diff = abs((
int)$current_time - (
int)$time);
413 $hour = $minute * 60;
416 if ($diff < $minute) {
417 return elgg_echo(
"friendlytime:justnow");
421 $granularity =
':minutes';
422 $diff = round($diff / $minute);
423 }
else if ($diff < $day) {
424 $granularity =
':hours';
425 $diff = round($diff / $hour);
427 $granularity =
':days';
428 $diff = round($diff / $day);
435 $future = ((int)$current_time - (
int)$time < 0) ?
':future' :
'';
436 $singular = ($diff == 1) ?
':singular' :
'';
438 return elgg_echo(
"friendlytime{$future}{$granularity}{$singular}", array($diff));
448 switch ($error_code) {
452 case UPLOAD_ERR_INI_SIZE:
456 case UPLOAD_ERR_FORM_SIZE:
460 case UPLOAD_ERR_PARTIAL:
464 case UPLOAD_ERR_NO_FILE:
468 case UPLOAD_ERR_NO_TMP_DIR:
472 case UPLOAD_ERR_CANT_WRITE:
476 case UPLOAD_ERR_EXTENSION:
501 $params[
'allowable_tags'] = $allowable_tags;
538 array(
'>',
'<',
'&',
'"',
'''),
539 array(
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'),
544 array(
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'),
545 array(
'>',
'<',
'&',
'"',
'''),
561 if (function_exists(
'mb_convert_encoding')) {
562 $display_query = mb_convert_encoding(
$string,
'HTML-ENTITIES',
'UTF-8');
565 $display_query = preg_replace(
"/[^\x01-\x7F]/",
"",
$string);
567 return htmlspecialchars($display_query, ENT_QUOTES,
'UTF-8',
false);
583 $value[] =
"{$CONFIG->path}engine/tests/ElggCoreOutputAutoPTest.php";
598 $events->registerHandler(
'init',
'system',
'_elgg_output_init');
parse_urls($text)
Takes a string and turns any URLs into formatted links.
elgg_strip_tags($string, $allowable_tags=null)
Strip tags and offer plugins the chance.
_elgg_get_display_query($string)
Prepares query string for output to prevent CSRF attacks.
elgg_register_plugin_hook_handler($hook, $type, $callback, $priority=500)
_elgg_clean_vars(array $vars=array())
Preps an associative array for use in elgg_format_attributes().
elgg_get_friendly_upload_error($error_code)
Returns a human-readable message for PHP's upload error codes.
elgg_format_element($tag_name, array $attributes=array(), $text= '', array $options=array())
Format an HTML element.
elgg_strlen()
Wrapper function for mb_strlen().
elgg_strrpos()
Wrapper function for mb_strrpos().
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_autop($string)
Create paragraphs from text with line spacing.
static urlize($string, $separator= '-')
Create a version of a string for embedding in a URL.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Log a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
elgg_format_bytes($size, $precision=2)
Format bytes to a human readable format.
elgg_get_site_url($site_guid=0)
Get the URL for the current (or specified) site.
_elgg_html_decode($string)
Apply html_entity_decode() to a string while re-entitising HTML special char entities to prevent them...
elgg_format_attributes(array $attrs=array())
Converts an associative array into a string of well-formed attributes.
_elgg_output_unit_test($hook, $type, $value, $params)
Unit tests for Output.
elgg_substr()
Wrapper function for mb_substr().
elgg_get_friendly_time($time, $current_time=null)
Formats a UNIX timestamp in a friendly way (eg "less than a minute ago")
elgg_get_excerpt($text, $num_chars=250)
Returns an excerpt.
elgg_format_url($url)
Handles formatting of ampersands in urls.
elgg_get_friendly_title($title)
When given a title, returns a version suitable for inclusion in a URL.
if(file_exists($welcome)) $vars
_elgg_output_init()
Initialize the output subsystem.