-
-<%INIT>
-if ( defined $current_toptab ) {
- foreach my $tab ( values %{$toptabs} ) {
- next unless $tab->{'path'} eq $current_toptab;
- @{ $tab }{ qw(subtabs current_subtab) } = ($tabs, $current_tab);
- }
-}
-
-my ($menu_depth, $almost_last, $page_tabs);
-
-# don't pull out the last submenu for 3.5-compat theme
-# see #14853 for details.
-if (RT->Config->Get( 'WebDefaultStylesheet', $session{'CurrentUser'} ) ne '3.4-compat') {
- ($menu_depth, $almost_last) = @{ $m->comp('.menu_recurse', data => $toptabs, current => $current_toptab ) };
-
- if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
- $page_tabs = {
- current_toptab => $almost_last->{current_subtab},
- %{$almost_last->{subtabs}},
- };
-
- delete $almost_last->{subtabs};
- delete $almost_last->{current_subtab};
- }
-}
-</%INIT>
-
-%# There's probably a better way to do this that involves three times as
-%# much work and redoing the whole menu/tab system... which would seem a
-%# bit out of scope.
-%#
-%# This function recurses through the menu and returns the second to
-%# last menu, that is, the menu holding the last reference to
-%# and submenu. It also returns the number of menu levels minus
-%# the last submenu.
-<%def .menu_recurse>
- <%args>
- $data => { }
- $current => ''
- $pdata => { }
- $ppdata => { }
- $level => 0
- </%args>
- <%init>
- if ($current) {
- for my $key (keys %$data) {
- next if !defined $data->{$key}->{'path'}
- || $data->{$key}->{'path'} ne $current;
- next unless ref( $data->{$key} ) eq 'HASH'
- && ref( $data->{$key}->{'subtabs'} ) eq 'HASH'
- && keys %{ $data->{$key}->{'subtabs'} };
- return $m->comp('.menu_recurse',
- data => $data->{$key}->{'subtabs'},
- current => $data->{$key}->{'current_subtab'} || '',
- pdata => $data->{$key},
- ppdata => $pdata,
- level => $level + 1,
- );
- }
- }
- $ppdata->{last_system_menu_level}++;
- return [$level, $pdata];
- </%init>
-</%def>
-