diff options
Diffstat (limited to 'views/default/output/confirmlink.php')
| -rw-r--r-- | views/default/output/confirmlink.php | 52 |
1 files changed, 30 insertions, 22 deletions
diff --git a/views/default/output/confirmlink.php b/views/default/output/confirmlink.php index e0a6f65d7..532790a38 100644 --- a/views/default/output/confirmlink.php +++ b/views/default/output/confirmlink.php @@ -5,35 +5,43 @@ * * @package Elgg * @subpackage Core - * @author Curverider Ltd - * @link http://elgg.org/ - * - * @uses $vars['text'] The text of the link - * @uses $vars['href'] The address - * @uses $vars['confirm'] The dialog text * + * @uses $vars['text'] The text of the link + * @uses $vars['href'] The address + * @uses $vars['title'] The title text (defaults to confirm text) + * @uses $vars['confirm'] The dialog text + * @uses $vars['encode_text'] Run $vars['text'] through htmlspecialchars() (false) */ -$confirm = $vars['confirm']; -if (!$confirm) { - $confirm = elgg_echo('question:areyousure'); -} +$vars['rel'] = elgg_extract('confirm', $vars, elgg_echo('question:areyousure')); +$vars['rel'] = addslashes($vars['rel']); +$encode = elgg_extract('encode_text', $vars, false); -$link = $vars['href']; +// always generate missing action tokens +$vars['href'] = elgg_add_action_tokens_to_url(elgg_normalize_url($vars['href']), true); -if ($vars['is_action']) { - $ts = time(); - $token = generate_action_token($ts); +$text = elgg_extract('text', $vars, ''); +if ($encode) { + $text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8', false); +} - $sep = "?"; - if (strpos($link, '?')>0) $sep = "&"; - $link = "$link{$sep}__elgg_token=$token&__elgg_ts=$ts"; +if (!isset($vars['title']) && isset($vars['confirm'])) { + $vars['title'] = $vars['rel']; } -if ($vars['class']) { - $class = 'class="' . $vars['class'] . '"'; +if (isset($vars['class'])) { + if (!is_array($vars['class'])) { + $vars['class'] = array($vars['class']); + } + $vars['class'][] = 'elgg-requires-confirmation'; } else { - $class = ''; + $vars['class'] = 'elgg-requires-confirmation'; } -?> -<a href="<?php echo $link; ?>" <?php echo $class; ?> onclick="return confirm('<?php echo addslashes($confirm); ?>');"><?php echo htmlentities($vars['text'], ENT_QUOTES, 'UTF-8'); ?></a>
\ No newline at end of file + +unset($vars['encode_text']); +unset($vars['text']); +unset($vars['confirm']); +unset($vars['is_trusted']); + +$attributes = elgg_format_attributes($vars); +echo "<a $attributes>$text</a>"; |
