aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation/tabs.php
blob: e3398a99dc48ed6073a8fabe350e4580f93ec4ea (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
48
49
50
51
52
53
54
55
56
57
58
59
60
<?php
/**
 * Tab navigation
 *
 * @uses string $vars['type'] horizontal || vertical - Defaults to horizontal (vertical TBI)
 * @uses array $vars['tabs'] A multi-dimensional array of tab entries in the format array(
 * 	'title' => string, // Title of link
 * 	'url' => string, // URL for the link
 * 	'url_js' => string, // JS to pass to the link
 * 	'url_class' => string, // Class to pass to the link
 * 	'class' => string  // Class of the li element.
 * 	'selected' => bool // if this link is currently selected
 * )
 */

$type = elgg_get_array_value('type', $vars, 'horizontal');
if ($type == 'horizontal') {
	$type_class = "elgg-tabs elgg-htabs mtm";
} else {
	$type_class = "elgg-tabs elgg-vtabs";
}

if (isset($vars['tabs']) && is_array($vars['tabs']) && !empty($vars['tabs'])) {
?>
	<ul class="<?php echo $type_class; ?>">
	<?php
	foreach ($vars['tabs'] as $info) {
		$class = elgg_get_array_value('class', $info, '');
		
		$selected = elgg_get_array_value('selected', $info, FALSE);
		if ($selected) {
			$class .= ' selected';
		}

		$class_str = ($class) ? "class=\"$class\"" : '';
		$title = htmlentities($info['title'], ENT_QUOTES, 'UTF-8');
		$url = htmlentities($info['url'], ENT_QUOTES, 'UTF-8');

		$options = array(
			'href' => $url,
			'title' => $title,
			'text' => $title
		);

		if (isset($info['url_js'])) {
			$options['js'] = $info['url_js'];
		}

		if (isset($info['url_class'])) {
			$options['class'] = $info['url_class'];
		}

		$link = elgg_view('output/url', $options);

		echo "<li $class_str $js>$link</li>";
	}
	?>
		</ul>
	<?php
}