Elgg  Version 1.11
tabs.php
Go to the documentation of this file.
1 <?php
18 
19 $type = elgg_extract('type', $vars, 'horizontal');
20 
21 if ($type == 'horizontal') {
22  $options['class'] = "elgg-tabs elgg-htabs";
23 } else {
24  $options['class'] = "elgg-tabs elgg-vtabs";
25 }
26 if (isset($vars['class'])) {
27  $options['class'] = "{$options['class']} {$vars['class']}";
28 }
29 
30 unset($options['tabs']);
31 unset($options['type']);
32 
34 
35 if (isset($vars['tabs']) && is_array($vars['tabs']) && !empty($vars['tabs'])) {
36  ?>
37  <ul <?php echo $attributes; ?>>
38  <?php
39  foreach ($vars['tabs'] as $info) {
40  $class = elgg_extract('class', $info, '');
41  $id = elgg_extract('id', $info, '');
42 
43  $selected = elgg_extract('selected', $info, FALSE);
44  if ($selected) {
45  $class .= ' elgg-state-selected';
46  }
47 
48  $class_str = ($class) ? "class=\"$class\"" : '';
49  $id_str = ($id) ? "id=\"$id\"" : '';
50 
51  $options = $info;
52  unset($options['class']);
53  unset($options['id']);
54  unset($options['selected']);
55 
56  if (!isset($info['href']) && isset($info['url'])) {
57  $options['href'] = $info['url'];
58  unset($options['url']);
59  }
60  if (!isset($info['text']) && isset($info['title'])) {
61  $options['text'] = $options['title'];
62  unset($options['title']);
63  }
64  if (isset($info['link_class'])) {
65  $options['class'] = $options['link_class'];
66  unset($options['link_class']);
67  }
68 
69  if (isset($info['link_id'])) {
70  $options['id'] = $options['link_id'];
71  unset($options['link_id']);
72  }
73 
74  $link = elgg_view('output/url', $options);
75 
76  echo "<li $id_str $class_str>$link</li>";
77  }
78  ?>
79  </ul>
80  <?php
81 }
$type
Definition: tabs.php:19
ul
Definition: admin.php:44
elgg_extract($key, array $array, $default=null, $strict=true)
Checks for $array[$key] and returns its value if it exists, else returns $default.
Definition: elgglib.php:1246
if(isset($vars['id'])) $class
Definition: ajax_loader.php:19
$attributes
Definition: tabs.php:33
_elgg_clean_vars(array $vars=array())
Preps an associative array for use in elgg_format_attributes().
Definition: output.php:265
$options
Tab navigation.
Definition: tabs.php:17
elgg echo
Translates a string.
Definition: languages.js:43
elgg_format_attributes(array $attrs=array())
Converts an associative array into a string of well-formed attributes.
Definition: output.php:139
elgg_view($view, $vars=array(), $bypass=false, $ignored=false, $viewtype= '')
Return a parsed view.
Definition: views.php:354
if(!$collection_name) $id
Definition: add.php:17
if(file_exists($welcome)) $vars
Definition: upgrade.php:93