This commit was generated by cvs2svn to compensate for changes in r4407,
[freeside.git] / rt / html / Elements / CollectionAsTable / Row
1 %# BEGIN LICENSE BLOCK;
2 %# 
3 %# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com>
4 %# 
5 %# (Except where explictly superceded by other copyright notices)
6 %# 
7 %# This work is made available to you under the terms of Version 2 of
8 %# the GNU General Public License. A copy of that license should have
9 %# been provided with this software, but in any event can be snarfed
10 %# from www.gnu.org.
11 %# 
12 %# This work is distributed in the hope that it will be useful, but
13 %# WITHOUT ANY WARRANTY; without even the implied warranty of
14 %# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
15 %# General Public License for more details.
16 %# 
17 %# Unless otherwise specified, all modifications, corrections or
18 %# extensions to this work which alter its source code become the
19 %# property of Best Practical Solutions, LLC when submitted for
20 %# inclusion in the work.
21 %# 
22 %# 
23 %# END LICENSE BLOCK
24
25 <%ARGS>
26 $i => undef
27 @Format => undef
28 $record => undef
29 $maxitems => undef
30 $Depth => undef
31 $Warning => undef
32 </%ARGS>
33
34 <%PERL>
35 $m->out( '<TR class="' . ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >' );
36 my $item;
37 foreach my $column (@Format) {
38     if ( $column->{title} eq 'NEWLINE' ) {
39         while ($item < $maxitems) {
40             $m->out("<td>&nbsp;</td>\n");
41             $item++;
42         }
43         $item = 0;
44         $m->out('</TR>');
45         $m->out( '<TR class="' . 
46                ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >' );
47         next;
48     }
49     $item++;
50     $m->out('<td align="left">');
51     foreach my $subcol ( @{ $column->{output} } ) {
52         if ( $subcol =~ /^__(.*?)__$/o ) {
53             my $col = $1;
54             my $value = $m->comp('/Elements/RT__Ticket/ColumnMap', Name => $col, Attr => 'value');
55
56             if ( $value && ref($value)) {
57                 # All HTML snippets are returned by the callback function
58                 # as scalar references.  Data fetched from the objects are
59                 # plain scalars, and needs to be escaped properly.
60                 $m->out( 
61                     map { ref($_) ? $$_ : $m->interp->apply_escapes( $_ => 'h' ) }
62                     &{ $value } ( $record, $i )
63                 );
64             } else {
65                 # Simple value; just escape it.
66                 $m->out( $m->interp->apply_escapes( $value => 'h' ) );
67             }
68         }
69         else {
70             $m->out( Encode::decode_utf8($subcol) );
71         }
72     }
73     $m->out('</td>');
74 }
75 $m->out('</TR>');
76 </%PERL>