Elgg  Version 1.11
url.php
Go to the documentation of this file.
1 <?php
20 if (!empty($vars['confirm']) && !isset($vars['is_action'])) {
21  $vars['is_action'] = true;
22 }
23 
24 if (!empty($vars['confirm'])) {
25  $vars['data-confirm'] = elgg_extract('confirm', $vars, elgg_echo('question:areyousure'));
26 
27  // if (bool) true use defaults
28  if ($vars['data-confirm'] === true) {
29  $vars['data-confirm'] = elgg_echo('question:areyousure');
30  }
31 }
32 
33 $url = elgg_extract('href', $vars, null);
34 if (!$url && isset($vars['value'])) {
35  $url = trim($vars['value']);
36  unset($vars['value']);
37 }
38 
39 if (isset($vars['text'])) {
40  if (elgg_extract('encode_text', $vars, false)) {
41  $text = htmlspecialchars($vars['text'], ENT_QUOTES, 'UTF-8', false);
42  } else {
43  $text = $vars['text'];
44  }
45  unset($vars['text']);
46 } else {
47  $text = htmlspecialchars($url, ENT_QUOTES, 'UTF-8', false);
48 }
49 
50 unset($vars['encode_text']);
51 
52 if ($url) {
54 
55  if (elgg_extract('is_action', $vars, false)) {
57  }
58 
59  if (!elgg_extract('is_trusted', $vars, false)) {
60  if (!isset($vars['rel'])) {
61  $vars['rel'] = 'nofollow';
62  $url = strip_tags($url);
63  }
64  }
65 
66  $vars['href'] = $url;
67 }
68 
69 if (!isset($vars['title']) && isset($vars['data-confirm'])) {
70  $vars['title'] = $vars['data-confirm'];
71 }
72 
73 unset($vars['is_action']);
74 unset($vars['is_trusted']);
75 unset($vars['confirm']);
76 
78 echo "<a $attributes>$text</a>";
$attributes
Definition: url.php:77
elgg_add_action_tokens_to_url($url, $html_encode=false)
Adds action tokens to URL.
Definition: elgglib.php:1059
elgg_normalize_url($url)
Definition: output.php:311
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:1246
if(!empty($vars['confirm'])&&!isset($vars['is_action'])) if(!empty($vars['confirm'])) $url
Definition: url.php:33
$text
Definition: default.php:25
elgg_echo($message_key, $args=array(), $language="")
Given a message key, returns an appropriately translated full-text string.
Definition: languages.php:21
elgg echo
Translates a string.
Definition: languages.js:43
elgg_format_attributes(array $attrs=array())
Converts an associative array into a string of well-formed attributes.
Definition: output.php:139
$vars['class']
Definition: url.php:12