Added output/url to the mix -- includes ability to accept arbitrary attributes
[lorea:html5.git] / views / default / output / url.php
1 <?php
2 /**
3  * Elgg URL display
4  * Displays a URL as a link
5  *
6  * @package Elgg
7  * @subpackage Core
8  * @author Curverider Ltd
9  * @link http://elgg.org/
10  *
11  * @uses string $vars['href'] The string to display in the <a></a> tags
12  * @uses string $vars['text'] The string between the <a></a> tags.
13  * @uses bool $vars['is_action'] Is this a link to an action?
14  *
15  */
16
17 if (isset($vars['value'])) {
18         $vars['href'] = $vars['value'];
19         unset($vars['value']);
20 }
21
22 $url = trim($vars['href']);
23
24 if (isset($vars['is_action']) && $vars['is_action']) {
25         $url = elgg_add_action_tokens_to_url($url);
26         unset($vars['is_action']);
27 }
28
29 if (isset($vars['body'])) {
30         $body = $vars['body'];
31         unset($vars['body']);
32 }
33
34 if (!isset($body)) {
35         if (isset($vars['text'])) {
36                 $text = $vars['text']; 
37                 unset($vars['text']);
38         } else {
39                 $text = $url;
40         }
41         
42         $body = htmlentities($text, ENT_QUOTES, 'UTF-8');
43 }
44
45 $vars['href'] = $url;
46 $attributes = html5_get_html_attributes($vars);
47 echo "<a $attributes>$text</a>";