think that should be it, fix bar when there's no primary $page_tabs
[freeside.git] / rt / html / Elements / PageLayout
1 %# BEGIN BPS TAGGED BLOCK {{{
2 %# 
3 %# COPYRIGHT:
4 %#  
5 %# This software is Copyright (c) 1996-2007 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/copyleft/gpl.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 %  #false laziness w/menubar.html... shouldn't these just go in freeside.css?
49 <style type="text/css">
50 a.fsblackbutton {
51          background-color:#333333;
52          color: #ffffff;
53          border:1px solid;
54          border-top-color:#cccccc;
55          border-left-color:#cccccc;
56          border-right-color:#aaaaaa;
57          border-bottom-color:#aaaaaa;
58          /*font-weight:bold;*/
59          /*padding-left:12px;
60          padding-right:12px;*/
61          padding-left:4px;
62          padding-right:4px;
63          font-size:16px;
64          text-decoration:none;
65          overflow:visible;
66          filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ff333333',EndColorStr='#ff666666')
67 }
68
69 a.fsblackbuttonselected,
70 a:link:hover.fsblackbutton,
71 a:visited:hover.fsblackbutton {
72          background-color:#7e0079;
73          color: #ffffff;
74          border:1px solid;
75          border-top-color:#cccccc;
76          border-left-color:#cccccc;
77          border-right-color:#aaaaaa;
78          border-bottom-color:#aaaaaa;
79          /*font-weight:bold;*/
80          /*padding-left:12px;
81          padding-right:12px;*/
82          padding-left:4px;
83          padding-right:4px;
84          font-size:16px;
85          text-decoration:none;
86          overflow:visible;
87          filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ff330033',EndColorStr='#ff7e0079')
88 }
89
90 a.fsdarkbutton {
91          background-color:#555555;
92          color: #ffffff;
93          border:1px solid;
94          border-top-color:#cccccc;
95          border-left-color:#cccccc;
96          border-right-color:#aaaaaa;
97          border-bottom-color:#aaaaaa;
98          /*font-weight:bold;*/
99          /*padding-left:12px;
100          padding-right:12px;*/
101          padding-left:4px;
102          padding-right:4px;
103          font-size:16px;
104          text-decoration:none;
105          overflow:visible;
106          filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ff555555',EndColorStr='#ff666666')
107 }
108
109 a.fsdarkbuttonselected,
110 a:link:hover.fsdarkbutton,
111 a:visited:hover.fsdarkbutton {
112          background-color:#7e0079;
113          color: #ffffff;
114          border:1px solid;
115          border-top-color:#cccccc;
116          border-left-color:#cccccc;
117          border-right-color:#aaaaaa;
118          border-bottom-color:#aaaaaa;
119          /*font-weight:bold;*/
120          /*padding-left:12px;
121          padding-right:12px;*/
122          padding-left:4px;
123          padding-right:4px;
124          font-size:16px;
125          text-decoration:none;
126          overflow:visible;
127          filter:progid:DXImageTransform.Microsoft.Gradient(GradientType=0,StartColorStr='#ff330033',EndColorStr='#ff7e0079')
128 }
129 </style>
130 <table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%">
131     <TR HEIGHT="100%">
132       <TD valign="top">
133
134 % if (0) { ##FREESIDE MENUS INSTEAD## if ( $show_menu ) {
135 %# if ( $show_menu ) {
136 <div id="nav">
137 <& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
138 </div>
139 % }
140
141 %#already shown  <h1><%$title%></h1>
142
143 % my $sep       = 0;
144 % my $postsep   = 0;
145 % my $count     = 0;
146 % my $class     = { };
147
148
149    <TABLE BGCOLOR="#000000" BORDER=0 CELLSPACING=0 CELLPADDING=0>
150      <TR>
151
152 %#  <ul id="page-menu"<% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
153
154 % if ($page_tabs) {
155     <TD><IMG SRC="<%$fsurl%>images/gray-black-side.png" WIDTH=13 HEIGHT=25></TD>
156       <TD>
157 %     foreach my $tab (sort keys %{$page_tabs}) {
158 %         next if $tab =~ /^(?:current_toptab|this)$/;
159 %         $count++;
160 %
161 %         my $current = $page_tabs->{current_toptab} || "";
162 %         my $path    = $page_tabs->{$tab}->{'path'} || "";
163 %         
164 %         $path    =~ s#/index.html$##gi;
165 %         $current =~ s#/index.html$##gi;
166 %         
167 %         $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
168 %
169 %         $class->{a} = $path eq $current ? ' class="selected"' : undef;
170 %
171 %         my @li;
172 %         push @li, 'first'
173 %                if $count == 1;
174 %
175 %         push @li, 'pre-separator'
176 %                if $sep;
177 %
178 %         push @li, 'post-separator'
179 %                if $postsep;
180 %
181 %         $class->{li} = join ' ', @li;
182 %     
183 %
184
185 %#    <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && "&#183; "|n%><a href="<%$RT::WebPath%>/<%$page_tabs->{$tab}->{'path'}%>"<%$class->{a}|n%><% $class->{a} ? ' name="focus"' : ''|n %>><% $page_tabs->{$tab}->{'title'} %></a></li>
186
187 %         $class->{a} = $path eq $current ? ' class="fsblackbuttonselected"' : ' class="fsblackbutton"';
188     <a href="<%$RT::WebPath%>/<%$page_tabs->{$tab}->{'path'}%>"<%$class->{a}|n%><% $class->{a} =~ 'selected' ? ' name="focus"' : ''|n %>><% $page_tabs->{$tab}->{'title'} %></a>
189
190 %     }
191       </TD>
192 %# } else {
193 %#&nbsp;
194 % }
195
196 % if (($actions && %$actions) || ($subactions && %$subactions)) {
197   <TD><IMG SRC="<%$fsurl%>images/<% $page_tabs ? 'black-gray' : 'gray-black' %>-side.png" WIDTH=13 HEIGHT=25></TD>
198 % if ( $page_tabs ) {
199   <TD BGCOLOR="#333333">&nbsp;&nbsp;</TD>
200 % }
201   <TD BGCOLOR="#333333">
202 % $sep       = 0;
203 % $postsep   = 0;
204 % $count     = 0;
205 % $class     = { };
206 %
207 % for my $type ($actions, $subactions) {
208 %
209 % if ($type && %$type) {
210 %     foreach my $action (sort keys %{$type}) {
211 %         $count++;
212 %
213 %         $sep = $type->{$action}->{'separator'} ? 1 : 0;
214 %
215 %         my @li;
216 %         push @li, 'first'
217 %                if $count == 1;
218 %
219 %         push @li, 'pre-separator'
220 %                if $sep;
221 %
222 %         push @li, 'post-separator'
223 %                if $postsep;
224 %
225 %         $class->{li} = join ' ', @li;
226 %
227
228 %#    <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">&#183; </span>]|n%>
229
230 %         #$class->{a} = $path eq $current ? ' class="fsblackbuttonselected"' : ' class="fsblackbutton"';
231 %         $type->{$action}->{class} ||= 'fsdarkbutton';
232
233 %         if ($type->{"$action"}->{'html'}) {
234       <% $type->{"$action"}->{'html'} | n %>
235 %         } else {
236       <a href="<%$RT::WebPath%>/<%$type->{$action}->{'path'}%>"<% $type->{$action}->{class} && ' class="'.$type->{$action}->{class}.'"' |n %><% $type->{$action}->{id} && ' id="'.$type->{$action}->{id}.'"' |n %>><%$type->{$action}->{'title'}%></a>
237 %         }
238
239 %     }
240 % }
241 % }
242
243   </TD>
244
245 % }
246
247     <TD><IMG SRC="<%$fsurl%>images/black-gray-side.png" WIDTH=13 HEIGHT=25></TD>
248   </TR>
249 </TABLE>
250
251
252 <div id="body">
253 <& /Elements/Callback, _CallbackName => 'BeforeBody',  %ARGS &>
254 %$m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
255
256 <%INIT>
257   foreach my $tab (sort keys %{$toptabs}) {
258     if ($current_toptab && $toptabs->{$tab}->{'path'} eq $current_toptab) {
259       $toptabs->{$tab}->{"subtabs"} = $tabs;
260       $toptabs->{$tab}->{"current_subtab"} = $current_tab;
261     }
262   }
263
264 if (! defined($AppName)) {
265   $AppName = loc("RT for [_1]", $RT::rtname);
266 }
267
268 my ($menu_depth, $almost_last, $page_tabs);
269
270 if ($RT::WebDefaultStylesheet ne '3.4-compat') {
271     ($menu_depth, $almost_last) = @{$m->comp('.menu_recurse', data => $toptabs)};
272
273     if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
274         $page_tabs = {
275             current_toptab => $almost_last->{current_subtab},
276             %{$almost_last->{subtabs}},
277         };
278
279         delete $almost_last->{subtabs};
280         delete $almost_last->{current_subtab};
281     }
282 }
283 </%INIT>
284
285 %# There's probably a better way to do this that involves three times as
286 %# much work and redoing the whole menu/tab system... which would seem a
287 %# bit out of scope.
288 %#
289 %# This function recurses through the menu and returns the second to
290 %# last menu, that is, the menu holding the last reference to
291 %# and submenu.  It also returns the number of menu levels minus
292 %# the last submenu.
293 <%def .menu_recurse>
294   <%args>
295       $data   => { }
296       $pdata  => { }
297       $ppdata => { }
298       $level  => 0
299   </%args>
300   <%init>
301       for my $key (keys %$data) {
302           return $m->comp('.menu_recurse', data   => $data->{$key}->{subtabs},
303                                            pdata  => $data->{$key},
304                                            ppdata => $pdata,
305                                            level  => $level+1)
306               if ref($data->{$key}) eq 'HASH'
307                  and defined $data->{$key}->{subtabs}
308                  and %{$data->{$key}->{subtabs}};
309       }
310       $ppdata->{last_system_menu_level}++;
311       return [$level, $pdata];
312   </%init>
313 </%def>
314
315 <%ARGS>
316 $current_toptab => undef
317 $current_tab => undef
318 $toptabs => undef
319 $topactions => undef
320 $tabs => undef
321 $actions => undef
322 $subactions => undef
323 $title => $m->callers(-1)->path
324 $AppName => undef
325 $show_menu => 1
326 </%ARGS>