aboutsummaryrefslogtreecommitdiff
path: root/views/default/output/confirmlink.php
blob: 5cb9aa52e00df7dd14a94b36d2594acf84b20e78 (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
<?php
/**
 * Elgg confirmation link
 * A link that displays a confirmation dialog before it executes
 *
 * @package Elgg
 * @subpackage Core
 *
 * @uses $vars['text'] The text of the link
 * @uses $vars['href'] The address
 * @uses $vars['confirm'] The dialog text
 * @uses $vars['encode'] Encode special characters?
 */

$confirm = elgg_get_array_value('confirm', $vars, elgg_echo('question:areyousure'));

$encode = elgg_get_array_value('encode', $vars, true);

// always generate missing action tokens
$link = elgg_add_action_tokens_to_url(elgg_normalize_url($vars['href']));

$text = elgg_get_array_value('text', $vars, '');
if ($encode) {
	$text = htmlspecialchars($text, ENT_QUOTES, 'UTF-8');
}

if (isset($vars['class']) && $vars['class']) {
	$class = 'class="' . $vars['class'] . '"';
} else {
	$class = '';
}
?>
<a href="<?php echo $link; ?>" <?php echo $class; ?> onclick="return confirm('<?php echo addslashes($confirm); ?>');">
	<?php echo $text; ?>
</a>