aboutsummaryrefslogtreecommitdiff
path: root/views/default/navigation
diff options
context:
space:
mode:
authorSilvio Rhatto <rhatto@riseup.net>2014-03-16 21:01:42 -0300
committerSilvio Rhatto <rhatto@riseup.net>2014-03-16 21:01:42 -0300
commit5f6dc365a8445a48156b45912827eac39fd64fc5 (patch)
tree0dc3326151072bb5d97592513e1af4b40be32e07 /views/default/navigation
downloadelgg-5f6dc365a8445a48156b45912827eac39fd64fc5.tar.gz
elgg-5f6dc365a8445a48156b45912827eac39fd64fc5.tar.bz2
Squashed 'mod/subgroups/' content from commit 835015b
git-subtree-dir: mod/subgroups git-subtree-split: 835015b66b9de6dc6de91ab39f95e1f09b2dbf84
Diffstat (limited to 'views/default/navigation')
-rw-r--r--views/default/navigation/breadcrumbs.php83
1 files changed, 83 insertions, 0 deletions
diff --git a/views/default/navigation/breadcrumbs.php b/views/default/navigation/breadcrumbs.php
new file mode 100644
index 000000000..6ceb5eacc
--- /dev/null
+++ b/views/default/navigation/breadcrumbs.php
@@ -0,0 +1,83 @@
+<?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();
+}
+
+
+$page_owner = elgg_get_page_owner_entity();
+
+if(elgg_instanceof($page_owner, 'group')) {
+
+ // $breadcrumbs[1] should corresponds to group's breadcrumb
+ // we'll look for it in crumbs link
+
+ $link = $breadcrumbs[1]['link'];
+ $guid = (string) $page_owner->guid;
+ $alias = $page_owner->alias;
+
+ $title = $breadcrumbs[1]['title'];
+ $name = $page_owner->name;
+
+ if(strpos($link, $guid) || $alias && strpos($link, $alias) || !$link && $title == $name) {
+ $first_crumb = array_shift($breadcrumbs);
+ $container = get_entity($page_owner->container_guid);
+ while(elgg_instanceof($container, 'group')) {
+
+ // TODO: I should find a better solution for this.
+ if(strpos($first_crumb['link'], 'groups') !== false) {
+ $container_link = str_replace('all', "profile/$container->guid", $first_crumb['link']);
+ } elseif(strpos($first_crumb['link'], 'discussion') !== false) {
+ $container_link = str_replace('all', "owner/$container->guid", $first_crumb['link']);
+ } else {
+ $container_link = str_replace('all', "group/$container->guid", $first_crumb['link']);
+ }
+
+ $container_link = elgg_trigger_plugin_hook('container_crumb_link', 'breadcrumbs', array('container' => $container, 'first_crumb' => $first_crumb), $container_link);
+
+ array_unshift($breadcrumbs, array(
+ 'title' => $container->name,
+ 'link' => $container_link,
+ ));
+ $container = get_entity($container->container_guid);
+ }
+ array_unshift($breadcrumbs, $first_crumb);
+ }
+}
+
+
+$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>';
+}