rt 3.6.10
[freeside.git] / rt / 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 %  #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 <% include('/elements/init_calendar.html') |n %>
131 <table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%">
132     <TR HEIGHT="100%">
133       <TD valign="top">
134
135 % if (0) { ##FREESIDE MENUS INSTEAD## if ( $show_menu ) {
136 %# if ( $show_menu ) {
137 <div id="nav">
138 <& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
139 </div>
140 % }
141
142 %#already shown  <h1><%$title%></h1>
143
144 % my $sep       = 0;
145 % my $postsep   = 0;
146 % my $count     = 0;
147 % my $class     = { };
148
149
150    <TABLE BGCOLOR="#000000" BORDER=0 CELLSPACING=0 CELLPADDING=0>
151      <TR>
152
153 %#  <ul id="page-menu"<% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
154
155 % if ($page_tabs) {
156     <TD><IMG SRC="<%$fsurl%>images/gray-black-side.png" WIDTH=13 HEIGHT=25></TD>
157       <TD>
158 %     foreach my $tab (sort keys %{$page_tabs}) {
159 %         next if $tab =~ /^(?:current_toptab|this)$/;
160 %         $count++;
161 %
162 %         my $current = $page_tabs->{current_toptab} || "";
163 %         my $path    = $page_tabs->{$tab}->{'path'} || "";
164 %         
165 %         $path    =~ s#/index.html$##gi;
166 %         $current =~ s#/index.html$##gi;
167 %         
168 %         $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
169 %
170 %         $class->{a} = $path eq $current ? ' class="selected"' : undef;
171 %
172 %         my @li;
173 %         push @li, 'first'
174 %                if $count == 1;
175 %
176 %         push @li, 'pre-separator'
177 %                if $sep;
178 %
179 %         push @li, 'post-separator'
180 %                if $postsep;
181 %
182 %         $class->{li} = join ' ', @li;
183 %     
184 %
185
186 %#    <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>
187
188 %         $class->{a} = $path eq $current ? ' class="fsblackbuttonselected"' : ' class="fsblackbutton"';
189     <a href="<%$RT::WebPath%>/<%$page_tabs->{$tab}->{'path'}%>"<%$class->{a}|n%><% $class->{a} =~ 'selected' ? ' name="focus"' : ''|n %>><% $page_tabs->{$tab}->{'title'} %></a>
190
191 %     }
192       </TD>
193 %# } else {
194 %#&nbsp;
195 % }
196
197 % if (($actions && %$actions) || ($subactions && %$subactions)) {
198   <TD><IMG SRC="<%$fsurl%>images/<% $page_tabs ? 'black-gray' : 'gray-black' %>-side.png" WIDTH=13 HEIGHT=25></TD>
199 % if ( $page_tabs ) {
200   <TD BGCOLOR="#333333">&nbsp;&nbsp;</TD>
201 % }
202   <TD BGCOLOR="#333333">
203 % $sep       = 0;
204 % $postsep   = 0;
205 % $count     = 0;
206 % $class     = { };
207 %
208 % for my $type ($actions, $subactions) {
209 %
210 % if ($type && %$type) {
211 %     foreach my $action (sort keys %{$type}) {
212 %         $count++;
213 %
214 %         $sep = $type->{$action}->{'separator'} ? 1 : 0;
215 %
216 %         my @li;
217 %         push @li, 'first'
218 %                if $count == 1;
219 %
220 %         push @li, 'pre-separator'
221 %                if $sep;
222 %
223 %         push @li, 'post-separator'
224 %                if $postsep;
225 %
226 %         $class->{li} = join ' ', @li;
227 %
228
229 %#    <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">&#183; </span>]|n%>
230
231 %         #$class->{a} = $path eq $current ? ' class="fsblackbuttonselected"' : ' class="fsblackbutton"';
232 %         $type->{$action}->{class} ||= 'fsdarkbutton';
233
234 %         if ($type->{"$action"}->{'html'}) {
235       <% $type->{"$action"}->{'html'} | n %>
236 %         } else {
237       <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>
238 %         }
239
240 %     }
241 % }
242 % }
243
244   </TD>
245
246 % }
247
248     <TD><IMG SRC="<%$fsurl%>images/black-gray-side.png" WIDTH=13 HEIGHT=25></TD>
249   </TR>
250 </TABLE>
251
252
253 <div id="body">
254 <& /Elements/Callback, _CallbackName => 'BeforeBody',  %ARGS &>
255 %$m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
256
257 <%INIT>
258   foreach my $tab (sort keys %{$toptabs}) {
259     if ($current_toptab && $toptabs->{$tab}->{'path'} eq $current_toptab) {
260       $toptabs->{$tab}->{"subtabs"} = $tabs;
261       $toptabs->{$tab}->{"current_subtab"} = $current_tab;
262     }
263   }
264
265 if (! defined($AppName)) {
266   $AppName = loc("RT for [_1]", $RT::rtname);
267 }
268
269 my ($menu_depth, $almost_last, $page_tabs);
270
271 if ($RT::WebDefaultStylesheet ne '3.4-compat') {
272     ($menu_depth, $almost_last) = @{$m->comp('.menu_recurse', data => $toptabs)};
273
274     if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
275         $page_tabs = {
276             current_toptab => $almost_last->{current_subtab},
277             %{$almost_last->{subtabs}},
278         };
279
280         delete $almost_last->{subtabs};
281         delete $almost_last->{current_subtab};
282     }
283 }
284 </%INIT>
285
286 %# There's probably a better way to do this that involves three times as
287 %# much work and redoing the whole menu/tab system... which would seem a
288 %# bit out of scope.
289 %#
290 %# This function recurses through the menu and returns the second to
291 %# last menu, that is, the menu holding the last reference to
292 %# and submenu.  It also returns the number of menu levels minus
293 %# the last submenu.
294 <%def .menu_recurse>
295   <%args>
296       $data   => { }
297       $pdata  => { }
298       $ppdata => { }
299       $level  => 0
300   </%args>
301   <%init>
302       for my $key (keys %$data) {
303           return $m->comp('.menu_recurse', data   => $data->{$key}->{subtabs},
304                                            pdata  => $data->{$key},
305                                            ppdata => $pdata,
306                                            level  => $level+1)
307               if ref($data->{$key}) eq 'HASH'
308                  and defined $data->{$key}->{subtabs}
309                  and %{$data->{$key}->{subtabs}};
310       }
311       $ppdata->{last_system_menu_level}++;
312       return [$level, $pdata];
313   </%init>
314 </%def>
315
316 <%ARGS>
317 $current_toptab => undef
318 $current_tab => undef
319 $toptabs => undef
320 $topactions => undef
321 $tabs => undef
322 $actions => undef
323 $subactions => undef
324 $title => $m->callers(-1)->path
325 $AppName => undef
326 $show_menu => 1
327 </%ARGS>