b9fd31f713b542e700bace1b39323bb1f6704927
[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
49 <table class="black" border=0 cellspacing=0 cellpadding=0 width="100%">
50 <tr>
51   <TD colspan=5 WIDTH="100%" STYLE="padding:0"><IMG BORDER=0 ALT="" SRC="<% $RT::URI::freeside::URL %>/images/black-gradient.png" HEIGHT="13" WIDTH="100%"></TD>
52 </tr>
53 <tr>
54
55   <div id="topactions">
56 %  my $notfirst = 0; foreach my $action (sort keys %{$topactions}) {
57     <span class="topaction">
58     <td class="blackright" ALIGN="right" VALIGN="center">
59 % $m->out($topactions->{"$action"}->{'html'});
60     </td>
61     </span>
62 % }
63   </div>
64
65 </tr>
66 </table>
67
68 %# End of div#quickbar from /Elements/Header
69 </div>
70
71 <table border=0 cellspacing=0 cellpadding=0 width="100%" height="100%">
72   <TR>
73     <TD STYLE="padding:0" WIDTH="100%"><IMG BORDER=0 ALT="" SRC="<% $RT::URI::freeside::URL %>/images/black-gray-top.png" HEIGHT="13" WIDTH="100%"></TD>
74     </TR>
75     <TR HEIGHT="100%">
76       <TD>
77
78 % if ( $show_menu ) {
79 <div id="nav">
80 <& /Elements/Menu, toptabs => $toptabs, current_toptab => $current_toptab &>
81 </div>
82 % }
83
84 <div id="header">
85   <h1><%$title%></h1>
86
87 % my $sep       = 0;
88 % my $postsep   = 0;
89 % my $count     = 0;
90 % my $class     = { };
91
92   <ul id="page-menu"<% (($actions && %$actions) || ($subactions && %$subactions)) && q[ class="actions-present"] | n %>>
93     <div><div><div>
94 % if ($page_tabs) {
95 %     foreach my $tab (sort keys %{$page_tabs}) {
96 %         next if $tab =~ /^(?:current_toptab|this)$/;
97 %         $count++;
98 %
99 %         my $current = $page_tabs->{current_toptab} || "";
100 %         my $path    = $page_tabs->{$tab}->{'path'} || "";
101 %         
102 %         $path    =~ s#/index.html$##gi;
103 %         $current =~ s#/index.html$##gi;
104 %         
105 %         $sep = $toptabs->{$tab}->{'separator'} ? 1 : 0;
106 %
107 %         $class->{a} = $path eq $current ? ' class="selected"' : undef;
108 %
109 %         my @li;
110 %         push @li, 'first'
111 %                if $count == 1;
112 %
113 %         push @li, 'pre-separator'
114 %                if $sep;
115 %
116 %         push @li, 'post-separator'
117 %                if $postsep;
118 %
119 %         $class->{li} = join ' ', @li;
120 %     
121 %
122     <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>
123 %
124 %         if ($sep) {
125     <li class="separator">&#183;&#183;&#183;</li>
126 %         }
127 %         $postsep = $sep;
128 %     }
129 % } else {
130 &nbsp;
131 % }
132     </div></div></div>
133   </ul>
134
135 % if (($actions && %$actions) || ($subactions && %$subactions)) {
136   <ul id="actions-menu">
137     <div><div><div>
138 % $sep       = 0;
139 % $postsep   = 0;
140 % $count     = 0;
141 % $class     = { };
142 %
143 % for my $type ($actions, $subactions) {
144 %
145 % if ($type && %$type) {
146 %     foreach my $action (sort keys %{$type}) {
147 %         $count++;
148 %
149 %         $sep = $type->{$action}->{'separator'} ? 1 : 0;
150 %
151 %         my @li;
152 %         push @li, 'first'
153 %                if $count == 1;
154 %
155 %         push @li, 'pre-separator'
156 %                if $sep;
157 %
158 %         push @li, 'post-separator'
159 %                if $postsep;
160 %
161 %         $class->{li} = join ' ', @li;
162 %
163     <li<% $class->{li} ? qq[ class="$class->{li}"] : ''|n %>><% $count > 1 && !$postsep && qq[<span class="bullet">&#183; </span>]|n%>
164 %         if ($type->{"$action"}->{'html'}) {
165       <% $type->{"$action"}->{'html'} | n %>
166 %         } else {
167       <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>
168 %         }
169     </li>
170 %         if ($sep) {
171     <li class="separator">&#183;&#183;&#183;</li>
172 %         }
173 %         $postsep = $sep;
174 %     }
175 % }
176 % }
177     </div></div></div>
178   </ul>
179 % }
180 </div>
181
182 <div id="body">
183 <& /Elements/Callback, _CallbackName => 'BeforeBody',  %ARGS &>
184 %$m->flush_buffer(); # we've got the page laid out, let's flush the buffer;
185
186 <%INIT>
187   foreach my $tab (sort keys %{$toptabs}) {
188     if ($current_toptab && $toptabs->{$tab}->{'path'} eq $current_toptab) {
189       $toptabs->{$tab}->{"subtabs"} = $tabs;
190       $toptabs->{$tab}->{"current_subtab"} = $current_tab;
191     }
192   }
193
194 if (! defined($AppName)) {
195   $AppName = loc("RT for [_1]", $RT::rtname);
196 }
197
198 my ($menu_depth, $almost_last, $page_tabs);
199
200 if ($RT::WebDefaultStylesheet ne '3.4-compat') {
201     ($menu_depth, $almost_last) = @{$m->comp('.menu_recurse', data => $toptabs)};
202
203     if (defined $almost_last->{subtabs} and %{$almost_last->{subtabs}}) {
204         $page_tabs = {
205             current_toptab => $almost_last->{current_subtab},
206             %{$almost_last->{subtabs}},
207         };
208
209         delete $almost_last->{subtabs};
210         delete $almost_last->{current_subtab};
211     }
212 }
213 </%INIT>
214
215 %# There's probably a better way to do this that involves three times as
216 %# much work and redoing the whole menu/tab system... which would seem a
217 %# bit out of scope.
218 %#
219 %# This function recurses through the menu and returns the second to
220 %# last menu, that is, the menu holding the last reference to
221 %# and submenu.  It also returns the number of menu levels minus
222 %# the last submenu.
223 <%def .menu_recurse>
224   <%args>
225       $data   => { }
226       $pdata  => { }
227       $ppdata => { }
228       $level  => 0
229   </%args>
230   <%init>
231       for my $key (keys %$data) {
232           return $m->comp('.menu_recurse', data   => $data->{$key}->{subtabs},
233                                            pdata  => $data->{$key},
234                                            ppdata => $pdata,
235                                            level  => $level+1)
236               if ref($data->{$key}) eq 'HASH'
237                  and defined $data->{$key}->{subtabs}
238                  and %{$data->{$key}->{subtabs}};
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 $AppName => undef
255 $show_menu => 1
256 </%ARGS>