aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation/tabs.php
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/navigation/tabs.php')
-rw-r--r--views/default/navigation/tabs.php102
1 files changed, 61 insertions, 41 deletions
diff --git a/views/default/navigation/tabs.php b/views/default/navigation/tabs.php
index 38a85dca2..95e3f2669 100644
--- a/views/default/navigation/tabs.php
+++ b/views/default/navigation/tabs.php
@@ -2,60 +2,80 @@
/**
* Tab navigation
*
- * @uses string $vars['type'] horizontal || vertical - Defaults to horizontal (vertical TBI)
+ * @uses string $vars['type'] horizontal || vertical - Defaults to horizontal
+ * @uses string $vars['class'] Additional class to add to ul
* @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
+ * 'text' => string, // The string between the <a></a> tags
+ * 'href' => string, // URL for the link
+ * 'class' => string // Class of the li element
+ * 'id' => string, // ID of the li element
+ * 'selected' => bool // if this tab is currently selected (applied to li element)
+ * 'link_class' => string, // Class to pass to the link
+ * 'link_id' => string, // ID to pass to the link
* )
- **/
+ */
+$options = elgg_clean_vars($vars);
+
+$type = elgg_extract('type', $vars, 'horizontal');
-$type = (isset($vars['type'])) ? $vars['type'] : 'horizontal';
if ($type == 'horizontal') {
- $type_class = "elgg_horizontal_tabbed_nav margin_top";
+ $options['class'] = "elgg-tabs elgg-htabs";
} else {
- $type_class = "elgg_vertical_tabbed_nav";
+ $options['class'] = "elgg-tabs elgg-vtabs";
+}
+if (isset($vars['class'])) {
+ $options['class'] = "{$options['class']} {$vars['class']}";
}
-if (isset($vars['tabs'])) {
+unset($options['tabs']);
+unset($options['type']);
+
+$attributes = elgg_format_attributes($options);
+
+if (isset($vars['tabs']) && is_array($vars['tabs']) && !empty($vars['tabs'])) {
?>
- <div class="<?php echo $type_class; ?>">
- <ul>
- <?php
- foreach ($vars['tabs'] as $info) {
- $class = (isset($info['class'])) ? $info['class'] : '';
+ <ul <?php echo $attributes; ?>>
+ <?php
+ foreach ($vars['tabs'] as $info) {
+ $class = elgg_extract('class', $info, '');
+ $id = elgg_extract('id', $info, '');
- if (isset($info['selected']) && $info['selected'] == TRUE) {
- $class .= ' selected';
- }
+ $selected = elgg_extract('selected', $info, FALSE);
+ if ($selected) {
+ $class .= ' elgg-state-selected';
+ }
- $class_str = ($class) ? "class=\"$class\"" : '';
- $title = htmlentities($info['title'], ENT_QUOTES, 'UTF-8');
- $url = htmlentities($info['url'], ENT_QUOTES, 'UTF-8');
+ $class_str = ($class) ? "class=\"$class\"" : '';
+ $id_str = ($id) ? "id=\"$id\"" : '';
- $options = array(
- 'href' => $url,
- 'title' => $title,
- 'text' => $title
- );
+ $options = $info;
+ unset($options['class']);
+ unset($options['id']);
+ unset($options['selected']);
- if (isset($info['url_js'])) {
- $options['js'] = $info['url_js'];
- }
+ if (!isset($info['href']) && isset($info['url'])) {
+ $options['href'] = $info['url'];
+ unset($options['url']);
+ }
+ if (!isset($info['text']) && isset($info['title'])) {
+ $options['text'] = $options['title'];
+ unset($options['title']);
+ }
+ if (isset($info['link_class'])) {
+ $options['class'] = $options['link_class'];
+ unset($options['link_class']);
+ }
- if (isset($info['url_class'])) {
- $options['class'] = $info['url_class'];
- }
+ if (isset($info['link_id'])) {
+ $options['id'] = $options['link_id'];
+ unset($options['link_id']);
+ }
- $link = elgg_view('output/url', $options);
+ $link = elgg_view('output/url', $options);
- echo "<li $class_str $js>$link</li>";
- }
- ?>
- </ul>
- </div>
+ echo "<li $id_str $class_str>$link</li>";
+ }
+ ?>
+ </ul>
<?php
-} \ No newline at end of file
+}