This commit was generated by cvs2svn to compensate for changes in r8690,
[freeside.git] / rt / share / html / Elements / PageLayout
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %# 
5 %# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC
6 %#                                          <jesse@bestpractical.com>
7 %# 
8 %# (Except where explicitly superseded by other copyright notices)
9 %# 
10 %# 
11 %# LICENSE:
12 %# 
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
16 %# from www.gnu.org.
17 %# 
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.
22 %# 
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.
28 %# 
29 %# 
30 %# CONTRIBUTION SUBMISSION POLICY:
31 %# 
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.)
37 %# 
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.
46 %# 
47 %# END BPS TAGGED BLOCK }}}
48 <div id="topactions">
49 % foreach my $action (reverse sort keys %{$topactions}) {
50 <span class="topaction" id="topaction-<%$action%>"><% $topactions->{"$action"}->{'html'} |n %></span>
51 % }
52 </div>
53
54 %# End of div#quickbar from /Elements/Header
55 </div>
56
57 % if ( $show_menu ) {
58 <div id="nav">
59 <& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
60 </div>
61 % }
62
63 <div id="header">
64 <h1><% $title %></h1>
65 <div id="page-navigation">
66 % my $sep       = 0;
67 % my $postsep   = 0;
68 % my $count     = 0;
69 % my $class     = { };
70
71   <ul id="page-menu" <% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
72     <div><div><div>
73 <%perl>
74  if ($page_tabs) {
75      my @tabs = ( sort grep { $_ !~ /^(?:current_toptab|this)$/ } keys %{$page_tabs});
76      my $tab_idx = -1;
77      foreach my $tab ( @tabs ) {
78          $count++;
79          $tab_idx++;
80
81          my $current = $page_tabs->{current_toptab} || "";
82          my $path    = $page_tabs->{$tab}->{'path'} || "";
83          
84          $path    =~ s#(/index\.html)?(\?)?$##gi;
85          $current =~ s#(/index\.html)?(\?)?$##gi;
86          
87          $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
88
89          my $next_tab = $tabs[$tab_idx+1];
90          if ($next_tab && $toptabs->{$next_tab}->{'pre_separator'}) {
91             $sep = 1;
92          }
93
94          $class->{a} = $path eq $current ? ' class="selected"' : undef;
95
96          my @li;
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;
102
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' );
108 </%perl>
109     <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && "&#183; "|n%><a href="<% $href %>"<%$class->{a}|n%><% $class->{a} ? ' name="focus"' : ''|n %><% $target? " target='$target'": '' |n %>><% $page_tabs->{$tab}->{'title'} %></a></li>
110 %
111 %         if ($sep) {
112     <li class="separator">&#183;&#183;&#183;</li>
113 %         }
114 %         $postsep = $sep;
115 %     }
116 % } else {
117 &nbsp;
118 % }
119     </div></div></div>
120   </ul>
121
122 % if (($actions && %$actions) || ($subactions && %$subactions)) {
123   <ul id="actions-menu">
124     <div><div><div>
125 <%perl>
126  $sep       = 0;
127  $postsep   = 0;
128  $count     = 0;
129  $class     = { };
130
131  for my $type ($actions, $subactions) {
132
133  if ($type && %$type) {
134      my @actions  = sort keys %{$type};
135      my $action_idx = -1;
136      foreach my $action (@actions) {
137          $count++;
138          $action_idx++;
139
140          $sep = $type->{$action}->{'separator'} ? 1 : 0;
141
142          my $next_action = $actions[$action_idx+1];
143          if ($next_action && $type->{$next_action}->{'pre_separator'}) {
144             $sep = 1;
145          }
146
147          my @li;
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];
152
153          $class->{li} = join ' ', @li;
154 </%perl>
155     <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">&#183; </span>]|n%>
156 %         if ($type->{"$action"}->{'html'}) {
157       <% $type->{"$action"}->{'html'} | n %>
158 %         } else {
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>
160 %         }
161     </li>
162 %         if ($sep) {
163     <li class="separator">&#183;&#183;&#183;</li>
164 %         }
165 %         $postsep = $sep;
166 %     }
167 % }
168 % }
169     </div></div></div>
170   </ul>
171 % }
172 </div>
173 </div>
174 <div id="body">
175 % $m->callback( %ARGS, CallbackName => 'BeforeBody' );
176 % $m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
177
178 <%INIT>
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);
183     }
184 }
185
186 my ($menu_depth, $almost_last, $page_tabs);
187
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 ) };
190
191     if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
192         $page_tabs = {
193             current_toptab => $almost_last->{current_subtab},
194             %{$almost_last->{subtabs}},
195         };
196
197         delete $almost_last->{subtabs};
198         delete $almost_last->{current_subtab};
199     }
200 }
201 </%INIT>
202
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
205 %# bit out of scope.
206 %#
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
210 %# the last submenu.
211 <%def .menu_recurse>
212   <%args>
213       $data    => { }
214       $current => ''
215       $pdata   => { }
216       $ppdata  => { }
217       $level   => 0
218   </%args>
219   <%init>
220     if ($current) {
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},
231               ppdata  => $pdata,
232               level   => $level + 1,
233           );
234       }
235     }
236     $ppdata->{last_system_menu_level}++;
237     return [$level, $pdata];
238   </%init>
239 </%def>
240
241 <%ARGS>
242 $current_toptab => undef
243 $current_tab => undef
244 $toptabs => undef
245 $topactions => undef
246 $tabs => undef
247 $actions => undef
248 $subactions => undef
249 $title => $m->callers(-1)->path
250 $show_menu => 1
251 </%ARGS>