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