aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation/tabs.php
blob: 8a51c7f3d7980138997c7d31dd44dca1bd3f0786 (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
<?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
 * 	'class' => string  // Class of the li element.
 * 	'selected' => bool // if this link is currently selected
 * )
 **/

$type = (isset($vars['type'])) ? $vars['type'] : 'horizontal';
if ($type == 'horizontal') {
	$type_class = "elgg_horizontal_tabbed_nav margin_top";
} else {
	$type_class = "elgg_vertical_tabbed_nav";
}

if (isset($vars['tabs'])) {
	?>
	<div class="<?php echo $type_class; ?>">
		<ul>
	<?php
	foreach ($vars['tabs'] as $info) {
		$class = (isset($info['class'])) ? $info['class'] : '';

		if (isset($info['selected']) && $info['selected'] == TRUE) {
			$class .= ' selected';
		}

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

		echo "<li $class_str $js><a href=\"$url\" title=\"$title\"><span>$title</span></a></li>";
	}
	?>
		</ul>
	</div>
	<?php
}