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);
126 if (isset(
$attrs[
'js'])) {
129 if (!empty(
$attrs[
'js'])) {
136 foreach (
$attrs as $attr => $val) {
137 $attr = strtolower($attr);
154 if ($val !== NULL && $val !==
false && (is_array($val) || !is_object($val))) {
155 if (is_array($val)) {
156 $val = implode(
' ', $val);
159 $val = htmlspecialchars($val, ENT_QUOTES,
'UTF-8',
false);
195 if (!is_string($tag_name)) {
196 throw new InvalidArgumentException(
'$tag_name is required');
203 $is_void = in_array(strtolower($tag_name), array(
204 'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'menuitem',
205 'meta',
'param',
'source',
'track',
'wbr' 209 if (!empty(
$options[
'encode_text'])) {
210 $double_encode = empty(
$options[
'double_encode']) ?
false :
true;
211 $text = htmlspecialchars(
$text, ENT_QUOTES,
'UTF-8', $double_encode);
224 return empty(
$options[
'is_xml']) ?
"<{$tag_name}{$attrs}>" :
"<{$tag_name}{$attrs} />";
226 return "<{$tag_name}{$attrs}>$text</$tag_name>";
245 unset(
$vars[
'config']);
247 unset(
$vars[
'user']);
250 if (isset(
$vars[
'internalname'])) {
251 if (!isset(
$vars[
'__ignoreInternalname'])) {
254 unset(
$vars[
'internalname']);
257 if (isset(
$vars[
'internalid'])) {
258 if (!isset(
$vars[
'__ignoreInternalid'])) {
261 unset(
$vars[
'internalid']);
264 if (isset(
$vars[
'__ignoreInternalid'])) {
265 unset(
$vars[
'__ignoreInternalid']);
268 if (isset(
$vars[
'__ignoreInternalname'])) {
269 unset(
$vars[
'__ignoreInternalname']);
293 $php_5_2_13_and_below = version_compare(PHP_VERSION,
'5.2.14',
'<');
294 $php_5_3_0_to_5_3_2 = version_compare(PHP_VERSION,
'5.3.0',
'>=') &&
295 version_compare(PHP_VERSION,
'5.3.3',
'<');
297 if ($php_5_2_13_and_below || $php_5_3_0_to_5_3_2) {
298 $tmp_address = str_replace(
"-",
"",
$url);
299 $validated = filter_var($tmp_address, FILTER_VALIDATE_URL);
301 $validated = filter_var(
$url, FILTER_VALIDATE_URL);
305 if (!$validated && (strpos(
$url,
'http:') === 0) || (strpos(
$url,
'https:') === 0)) {
313 } elseif (preg_match(
"#^(\#|\?|//)#i",
$url)) {
318 } elseif (stripos(
$url,
'javascript:') === 0 || stripos(
$url,
'mailto:') === 0) {
323 } elseif (preg_match(
"#^[^/]*\.php(\?.*)?$#i",
$url)) {
327 } elseif (preg_match(
"#^[^/?]*\.#i",
$url)) {
329 return "http://$url";
358 $title = html_entity_decode(
$title, ENT_QUOTES,
'UTF-8');
378 if (!$current_time) {
379 $current_time = time();
383 $params = array(
'time' => $time,
'current_time' => $current_time);
389 $diff = abs((
int)$current_time - (
int)$time);
392 $hour = $minute * 60;
395 if ($diff < $minute) {
396 return elgg_echo(
"friendlytime:justnow");
400 $granularity =
':minutes';
401 $diff = round($diff / $minute);
402 }
else if ($diff < $day) {
403 $granularity =
':hours';
404 $diff = round($diff / $hour);
406 $granularity =
':days';
407 $diff = round($diff / $day);
414 $future = ((int)$current_time - (
int)$time < 0) ?
':future' :
'';
415 $singular = ($diff == 1) ?
':singular' :
'';
417 return elgg_echo(
"friendlytime{$future}{$granularity}{$singular}", array($diff));
427 switch ($error_code) {
431 case UPLOAD_ERR_INI_SIZE:
435 case UPLOAD_ERR_FORM_SIZE:
439 case UPLOAD_ERR_PARTIAL:
443 case UPLOAD_ERR_NO_FILE:
447 case UPLOAD_ERR_NO_TMP_DIR:
451 case UPLOAD_ERR_CANT_WRITE:
455 case UPLOAD_ERR_EXTENSION:
480 $params[
'allowable_tags'] = $allowable_tags;
517 array(
'>',
'<',
'&',
'"',
'''),
518 array(
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'),
523 array(
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'),
524 array(
'>',
'<',
'&',
'"',
'''),
540 if (function_exists(
'mb_convert_encoding')) {
541 $display_query = mb_convert_encoding(
$string,
'HTML-ENTITIES',
'UTF-8');
544 $display_query = preg_replace(
"/[^\x01-\x7F]/",
"",
$string);
546 return htmlspecialchars($display_query, ENT_QUOTES,
'UTF-8',
false);
562 $value[] =
"{$CONFIG->path}engine/tests/ElggCoreOutputAutoPTest.php";
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)
Register a callback as a plugin hook handler.
_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.
elgg_trigger_plugin_hook($hook, $type, $params=null, $returnvalue=null)
Trigger a Plugin Hook and run all handler callbacks registered to that hook:type. ...
elgg_deprecated_notice($msg, $dep_version, $backtrace_level=1)
Sends a notice about deprecated use of a function, view, etc.
elgg global
Pointer to the global context.
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_register_event_handler($event, $object_type, $callback, $priority=500)
Register a callback as an Elgg event handler.
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.
static urlize($string, $separator= '-')
Create a version of a string for embedding in a URL.
if(file_exists($welcome)) $vars
_elgg_output_init()
Initialize the output subsystem.