PageLayout 7.5 KB
Newer Older
1
%# BEGIN BPS TAGGED BLOCK {{{
Linda Julien's avatar
Linda Julien committed
2
%# 
3
4
%# COPYRIGHT:
%#  
Jesse Vincent's avatar
Jesse Vincent committed
5
%# This software is Copyright (c) 1996-2007 Best Practical Solutions, LLC 
6
%#                                          <jesse@bestpractical.com>
Linda Julien's avatar
Linda Julien committed
7
%# 
8
9
10
11
%# (Except where explicitly superseded by other copyright notices)
%# 
%# 
%# LICENSE:
Linda Julien's avatar
Linda Julien committed
12
13
14
15
%# 
%# This work is made available to you under the terms of Version 2 of
%# the GNU General Public License. A copy of that license should have
%# been provided with this software, but in any event can be snarfed
16
%# from www.gnu.org.
Linda Julien's avatar
Linda Julien committed
17
18
19
20
21
22
%# 
%# This work is distributed in the hope that it will be useful, but
%# WITHOUT ANY WARRANTY; without even the implied warranty of
%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
%# General Public License for more details.
%# 
23
24
%# You should have received a copy of the GNU General Public License
%# along with this program; if not, write to the Free Software
Jesse Vincent's avatar
Jesse Vincent committed
25
26
27
%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
%# 02110-1301 or visit their web page on the internet at
%# http://www.gnu.org/copyleft/gpl.html.
28
29
30
31
32
33
34
35
36
%# 
%# 
%# CONTRIBUTION SUBMISSION POLICY:
%# 
%# (The following paragraph is not intended to limit the rights granted
%# to you to modify and distribute this software under the terms of
%# the GNU General Public License and is only of importance to you if
%# you choose to contribute your changes and enhancements to the
%# community by submitting them to Best Practical Solutions, LLC.)
Linda Julien's avatar
Linda Julien committed
37
%# 
38
39
40
41
42
43
44
45
%# By intentionally submitting any modifications, corrections or
%# derivatives to this work, or any other work intended for use with
%# Request Tracker, to Best Practical Solutions, LLC, you confirm that
%# you are the copyright holder for those contributions and you grant
%# Best Practical Solutions,  LLC a nonexclusive, worldwide, irrevocable,
%# royalty-free, perpetual, license to use, copy, create derivative
%# works based on those contributions, and sublicense and distribute
%# those contributions and any derivatives thereof.
Linda Julien's avatar
Linda Julien committed
46
%# 
47
%# END BPS TAGGED BLOCK }}}
48
<div id="topactions">
49
% foreach my $action (reverse sort keys %{$topactions}) {
50
<span class="topaction"><% $topactions->{"$action"}->{'html'} |n %></span>
Linda Julien's avatar
Linda Julien committed
51
% }
52
</div>
53
54

%# End of div#quickbar from /Elements/Header
55
</div>
56

57
% if ( $show_menu ) {
58
59
60
<div id="nav">
<& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
</div>
61
% }
62

63
<div id="header">
Ruslan Zakirov's avatar
minor    
Ruslan Zakirov committed
64
<h1><% $title %></h1>
65
<div id="page-navigation">
Thomas Sibley's avatar
Thomas Sibley committed
66
67
68
69
% my $sep       = 0;
% my $postsep   = 0;
% my $count     = 0;
% my $class     = { };
70
% 
71
  <ul id="page-menu"<% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
72
    <div><div><div>
73
% if ($page_tabs) {
74
75
76
77
78
79
80
81
82
83
%     foreach my $tab (sort keys %{$page_tabs}) {
%         next if $tab =~ /^(?:current_toptab|this)$/;
%         $count++;
%
%         my $current = $page_tabs->{current_toptab} || "";
%         my $path    = $page_tabs->{$tab}->{'path'} || "";
%         
%         $path    =~ s#/index.html$##gi;
%         $current =~ s#/index.html$##gi;
%         
Thomas Sibley's avatar
Thomas Sibley committed
84
%         $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
85
86
87
88
89
90
91
%
%         $class->{a} = $path eq $current ? ' class="selected"' : undef;
%
%         my @li;
%         push @li, 'first'
%                if $count == 1;
%
Thomas Sibley's avatar
Thomas Sibley committed
92
%         push @li, 'pre-separator'
93
94
%                if $sep;
%
Thomas Sibley's avatar
Thomas Sibley committed
95
96
97
%         push @li, 'post-separator'
%                if $postsep;
%
98
99
100
%         $class->{li} = join ' ', @li;
%     
%
101
    <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && "&#183; "|n%><a href="<%RT->Config->Get('WebPath')%>/<%$page_tabs->{$tab}->{'path'}%>"<%$class->{a}|n%><% $class->{a} ? ' name="focus"' : ''|n %>><% $page_tabs->{$tab}->{'title'} %></a></li>
Thomas Sibley's avatar
Thomas Sibley committed
102
103
104
105
106
%
%         if ($sep) {
    <li class="separator">&#183;&#183;&#183;</li>
%         }
%         $postsep = $sep;
107
%     }
108
109
110
% } else {
&nbsp;
% }
111
112
    </div></div></div>
  </ul>
113

114
% if (($actions && %$actions) || ($subactions && %$subactions)) {
115
  <ul id="actions-menu">
116
    <div><div><div>
Thomas Sibley's avatar
Thomas Sibley committed
117
118
119
120
% $sep       = 0;
% $postsep   = 0;
% $count     = 0;
% $class     = { };
121
%
Thomas Sibley's avatar
Thomas Sibley committed
122
123
% for my $type ($actions, $subactions) {
%
124
% if ($type && %$type) {
Thomas Sibley's avatar
Thomas Sibley committed
125
%     foreach my $action (sort keys %{$type}) {
126
%         $count++;
Thomas Sibley's avatar
Thomas Sibley committed
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
%
%         $sep = $type->{$action}->{'separator'} ? 1 : 0;
%
%         my @li;
%         push @li, 'first'
%                if $count == 1;
%
%         push @li, 'pre-separator'
%                if $sep;
%
%         push @li, 'post-separator'
%                if $postsep;
%
%         $class->{li} = join ' ', @li;
%
142
    <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">&#183; </span>]|n%>
Thomas Sibley's avatar
Thomas Sibley committed
143
144
%         if ($type->{"$action"}->{'html'}) {
      <% $type->{"$action"}->{'html'} | n %>
145
%         } else {
146
      <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>
Thomas Sibley's avatar
Thomas Sibley committed
147
148
149
150
%         }
    </li>
%         if ($sep) {
    <li class="separator">&#183;&#183;&#183;</li>
151
%         }
Thomas Sibley's avatar
Thomas Sibley committed
152
%         $postsep = $sep;
153
%     }
154
% }
Linda Julien's avatar
Linda Julien committed
155
% }
156
    </div></div></div>
157
  </ul>
158
% }
159
</div>
160
</div>
161
<div id="body">
162
% $m->callback( %ARGS, CallbackName => 'BeforeBody' );
163
% $m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
Linda Julien's avatar
Linda Julien committed
164

165
<%INIT>
166
167
if ( defined $current_toptab ) {
    foreach my $tab ( values %{$toptabs} ) {
Ruslan Zakirov's avatar
minor    
Ruslan Zakirov committed
168
169
        next unless $tab->{'path'} eq $current_toptab;
        @{ $tab }{ qw(subtabs current_subtab) } = ($tabs, $current_tab);
Linda Julien's avatar
Linda Julien committed
170
    }
171
}
172

173
my ($menu_depth, $almost_last, $page_tabs);
174

175
if (RT->Config->Get( 'WebDefaultStylesheet', $session{'CurrentUser'} ) ne '3.4-compat') {
176
    ($menu_depth, $almost_last) = @{ $m->comp('.menu_recurse', data => $toptabs, current => $current_toptab ) };
177

178
179
180
181
182
    if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
        $page_tabs = {
            current_toptab => $almost_last->{current_subtab},
            %{$almost_last->{subtabs}},
        };
183

184
185
186
        delete $almost_last->{subtabs};
        delete $almost_last->{current_subtab};
    }
187
}
Linda Julien's avatar
Linda Julien committed
188
</%INIT>
189
190

%# There's probably a better way to do this that involves three times as
Thomas Sibley's avatar
Thomas Sibley committed
191
192
%# much work and redoing the whole menu/tab system... which would seem a
%# bit out of scope.
193
194
195
196
%#
%# 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
197
%# the last submenu.
198
199
<%def .menu_recurse>
  <%args>
200
201
202
203
204
      $data    => { }
      $current => ''
      $pdata   => { }
      $ppdata  => { }
      $level   => 0
205
206
  </%args>
  <%init>
Chia-liang Kao's avatar
Chia-liang Kao committed
207
    if ($current) {
208
      for my $key (keys %$data) {
209
210
          next if !defined $data->{$key}->{'path'} 
                    || $data->{$key}->{'path'} ne $current;
211
212
213
214
215
216
217
218
219
220
          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,
          );
221
      }
Chia-liang Kao's avatar
Chia-liang Kao committed
222
223
224
    }
    $ppdata->{last_system_menu_level}++;
    return [$level, $pdata];
225
226
227
  </%init>
</%def>

Linda Julien's avatar
Linda Julien committed
228
229
230
231
232
233
234
235
<%ARGS>
$current_toptab => undef
$current_tab => undef
$toptabs => undef
$topactions => undef
$tabs => undef
$actions => undef
$subactions => undef
236
$title => $m->callers(-1)->path
237
$show_menu => 1
Linda Julien's avatar
Linda Julien committed
238
</%ARGS>