Elgg  Version 1.9
url.php
Go to the documentation of this file.
1 <?php
16 $url = elgg_extract('href', $vars, null);
17 if (!$url and isset($vars['value'])) {
18  $url = trim($vars['value']);
19  unset($vars['value']);
20 }
21 
22 if (isset($vars['text'])) {
23  if (elgg_extract('encode_text', $vars, false)) {
24  $text = htmlspecialchars($vars['text'], ENT_QUOTES, 'UTF-8', false);
25  } else {
26  $text = $vars['text'];
27  }
28  unset($vars['text']);
29 } else {
30  $text = htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false);
31 }
32 
33 unset($vars['encode_text']);
34 
35 if ($url) {
37 
38  if (elgg_extract('is_action', $vars, false)) {
40  }
41 
42  if (!elgg_extract('is_trusted', $vars, false)) {
43  if (!isset($vars['rel'])) {
44  $vars['rel'] = 'nofollow';
45  $url = strip_tags($url);
46  }
47  }
48 
49  $vars['href'] = $url;
50 }
51 
52 unset($vars['is_action']);
53 unset($vars['is_trusted']);
54 
56 echo "<a $attributes>$text</a>";
$text
Definition: default.php:25
$vars
Definition: url.php:25
$url
Definition: url.php:16
$attributes
Definition: url.php:55
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1464
elgg_add_action_tokens_to_url($url, $html_encode=false)
Adds action tokens to URL.
Definition: elgglib.php:1277
elgg_format_attributes(array $attrs=array())
Converts an associative array into a string of well-formed attributes.
Definition: output.php:118
elgg_normalize_url($url)
Definition: output.php:290