diff options
author | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-20 06:04:43 +0000 |
---|---|---|
committer | ewinslow <ewinslow@36083f99-b078-4883-b0ff-0f9b5a30f544> | 2010-11-20 06:04:43 +0000 |
commit | a8833f0ab81df477c8a19b221a9ae8a90294bdf8 (patch) | |
tree | 1a38a47a466a565d38df9b549ad727bd5f363b19 /views/default/output | |
parent | 2da8c3e8428f09bab7aefa39cadc0a4f2d6f7a80 (diff) | |
download | elgg-a8833f0ab81df477c8a19b221a9ae8a90294bdf8.tar.gz elgg-a8833f0ab81df477c8a19b221a9ae8a90294bdf8.tar.bz2 |
Refs #2143: Added elgg_format_attributes() for generating an attribute string from an associative array. DRYed up input/output url
git-svn-id: http://code.elgg.org/elgg/trunk@7354 36083f99-b078-4883-b0ff-0f9b5a30f544
Diffstat (limited to 'views/default/output')
-rw-r--r-- | views/default/output/url.php | 54 |
1 files changed, 14 insertions, 40 deletions
diff --git a/views/default/output/url.php b/views/default/output/url.php index c857d24d1..23b774198 100644 --- a/views/default/output/url.php +++ b/views/default/output/url.php @@ -6,68 +6,42 @@ * @package Elgg * @subpackage Core * - * @uses string $vars['href'] The URL. - * @uses string $vars['text'] The string between the <a></a> tags. - * @uses string $vars['target'] Set the target="" attribute. - * @uses bool $vars['encode_text'] Run $vars['text'] through htmlentities()? - * @uses string $vars['class'] what to add in class="" - * @uses string $vars['js'] Javascript to insert in <a> tag - * @uses string $vars['title'] Title attribute to <a> tag - * @uses bool $vars['is_action'] Is this a link to an action? + * @uses string $vars['text'] The string between the <a></a> tags. + * @uses bool $vars['encode_text'] Run $vars['text'] through htmlentities()? + * @uses bool $vars['is_action'] Is this a link to an action? * */ $url = trim($vars['href']); if (!$url and isset($vars['value'])) { $url = trim($vars['value']); + unset($vars['value']); } -if (!empty($url)) { - if (isset($vars['target'])) { - $target = "target = \"{$vars['target']}\""; - } else { - $target = ''; - } - - if (isset($vars['class'])) { - $class = "class = \"{$vars['class']}\""; - } else { - $class = ''; - } - - if (isset($vars['internalid'])) { - $id = "id = \"{$vars['internalid']}\""; - } else { - $id = ''; - } - - if (isset($vars['js'])) { - $js = "{$vars['js']}"; - } else { - $js = ''; - } - +if (!empty($url)) {
if (isset($vars['text'])) { if (isset($vars['encode_text']) && $vars['encode_text']) { $text = htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); } else { $text = $vars['text']; } + + unset($vars['text']); } else { $text = htmlentities($url, ENT_QUOTES, 'UTF-8'); } + unset($vars['encode_text']); + $url = elgg_normalize_url($url); if (isset($vars['is_action'])) { $url = elgg_add_action_tokens_to_url($url); + unset($vars['is_action']); } - if (isset($vars['title'])) { - $title = 'title="' . htmlentities($vars['title']) . '"'; - } else { - $title = ''; - } - - echo "<a href=\"{$url}\" $target $class $id $js $title>$text</a>"; + $vars['href'] = $url; +
+ $attributes = elgg_format_attributes($vars); + echo "<a $attributes>$text</a>";
}
\ No newline at end of file |