aboutsummaryrefslogtreecommitdiff
path: root/views/default/output/url.php
blob: 31db9e928d3867365fda5e29d5eda8d6af8a5a64 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<?php
/**
 * Elgg URL display
 * Displays a URL as a link
 *
 * @package Elgg
 * @subpackage Core
 * @author Curverider Ltd
 * @link http://elgg.org/
 *
 * @uses string $vars['body'] The html to insert between the <a></a> tags
 * @uses string $vars['text'] The string between the <a></a> tags.
 * @uses bool $vars['is_action'] Is this a link to an action?
 *
 */

if (isset($vars['value'])) {
	$vars['href'] = $vars['value'];
	unset($vars['value']);
}

$url = trim($vars['href']);

if (isset($vars['is_action']) && $vars['is_action']) {
	$url = elgg_add_action_tokens_to_url($url);
	unset($vars['is_action']);
}

if (isset($vars['body'])) {
	$body = $vars['body'];
	unset($vars['body']);
}

if (!isset($body)) {
	if (isset($vars['text'])) {
		$text = $vars['text']; 
		unset($vars['text']);
	} else {
		$text = $url;
	}
	
	$body = htmlentities($text, ENT_QUOTES, 'UTF-8');
}

$vars['href'] = $url;
$attributes = elgg_format_attributes($vars);
echo "<a $attributes>$body</a>";