1 %# BEGIN BPS TAGGED BLOCK {{{
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %# <jesse@bestpractical.com>
8 %# (Except where explicitly superseded by other copyright notices)
13 %# This work is made available to you under the terms of Version 2 of
14 %# the GNU General Public License. A copy of that license should have
15 %# been provided with this software, but in any event can be snarfed
18 %# This work is distributed in the hope that it will be useful, but
19 %# WITHOUT ANY WARRANTY; without even the implied warranty of
20 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
21 %# General Public License for more details.
23 %# You should have received a copy of the GNU General Public License
24 %# along with this program; if not, write to the Free Software
25 %# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 %# 02110-1301 or visit their web page on the internet at
27 %# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html.
30 %# CONTRIBUTION SUBMISSION POLICY:
32 %# (The following paragraph is not intended to limit the rights granted
33 %# to you to modify and distribute this software under the terms of
34 %# the GNU General Public License and is only of importance to you if
35 %# you choose to contribute your changes and enhancements to the
36 %# community by submitting them to Best Practical Solutions, LLC.)
38 %# By intentionally submitting any modifications, corrections or
39 %# derivatives to this work, or any other work intended for use with
40 %# Request Tracker, to Best Practical Solutions, LLC, you confirm that
41 %# you are the copyright holder for those contributions and you grant
42 %# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable,
43 %# royalty-free, perpetual, license to use, copy, create derivative
44 %# works based on those contributions, and sublicense and distribute
45 %# those contributions and any derivatives thereof.
47 %# END BPS TAGGED BLOCK }}}
49 % foreach my $action (reverse sort keys %{$topactions}) {
50 <span class="topaction" id="topaction-<%$action%>"><% $topactions->{"$action"}->{'html'} |n %></span>
54 %# End of div#quickbar from /Elements/Header
59 <& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
65 <div id="page-navigation">
71 <ul id="page-menu" <% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
75 my @tabs = ( sort grep { $_ !~ /^(?:current_toptab|this)$/ } keys %{$page_tabs});
77 foreach my $tab ( @tabs ) {
81 my $current = $page_tabs->{current_toptab} || "";
82 my $path = $page_tabs->{$tab}->{'path'} || "";
84 $path =~ s#(/index\.html)?(\?)?$##gi;
85 $current =~ s#(/index\.html)?(\?)?$##gi;
87 $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
89 my $next_tab = $tabs[$tab_idx+1];
90 if ($next_tab && $toptabs->{$next_tab}->{'pre_separator'}) {
94 $class->{a} = $path eq $current ? ' class="selected"' : undef;
97 push @li, 'first' if $count == 1;
98 push @li, 'pre-separator' if $sep;
99 push @li, 'post-separator' if $postsep;
100 push @li, 'last' if $tab eq $tabs[-1];
101 $class->{li} = join ' ', @li;
103 my $href = $page_tabs->{$tab}->{'path'} || "";
104 $href = RT->Config->Get('WebPath') .'/'. $href
105 unless $path =~ /^\w+:/;
106 my $target = $page_tabs->{$tab}->{'target'} || '';
107 $target = $m->interp->apply_escapes( $target, 'h' );
109 <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && "· "|n%><a href="<% $href %>"<%$class->{a}|n%><% $class->{a} ? ' name="focus"' : ''|n %><% $target? " target='$target'": '' |n %>><% $page_tabs->{$tab}->{'title'} %></a></li>
112 <li class="separator">···</li>
122 % if (($actions && %$actions) || ($subactions && %$subactions)) {
123 <ul id="actions-menu">
131 for my $type ($actions, $subactions) {
133 if ($type && %$type) {
134 my @actions = sort keys %{$type};
136 foreach my $action (@actions) {
140 $sep = $type->{$action}->{'separator'} ? 1 : 0;
142 my $next_action = $actions[$action_idx+1];
143 if ($next_action && $type->{$next_action}->{'pre_separator'}) {
148 push @li, 'first' if $count == 1;
149 push @li, 'pre-separator' if $sep;
150 push @li, 'post-separator' if $postsep;
151 push @li, 'last' if $action eq $actions[-1];
153 $class->{li} = join ' ', @li;
155 <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">· </span>]|n%>
156 % if ($type->{"$action"}->{'html'}) {
157 <% $type->{"$action"}->{'html'} | n %>
159 <a href="<%RT->Config->Get('WebPath')%>/<%$type->{$action}->{'path'}%>"<% $type->{$action}->{class} && ' class="'.$type->{$action}->{class}.'"' |n %><% $type->{$action}->{id} && ' id="'.$type->{$action}->{id}.'"' |n %>><%$type->{$action}->{'title'}%></a>
163 <li class="separator">···</li>
175 % $m->callback( %ARGS, CallbackName => 'BeforeBody' );
176 % $m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
179 if ( defined $current_toptab ) {
180 foreach my $tab ( values %{$toptabs} ) {
181 next unless $tab->{'path'} eq $current_toptab;
182 @{ $tab }{ qw(subtabs current_subtab) } = ($tabs, $current_tab);
186 my ($menu_depth, $almost_last, $page_tabs);
188 if (RT->Config->Get( 'WebDefaultStylesheet', $session{'CurrentUser'} ) ne '3.4-compat') {
189 ($menu_depth, $almost_last) = @{ $m->comp('.menu_recurse', data => $toptabs, current => $current_toptab ) };
191 if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
193 current_toptab => $almost_last->{current_subtab},
194 %{$almost_last->{subtabs}},
197 delete $almost_last->{subtabs};
198 delete $almost_last->{current_subtab};
203 %# There's probably a better way to do this that involves three times as
204 %# much work and redoing the whole menu/tab system... which would seem a
207 %# This function recurses through the menu and returns the second to
208 %# last menu, that is, the menu holding the last reference to
209 %# and submenu. It also returns the number of menu levels minus
221 for my $key (keys %$data) {
222 next if !defined $data->{$key}->{'path'}
223 || $data->{$key}->{'path'} ne $current;
224 next unless ref( $data->{$key} ) eq 'HASH'
225 && ref( $data->{$key}->{'subtabs'} ) eq 'HASH'
226 && keys %{ $data->{$key}->{'subtabs'} };
227 return $m->comp('.menu_recurse',
228 data => $data->{$key}->{'subtabs'},
229 current => $data->{$key}->{'current_subtab'} || '',
230 pdata => $data->{$key},
236 $ppdata->{last_system_menu_level}++;
237 return [$level, $pdata];
242 $current_toptab => undef
243 $current_tab => undef
249 $title => $m->callers(-1)->path