aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation
diff options
context:
space:
mode:
Diffstat (limited to 'views/default/navigation')
-rw-r--r--views/default/navigation/breadcrumbs.php41
-rw-r--r--views/default/navigation/menu/default.php31
-rw-r--r--views/default/navigation/menu/elements/item.php43
-rw-r--r--views/default/navigation/menu/elements/section.php30
-rw-r--r--views/default/navigation/menu/page.php36
-rw-r--r--views/default/navigation/menu/site.php30
-rw-r--r--views/default/navigation/menu/user_hover.php60
-rw-r--r--views/default/navigation/pagination.php132
-rw-r--r--views/default/navigation/tabs.php81
-rw-r--r--views/default/navigation/topbar_tools.php9
-rw-r--r--views/default/navigation/viewtype.php11
11 files changed, 504 insertions, 0 deletions
diff --git a/views/default/navigation/breadcrumbs.php b/views/default/navigation/breadcrumbs.php
new file mode 100644
index 000000000..88577a8ff
--- /dev/null
+++ b/views/default/navigation/breadcrumbs.php
@@ -0,0 +1,41 @@
+<?php
+/**
+ * Displays breadcrumbs.
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ * @uses $vars['breadcrumbs'] (Optional) Array of arrays with keys 'title' and 'link'
+ * @uses $vars['class']
+ *
+ * @see elgg_push_breadcrumb
+ */
+
+if (isset($vars['breadcrumbs'])) {
+ $breadcrumbs = $vars['breadcrumbs'];
+} else {
+ $breadcrumbs = elgg_get_breadcrumbs();
+}
+
+$class = 'elgg-menu elgg-breadcrumbs';
+$additional_class = elgg_extract('class', $vars, '');
+if ($additional_class) {
+ $class = "$class $additional_class";
+}
+
+if (is_array($breadcrumbs) && count($breadcrumbs) > 0) {
+ echo "<ul class=\"$class\">";
+ foreach ($breadcrumbs as $breadcrumb) {
+ if (!empty($breadcrumb['link'])) {
+ $crumb = elgg_view('output/url', array(
+ 'href' => $breadcrumb['link'],
+ 'text' => $breadcrumb['title'],
+ 'is_trusted' => true,
+ ));
+ } else {
+ $crumb = $breadcrumb['title'];
+ }
+ echo "<li>$crumb</li>";
+ }
+ echo '</ul>';
+}
diff --git a/views/default/navigation/menu/default.php b/views/default/navigation/menu/default.php
new file mode 100644
index 000000000..006deb3ea
--- /dev/null
+++ b/views/default/navigation/menu/default.php
@@ -0,0 +1,31 @@
+<?php
+/**
+ * Default menu
+ *
+ * @uses $vars['name'] Name of the menu
+ * @uses $vars['menu'] Array of menu items
+ * @uses $vars['class'] Additional CSS class for the menu
+ * @uses $vars['item_class'] Additional CSS class for each menu item
+ * @uses $vars['show_section_headers'] Do we show headers for each section?
+ */
+
+// we want css classes to use dashes
+$vars['name'] = preg_replace('/[^a-z0-9\-]/i', '-', $vars['name']);
+$headers = elgg_extract('show_section_headers', $vars, false);
+$item_class = elgg_extract('item_class', $vars, '');
+
+$class = "elgg-menu elgg-menu-{$vars['name']}";
+if (isset($vars['class'])) {
+ $class .= " {$vars['class']}";
+}
+
+foreach ($vars['menu'] as $section => $menu_items) {
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'items' => $menu_items,
+ 'class' => "$class elgg-menu-{$vars['name']}-$section",
+ 'section' => $section,
+ 'name' => $vars['name'],
+ 'show_section_headers' => $headers,
+ 'item_class' => $item_class,
+ ));
+}
diff --git a/views/default/navigation/menu/elements/item.php b/views/default/navigation/menu/elements/item.php
new file mode 100644
index 000000000..fd9738826
--- /dev/null
+++ b/views/default/navigation/menu/elements/item.php
@@ -0,0 +1,43 @@
+<?php
+/**
+ * A single element of a menu.
+ *
+ * @package Elgg.Core
+ * @subpackage Navigation
+ *
+ * @uses $vars['item'] ElggMenuItem
+ * @uses $vars['item_class'] Additional CSS class for the menu item
+ */
+
+$item = $vars['item'];
+
+$link_class = 'elgg-menu-closed';
+if ($item->getSelected()) {
+ // @todo switch to addItemClass when that is implemented
+ //$item->setItemClass('elgg-state-selected');
+ $link_class = 'elgg-menu-opened';
+}
+
+$children = $item->getChildren();
+if ($children) {
+ $item->addLinkClass($link_class);
+ $item->addLinkClass('elgg-menu-parent');
+}
+
+$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'];
+}
+
+echo "<li class=\"$item_class\">";
+echo $item->getContent();
+if ($children) {
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'items' => $children,
+ 'class' => 'elgg-menu elgg-child-menu',
+ ));
+}
+echo '</li>';
diff --git a/views/default/navigation/menu/elements/section.php b/views/default/navigation/menu/elements/section.php
new file mode 100644
index 000000000..c0e9ba750
--- /dev/null
+++ b/views/default/navigation/menu/elements/section.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Menu group
+ *
+ * @uses $vars['items'] Array of menu items
+ * @uses $vars['class'] Additional CSS class for the section
+ * @uses $vars['name'] Name of the menu
+ * @uses $vars['section'] The section name
+ * @uses $vars['item_class'] Additional CSS class for each menu item
+ * @uses $vars['show_section_headers'] Do we show headers for each section
+ */
+
+$headers = elgg_extract('show_section_headers', $vars, false);
+$class = elgg_extract('class', $vars, '');
+$item_class = elgg_extract('item_class', $vars, '');
+
+if ($headers) {
+ $name = elgg_extract('name', $vars);
+ $section = elgg_extract('section', $vars);
+ echo '<h2>' . elgg_echo("menu:$name:header:$section") . '</h2>';
+}
+
+echo "<ul class=\"$class\">";
+foreach ($vars['items'] as $menu_item) {
+ echo elgg_view('navigation/menu/elements/item', array(
+ 'item' => $menu_item,
+ 'item_class' => $item_class,
+ ));
+}
+echo '</ul>';
diff --git a/views/default/navigation/menu/page.php b/views/default/navigation/menu/page.php
new file mode 100644
index 000000000..56a288234
--- /dev/null
+++ b/views/default/navigation/menu/page.php
@@ -0,0 +1,36 @@
+<?php
+/**
+ * Page menu
+ *
+ * @uses $vars['menu']
+ * @uses $vars['selected_item']
+ * @uses $vars['class']
+ * @uses $vars['name']
+ * @uses $vars['show_section_headers']
+ */
+
+$headers = elgg_extract('show_section_headers', $vars, false);
+
+$class = 'elgg-menu elgg-menu-page';
+if (isset($vars['class'])) {
+ $class = "$class {$vars['class']}";
+}
+
+if (isset($vars['selected_item'])) {
+ $parent = $vars['selected_item']->getParent();
+
+ while ($parent) {
+ $parent->setSelected();
+ $parent = $parent->getParent();
+ }
+}
+
+foreach ($vars['menu'] as $section => $menu_items) {
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'items' => $menu_items,
+ 'class' => "$class elgg-menu-page-$section",
+ 'section' => $section,
+ 'name' => $vars['name'],
+ 'show_section_headers' => $headers
+ ));
+}
diff --git a/views/default/navigation/menu/site.php b/views/default/navigation/menu/site.php
new file mode 100644
index 000000000..24c21dd57
--- /dev/null
+++ b/views/default/navigation/menu/site.php
@@ -0,0 +1,30 @@
+<?php
+/**
+ * Site navigation menu
+ *
+ * @uses $vars['menu']['default']
+ * @uses $vars['menu']['more']
+ */
+
+$default_items = elgg_extract('default', $vars['menu'], array());
+$more_items = elgg_extract('more', $vars['menu'], array());
+
+echo '<ul class="elgg-menu elgg-menu-site elgg-menu-site-default clearfix">';
+foreach ($default_items as $menu_item) {
+ echo elgg_view('navigation/menu/elements/item', array('item' => $menu_item));
+}
+
+if ($more_items) {
+ echo '<li class="elgg-more">';
+
+ $more = elgg_echo('more');
+ echo "<a href=\"#\">$more</a>";
+
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'class' => 'elgg-menu elgg-menu-site elgg-menu-site-more',
+ 'items' => $more_items,
+ ));
+
+ echo '</li>';
+}
+echo '</ul>';
diff --git a/views/default/navigation/menu/user_hover.php b/views/default/navigation/menu/user_hover.php
new file mode 100644
index 000000000..5c89e585c
--- /dev/null
+++ b/views/default/navigation/menu/user_hover.php
@@ -0,0 +1,60 @@
+<?php
+/**
+ * User hover menu
+ *
+ * Register for the 'register', 'menu:user_hover' plugin hook to add to the user
+ * hover menu. There are three sections: action, default, and admin.
+ *
+ * @uses $vars['menu'] Menu array provided by elgg_view_menu()
+ */
+
+$user = $vars['entity'];
+$actions = elgg_extract('action', $vars['menu'], null);
+$main = elgg_extract('default', $vars['menu'], null);
+$admin = elgg_extract('admin', $vars['menu'], null);
+
+echo '<ul class="elgg-menu elgg-menu-hover">';
+
+// name and username
+$name_link = elgg_view('output/url', array(
+ 'href' => $user->getURL(),
+ 'text' => "<span class=\"elgg-heading-basic\">$user->name</span>&#64;$user->username",
+ 'is_trusted' => true,
+));
+echo "<li>$name_link</li>";
+
+// actions
+if (elgg_is_logged_in() && $actions) {
+ echo '<li>';
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'class' => "elgg-menu elgg-menu-hover-actions",
+ 'items' => $actions,
+ ));
+ echo '</li>';
+}
+
+// main
+if ($main) {
+ echo '<li>';
+
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'class' => 'elgg-menu elgg-menu-hover-default',
+ 'items' => $main,
+ ));
+
+ echo '</li>';
+}
+
+// admin
+if (elgg_is_admin_logged_in() && $admin) {
+ echo '<li>';
+
+ echo elgg_view('navigation/menu/elements/section', array(
+ 'class' => 'elgg-menu elgg-menu-hover-admin',
+ 'items' => $admin,
+ ));
+
+ echo '</li>';
+}
+
+echo '</ul>';
diff --git a/views/default/navigation/pagination.php b/views/default/navigation/pagination.php
new file mode 100644
index 000000000..04044c51c
--- /dev/null
+++ b/views/default/navigation/pagination.php
@@ -0,0 +1,132 @@
+<?php
+/**
+ * Elgg pagination
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ * @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['base_url'] Base URL to use in links
+ * @uses string $vars['offset_key'] The string to use for offet in the URL
+ */
+
+if (elgg_in_context('widget')) {
+ // widgets do not show pagination
+ return true;
+}
+
+$offset = abs((int) elgg_extract('offset', $vars, 0));
+// because you can say $vars['limit'] = 0
+if (!$limit = (int) elgg_extract('limit', $vars, 10)) {
+ $limit = 10;
+}
+
+$count = (int) elgg_extract('count', $vars, 0);
+$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();
+}
+
+$num_pages = elgg_extract('num_pages', $vars, 10);
+$delta = ceil($num_pages / 2);
+
+if ($count <= $limit && $offset == 0) {
+ // no need for pagination
+ return true;
+}
+
+$total_pages = ceil($count / $limit);
+$current_page = ceil($offset / $limit) + 1;
+
+$pages = new stdClass();
+$pages->prev = array(
+ 'text' => '&laquo; ' . elgg_echo('previous'),
+ 'href' => '',
+ 'is_trusted' => true,
+);
+$pages->next = array(
+ 'text' => elgg_echo('next') . ' &raquo;',
+ 'href' => '',
+ 'is_trusted' => true,
+);
+$pages->items = array();
+
+// Add pages before the current page
+if ($current_page > 1) {
+ $prev_offset = $offset - $limit;
+ if ($prev_offset < 0) {
+ $prev_offset = 0;
+ }
+
+ $pages->prev['href'] = elgg_http_add_url_query_elements($base_url, array($offset_key => $prev_offset));
+
+ $first_page = $current_page - $delta;
+ if ($first_page < 1) {
+ $first_page = 1;
+ }
+
+ $pages->items = range($first_page, $current_page - 1);
+}
+
+
+$pages->items[] = $current_page;
+
+
+// add pages after the current one
+if ($current_page < $total_pages) {
+ $next_offset = $offset + $limit;
+ if ($next_offset >= $count) {
+ $next_offset--;
+ }
+
+ $pages->next['href'] = elgg_http_add_url_query_elements($base_url, array($offset_key => $next_offset));
+
+ $last_page = $current_page + $delta;
+ if ($last_page > $total_pages) {
+ $last_page = $total_pages;
+ }
+
+ $pages->items = array_merge($pages->items, range($current_page + 1, $last_page));
+}
+
+
+echo '<ul class="elgg-pagination">';
+
+if ($pages->prev['href']) {
+ $link = elgg_view('output/url', $pages->prev);
+ echo "<li>$link</li>";
+} else {
+ echo "<li class=\"elgg-state-disabled\"><span>{$pages->prev['text']}</span></li>";
+}
+
+foreach ($pages->items as $page) {
+ if ($page == $current_page) {
+ echo "<li class=\"elgg-state-selected\"><span>$page</span></li>";
+ } else {
+ $page_offset = (($page - 1) * $limit);
+ $url = elgg_http_add_url_query_elements($base_url, array($offset_key => $page_offset));
+ $link = elgg_view('output/url', array(
+ 'href' => $url,
+ 'text' => $page,
+ 'is_trusted' => true,
+ ));
+ echo "<li>$link</li>";
+ }
+}
+
+if ($pages->next['href']) {
+ $link = elgg_view('output/url', $pages->next);
+ echo "<li>$link</li>";
+} else {
+ echo "<li class=\"elgg-state-disabled\"><span>{$pages->next['text']}</span></li>";
+}
+
+echo '</ul>';
diff --git a/views/default/navigation/tabs.php b/views/default/navigation/tabs.php
new file mode 100644
index 000000000..95e3f2669
--- /dev/null
+++ b/views/default/navigation/tabs.php
@@ -0,0 +1,81 @@
+<?php
+/**
+ * Tab navigation
+ *
+ * @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(
+ * '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');
+
+if ($type == 'horizontal') {
+ $options['class'] = "elgg-tabs elgg-htabs";
+} else {
+ $options['class'] = "elgg-tabs elgg-vtabs";
+}
+if (isset($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 <?php echo $attributes; ?>>
+ <?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';
+ }
+
+ $class_str = ($class) ? "class=\"$class\"" : '';
+ $id_str = ($id) ? "id=\"$id\"" : '';
+
+ $options = $info;
+ unset($options['class']);
+ unset($options['id']);
+ unset($options['selected']);
+
+ 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['link_id'])) {
+ $options['id'] = $options['link_id'];
+ unset($options['link_id']);
+ }
+
+ $link = elgg_view('output/url', $options);
+
+ echo "<li $id_str $class_str>$link</li>";
+ }
+ ?>
+ </ul>
+ <?php
+}
diff --git a/views/default/navigation/topbar_tools.php b/views/default/navigation/topbar_tools.php
new file mode 100644
index 000000000..307f03fc6
--- /dev/null
+++ b/views/default/navigation/topbar_tools.php
@@ -0,0 +1,9 @@
+<?php
+/**
+ * Empty view for backward compatibility.
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ * @deprecated 1.8 Extend the topbar menus or the page/elements/topbar view directly
+ */
diff --git a/views/default/navigation/viewtype.php b/views/default/navigation/viewtype.php
new file mode 100644
index 000000000..6dfa4ebc7
--- /dev/null
+++ b/views/default/navigation/viewtype.php
@@ -0,0 +1,11 @@
+<?php
+/**
+ * Elgg list view switcher
+ *
+ * @package Elgg
+ * @subpackage Core
+ *
+ * @deprecated 1.8 See how file plugin adds a toggle in function file_register_toggle()
+ */
+
+elgg_deprecated_notice('navigation/viewtype was deprecated', 1.8);