skin RT 3.8, RT#6640
[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
49 % if (0) { ## new ticket via customer, and we already have a ticket search box
50 <div id="topactions">
51 % foreach my $action (reverse sort keys %{$topactions}) {
52 <span class="topaction" id="topaction-<%$action%>"><% $topactions->{"$action"}->{'html'} |n %></span>
53 % }
54 </div>
55 % }
56
57 % if (0) { ##FREESIDE MENUS INSTEAD## if ( $show_menu ) {
58 % if ( $show_menu ) {
59 <div id="nav">
60 <& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
61 </div>
62 % }
63 % }
64
65 <div id="header">
66 %#already shown <h1><% $title %></h1>
67 <div id="page-navigation">
68 % my $sep       = 0;
69 % my $postsep   = 0;
70 % my $count     = 0;
71 % my $class     = { };
72
73   <ul id="page-menu" <% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
74     <div><div><div>
75 <%perl>
76  if ($page_tabs) {
77      my @tabs = ( sort grep { $_ !~ /^(?:current_toptab|this)$/ } keys %{$page_tabs});
78      my $tab_idx = -1;
79      foreach my $tab ( @tabs ) {
80          $count++;
81          $tab_idx++;
82
83          my $current = $page_tabs->{current_toptab} || "";
84          my $path    = $page_tabs->{$tab}->{'path'} || "";
85          
86          $path    =~ s#(/index\.html)?(\?)?$##gi;
87          $current =~ s#(/index\.html)?(\?)?$##gi;
88          
89          $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
90
91          my $next_tab = $tabs[$tab_idx+1];
92          if ($next_tab && $toptabs->{$next_tab}->{'pre_separator'}) {
93             $sep = 1;
94          }
95
96          $class->{a} = $path eq $current ? ' class="selected"' : undef;
97
98          my @li;
99          push @li, 'first' if $count == 1;
100          push @li, 'pre-separator' if $sep;
101          push @li, 'post-separator' if $postsep;
102          push @li, 'last' if $tab eq $tabs[-1];
103          $class->{li} = join ' ', @li;
104
105          my $href = $page_tabs->{$tab}->{'path'} || "";
106          $href = RT->Config->Get('WebPath') .'/'. $href
107             unless $path =~ /^\w+:/;
108          my $target = $page_tabs->{$tab}->{'target'} || '';
109          $target = $m->interp->apply_escapes( $target, 'h' );
110 </%perl>
111     <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>
112 %
113 %         if ($sep) {
114     <li class="separator">&#183;&#183;&#183;</li>
115 %         }
116 %         $postsep = $sep;
117 %     }
118 % } else {
119 &nbsp;
120 % }
121     </div></div></div>
122   </ul>
123
124 % if (($actions && %$actions) || ($subactions && %$subactions)) {
125   <ul id="actions-menu">
126     <div><div><div>
127 <%perl>
128  $sep       = 0;
129  $postsep   = 0;
130  $count     = 0;
131  $class     = { };
132
133  for my $type ($actions, $subactions) {
134
135  if ($type && %$type) {
136      my @actions  = sort keys %{$type};
137      my $action_idx = -1;
138      foreach my $action (@actions) {
139          $count++;
140          $action_idx++;
141
142          $sep = $type->{$action}->{'separator'} ? 1 : 0;
143
144          my $next_action = $actions[$action_idx+1];
145          if ($next_action && $type->{$next_action}->{'pre_separator'}) {
146             $sep = 1;
147          }
148
149          my @li;
150          push @li, 'first' if $count == 1;
151          push @li, 'pre-separator' if $sep;
152          push @li, 'post-separator' if $postsep;
153          push @li, 'last' if $action  eq $actions[-1];
154
155          $class->{li} = join ' ', @li;
156 </%perl>
157     <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">&#183; </span>]|n%>
158 %         if ($type->{"$action"}->{'html'}) {
159       <% $type->{"$action"}->{'html'} | n %>
160 %         } else {
161       <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>
162 %         }
163     </li>
164 %         if ($sep) {
165     <li class="separator">&#183;&#183;&#183;</li>
166 %         }
167 %         $postsep = $sep;
168 %     }
169 % }
170 % }
171     </div></div></div>
172   </ul>
173 % }
174 </div>
175 </div>
176 <div id="body">
177 % $m->callback( %ARGS, CallbackName => 'BeforeBody' );
178 % $m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
179
180 <%INIT>
181 if ( defined $current_toptab ) {
182     foreach my $tab ( values %{$toptabs} ) {
183         next unless $tab->{'path'} eq $current_toptab;
184         @{ $tab }{ qw(subtabs current_subtab) } = ($tabs, $current_tab);
185     }
186 }
187
188 my ($menu_depth, $almost_last, $page_tabs);
189
190 if (RT->Config->Get( 'WebDefaultStylesheet', $session{'CurrentUser'} ) ne '3.4-compat') {
191     ($menu_depth, $almost_last) = @{ $m->comp('.menu_recurse', data => $toptabs, current => $current_toptab ) };
192
193     if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
194         $page_tabs = {
195             current_toptab => $almost_last->{current_subtab},
196             %{$almost_last->{subtabs}},
197         };
198
199         delete $almost_last->{subtabs};
200         delete $almost_last->{current_subtab};
201     }
202 }
203 </%INIT>
204
205 %# There's probably a better way to do this that involves three times as
206 %# much work and redoing the whole menu/tab system... which would seem a
207 %# bit out of scope.
208 %#
209 %# This function recurses through the menu and returns the second to
210 %# last menu, that is, the menu holding the last reference to
211 %# and submenu.  It also returns the number of menu levels minus
212 %# the last submenu.
213 <%def .menu_recurse>
214   <%args>
215       $data    => { }
216       $current => ''
217       $pdata   => { }
218       $ppdata  => { }
219       $level   => 0
220   </%args>
221   <%init>
222     if ($current) {
223       for my $key (keys %$data) {
224           next if !defined $data->{$key}->{'path'} 
225                     || $data->{$key}->{'path'} ne $current;
226           next unless    ref( $data->{$key} ) eq 'HASH'
227                       && ref( $data->{$key}->{'subtabs'} ) eq 'HASH'
228                       && keys %{ $data->{$key}->{'subtabs'} };
229           return $m->comp('.menu_recurse',
230               data    => $data->{$key}->{'subtabs'},
231               current => $data->{$key}->{'current_subtab'} || '',
232               pdata   => $data->{$key},
233               ppdata  => $pdata,
234               level   => $level + 1,
235           );
236       }
237     }
238     $ppdata->{last_system_menu_level}++;
239     return [$level, $pdata];
240   </%init>
241 </%def>
242
243 <%ARGS>
244 $current_toptab => undef
245 $current_tab => undef
246 $toptabs => undef
247 $topactions => undef
248 $tabs => undef
249 $actions => undef
250 $subactions => undef
251 $title => $m->callers(-1)->path
252 $show_menu => 1
253 </%ARGS>