19 $linkify = new \Misd\Linkify\Linkify();
21 return $linkify->processUrls(
$text, [
'attr' => [
'rel' =>
'nofollow']]);
34 $linkify = new \Misd\Linkify\Linkify();
36 return $linkify->processEmails(
$text, [
'attr' => [
'rel' =>
'nofollow']]);
63 $view =
'output/excerpt';
82 return preg_replace(
'/&(?!amp;)/',
'&',
$url);
100 $base = log(
$size) / log(1024);
101 $suffixes = array(
'B',
'kB',
'MB',
'GB',
'TB');
103 return round(pow(1024, $base - floor($base)), $precision) .
' ' . $suffixes[floor($base)];
137 if (0 !== strpos(
$attr,
'data-') &&
false !== strpos(
$attr,
'_')) {
144 if (!isset($val) || $val ===
false) {
152 if (is_scalar($val)) {
156 if (!is_array($val)) {
161 $filtered_val = array_filter($val,
function(
$e) {
162 return is_scalar(
$e);
165 if (count($val) != count($filtered_val)) {
169 $val = implode(
' ', $val);
171 $val = htmlspecialchars($val, ENT_QUOTES,
'UTF-8',
false);
209 if (is_array($tag_name)) {
213 throw new \InvalidArgumentException(
'If $tag_name is an array, the other arguments must not be set');
216 if (isset(
$args[
'#tag_name'])) {
217 $tag_name =
$args[
'#tag_name'];
219 if (isset(
$args[
'#text'])) {
222 if (isset(
$args[
'#options'])) {
230 if (!is_string($tag_name) || $tag_name ===
'') {
231 throw new \InvalidArgumentException(
'$tag_name is required');
238 $is_void = in_array(strtolower($tag_name), array(
239 'area',
'base',
'br',
'col',
'embed',
'hr',
'img',
'input',
'keygen',
'link',
'menuitem',
240 'meta',
'param',
'source',
'track',
'wbr' 244 if (!empty(
$options[
'encode_text'])) {
245 $double_encode = empty(
$options[
'double_encode']) ?
false :
true;
246 $text = htmlspecialchars(
$text, ENT_QUOTES,
'UTF-8', $double_encode);
259 return empty(
$options[
'is_xml']) ?
"<{$tag_name}{$attrs}>" :
"<{$tag_name}{$attrs} />";
261 return "<{$tag_name}{$attrs}>$text</$tag_name>";
281 $url = str_replace(
' ',
'%20',
$url);
287 if (preg_match(
"#^([a-z]+)\\:#",
$url,
$m)) {
290 if (
$m[1] !==
'http' &&
$m[1] !==
'https') {
295 if (preg_match(
"#^(\\#|\\?|//)#",
$url)) {
300 if (preg_match(
"#^[^/]*\\.php(\\?.*)?$#",
$url)) {
306 if (preg_match(
"#^[^/?]*\\.#",
$url)) {
308 return "http://$url";
327 if (!is_string($unsafe_url)) {
357 $title = html_entity_decode(
$title, ENT_QUOTES,
'UTF-8');
377 if (!$current_time) {
378 $current_time =
time();
382 $params = array(
'time' => $time,
'current_time' => $current_time);
388 $diff = abs((
int)$current_time - (
int)$time);
391 $hour = $minute * 60;
394 if ($diff < $minute) {
395 return elgg_echo(
"friendlytime:justnow");
399 $granularity =
':minutes';
400 $diff = round($diff / $minute);
401 }
else if ($diff < $day) {
402 $granularity =
':hours';
403 $diff = round($diff / $hour);
405 $granularity =
':days';
406 $diff = round($diff / $day);
413 $future = ((int)$current_time - (
int)$time < 0) ?
':future' :
'';
414 $singular = ($diff == 1) ?
':singular' :
'';
416 return elgg_echo(
"friendlytime{$future}{$granularity}{$singular}", array($diff));
426 switch ($error_code) {
430 case UPLOAD_ERR_INI_SIZE:
434 case UPLOAD_ERR_FORM_SIZE:
438 case UPLOAD_ERR_PARTIAL:
442 case UPLOAD_ERR_NO_FILE:
446 case UPLOAD_ERR_NO_TMP_DIR:
450 case UPLOAD_ERR_CANT_WRITE:
454 case UPLOAD_ERR_EXTENSION:
479 $params[
'allowable_tags'] = $allowable_tags;
516 array(
'>',
'<',
'&',
'"',
'''),
517 array(
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'),
522 array(
'&gt;',
'&lt;',
'&amp;',
'&quot;',
'&#039;'),
523 array(
'>',
'<',
'&',
'"',
'''),
555 if (function_exists(
'mb_convert_encoding')) {
556 $display_query = mb_convert_encoding(
$string,
'HTML-ENTITIES',
'UTF-8');
559 $display_query = preg_replace(
"/[^\x01-\x7F]/",
"",
$string);
561 return htmlspecialchars($display_query, ENT_QUOTES,
'UTF-8',
false);
573 $res = filter_var(
$url, FILTER_VALIDATE_URL);
580 if (strlen(
$url) == $l) {
586 for ($i = 0; $i < $l; ++$i) {
588 $s .= (strlen($ch) > 1) ?
'X' : $ch;
592 return filter_var($s, FILTER_VALIDATE_URL) ?
$url :
false;
elgg_view_exists($view, $viewtype= '', $recurse=true)
Returns whether the specified view exists.
parse_urls($text)
Takes a string and turns any URLs into formatted links.
_elgg_sane_validate_url($url)
Use a "fixed" filter_var() with FILTER_VALIDATE_URL that handles multi-byte chars.
elgg_html_decode($string)
Decode HTML markup into a raw text string.
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
elgg_strip_tags($string, $allowable_tags=null)
Strip tags and offer plugins the chance.
elgg_normalize_site_url($unsafe_url)
From untrusted input, get a site URL safe for forwarding.
_elgg_get_display_query($string)
Prepares query string for output to prevent CSRF attacks.
$args
Some servers don't allow PHP to check the rewrite, so try via AJAX.
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_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_parse_emails($text)
Takes a string and turns any email addresses into formatted links.
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_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)
Alias of elgg_html_decode.
elgg_format_attributes(array $attrs=array())
Converts an associative array into a string of well-formed HTML/XML attributes Returns a concatenated...
_elgg_services(\Elgg\Di\ServiceProvider $services=null)
Get the global service provider.
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.
_elgg_view_under_viewtype($view, $vars, $viewtype)
Render a view while the global viewtype is temporarily changed.