Commit f93ee67c authored by Chris Graham's avatar Chris Graham
Browse files

Fixed MANTIS-4945 (Breadcrumb label substitutions don't work with virtual roots)

parent e0e0bade
Loading
Loading
Loading
Loading
+4 −3
Original line number Diff line number Diff line
@@ -60,7 +60,6 @@ function load_breadcrumb_substitutions($segments)
    $segments_new = array();
    $done_one = false;
    $final = false;

    foreach ($segments as $i => $segment) { // Loop by active breadcrumb segments
        $include_self = true;

@@ -102,9 +101,11 @@ function load_breadcrumb_substitutions($segments)
                            $done_one = true;
                        }

                        if ($segment[0] === null) { // New label for active page specified here?
                        if ($substitution_label !== null) {
                            if ($segment[0] === null) { // New label for active page specified here?
                                $GLOBALS['BREADCRUMB_SET_SELF'] = $substitution_label;
                            } elseif (!isset($segments[$i + 1])) { // New label for last segment specified here?
                                $segment[1] = $substitution_label;
                            }
                        }

+9 −3
Original line number Diff line number Diff line
@@ -514,10 +514,16 @@ function breadcrumbs($show_self = true)

    // Substitutions
    if ((addon_installed('breadcrumbs')) && (function_exists('xml_parser_create'))) {
        // We may need to add in the final label so load_breadcrumb_substitutions can see and match on it; we will then pop that final label knowing that load_breadcrumb_substitutions altered the BREADCRUMB_SET_SELF global if it needed to
        require_code('breadcrumbs');
        $needs_pop = ($GLOBALS['BREADCRUMB_SET_SELF'] !== null) || ($GLOBALS['DISPLAYED_TITLE'] !== null);
        if ($needs_pop) {
            $BREADCRUMB_SET_PARENTS[] = array(null, ($GLOBALS['BREADCRUMB_SET_SELF'] !== null) ? $GLOBALS['BREADCRUMB_SET_SELF'] : $GLOBALS['DISPLAYED_TITLE']);
        $needs_pop = false;
        if (($GLOBALS['BREADCRUMB_SET_SELF'] !== null) || ($GLOBALS['DISPLAYED_TITLE'] !== null)) {
            $last_segment_label = isset($BREADCRUMB_SET_PARENTS[count($BREADCRUMB_SET_PARENTS) - 1]) ? $BREADCRUMB_SET_PARENTS[count($BREADCRUMB_SET_PARENTS) - 1][1] : null;
            $new_last_segment_label = ($GLOBALS['BREADCRUMB_SET_SELF'] !== null) ? $GLOBALS['BREADCRUMB_SET_SELF'] : $GLOBALS['DISPLAYED_TITLE'];
            if (($last_segment_label === null) || ((is_object($new_last_segment_label) ? $new_last_segment_label->evaluate() : $new_last_segment_label) != (is_object($last_segment_label) ? $last_segment_label->evaluate() : $last_segment_label))) {
                $BREADCRUMB_SET_PARENTS[] = array(null, $last_segment_label);
                $needs_pop = true;
            }
        }
        $BREADCRUMB_SET_PARENTS = load_breadcrumb_substitutions($BREADCRUMB_SET_PARENTS);
        if ($needs_pop) {