diff options
author | Silvio Rhatto <rhatto@riseup.net> | 2014-03-16 21:01:42 -0300 |
---|---|---|
committer | Silvio Rhatto <rhatto@riseup.net> | 2014-03-16 21:01:42 -0300 |
commit | 815bb3bf5a5e8da9a7962a4a532c3129f09d5735 (patch) | |
tree | 41bec5b730cc3dca936438f9e97810e7ab3ede0a /mod/subgroups/views/default/navigation | |
parent | c102a5c9f4e9e2f78260019ccab6098435b1df19 (diff) | |
parent | 5f6dc365a8445a48156b45912827eac39fd64fc5 (diff) | |
download | elgg-815bb3bf5a5e8da9a7962a4a532c3129f09d5735.tar.gz elgg-815bb3bf5a5e8da9a7962a4a532c3129f09d5735.tar.bz2 |
Merge commit '5f6dc365a8445a48156b45912827eac39fd64fc5' as 'mod/subgroups'
Diffstat (limited to 'mod/subgroups/views/default/navigation')
-rw-r--r-- | mod/subgroups/views/default/navigation/breadcrumbs.php | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/mod/subgroups/views/default/navigation/breadcrumbs.php b/mod/subgroups/views/default/navigation/breadcrumbs.php new file mode 100644 index 000000000..6ceb5eacc --- /dev/null +++ b/mod/subgroups/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>'; +} |