diff options
Diffstat (limited to 'views/default/navigation')
-rw-r--r-- | views/default/navigation/menu/elements/item.php | 6 | ||||
-rw-r--r-- | views/default/navigation/pagination.php | 12 | ||||
-rw-r--r-- | views/default/navigation/tabs.php | 95 |
3 files changed, 67 insertions, 46 deletions
diff --git a/views/default/navigation/menu/elements/item.php b/views/default/navigation/menu/elements/item.php index 22383ce0b..fd9738826 100644 --- a/views/default/navigation/menu/elements/item.php +++ b/views/default/navigation/menu/elements/item.php @@ -13,7 +13,8 @@ $item = $vars['item']; $link_class = 'elgg-menu-closed'; if ($item->getSelected()) { - $item->setItemClass('elgg-state-selected'); + // @todo switch to addItemClass when that is implemented + //$item->setItemClass('elgg-state-selected'); $link_class = 'elgg-menu-opened'; } @@ -24,6 +25,9 @@ if ($children) { } $item_class = $item->getItemClass(); +if ($item->getSelected()) { + $item_class = "$item_class elgg-state-selected"; +} if (isset($vars['item_class']) && $vars['item_class']) { $item_class .= ' ' . $vars['item_class']; } diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php index ad4689d83..04044c51c 100644 --- a/views/default/navigation/pagination.php +++ b/views/default/navigation/pagination.php @@ -8,7 +8,7 @@ * @uses int $vars['offset'] The offset in the list * @uses int $vars['limit'] Number of items per page * @uses int $vars['count'] Number of items in list - * @uses string $vars['baseurl'] Base URL to use in links + * @uses string $vars['base_url'] Base URL to use in links * @uses string $vars['offset_key'] The string to use for offet in the URL */ @@ -28,6 +28,9 @@ $offset_key = elgg_extract('offset_key', $vars, 'offset'); // some views pass an empty string for base_url if (isset($vars['base_url']) && $vars['base_url']) { $base_url = $vars['base_url']; +} else if (isset($vars['baseurl']) && $vars['baseurl']) { + elgg_deprecated_notice("Use 'base_url' instead of 'baseurl' for the navigation/pagination view", 1.8); + $base_url = $vars['baseurl']; } else { $base_url = current_page_url(); } @@ -110,7 +113,12 @@ foreach ($pages->items as $page) { } else { $page_offset = (($page - 1) * $limit); $url = elgg_http_add_url_query_elements($base_url, array($offset_key => $page_offset)); - echo "<li><a href=\"$url\">$page</a></li>"; + $link = elgg_view('output/url', array( + 'href' => $url, + 'text' => $page, + 'is_trusted' => true, + )); + echo "<li>$link</li>"; } } diff --git a/views/default/navigation/tabs.php b/views/default/navigation/tabs.php index e8fde3579..95e3f2669 100644 --- a/views/default/navigation/tabs.php +++ b/views/default/navigation/tabs.php @@ -5,68 +5,77 @@ * @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 + * '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 li element is currently selected - * 'url_class' => string, // Class to pass to the link - * 'url_id' => string, // ID to pass to the link + * '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'); + if ($type == 'horizontal') { - $type_class = "elgg-tabs elgg-htabs"; + $options['class'] = "elgg-tabs elgg-htabs"; } else { - $type_class = "elgg-tabs elgg-vtabs"; + $options['class'] = "elgg-tabs elgg-vtabs"; } - if (isset($vars['class'])) { - $type_class = "$type_class {$vars['class']}"; + $options['class'] = "{$options['class']} {$vars['class']}"; } +unset($options['tabs']); +unset($options['type']); + +$attributes = elgg_format_attributes($options); + 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_extract('class', $info, ''); - $id = elgg_extract('id', $info, ''); - - $selected = elgg_extract('selected', $info, FALSE); - if ($selected) { - $class .= ' elgg-state-selected'; - } + ?> + <ul <?php echo $attributes; ?>> + <?php + foreach ($vars['tabs'] as $info) { + $class = elgg_extract('class', $info, ''); + $id = elgg_extract('id', $info, ''); - $class_str = ($class) ? "class=\"$class\"" : ''; - $id_str = ($id) ? "id=\"$id\"" : ''; - $title = htmlspecialchars($info['title'], ENT_QUOTES, 'UTF-8'); - $url = htmlspecialchars($info['url'], ENT_QUOTES, 'UTF-8'); + $selected = elgg_extract('selected', $info, FALSE); + if ($selected) { + $class .= ' elgg-state-selected'; + } - $options = array( - 'href' => $url, - 'title' => $title, - 'text' => $title, - ); + $class_str = ($class) ? "class=\"$class\"" : ''; + $id_str = ($id) ? "id=\"$id\"" : ''; - if (isset($info['url_class'])) { - $options['class'] = $info['url_class']; - } + $options = $info; + unset($options['class']); + unset($options['id']); + unset($options['selected']); - if (isset($info['url_id'])) { - $options['id'] = $info['url_id']; - } + 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['rel']) && !isset($info['is_trusted'])) { - $options['is_trusted'] = true; - } + 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> + echo "<li $id_str $class_str>$link</li>"; + } + ?> + </ul> <?php } |