[Rt-commit] r6749 - in rt/branches/3.7-EXPERIMENTAL: .

ruz at bestpractical.com ruz at bestpractical.com
Sun Jan 14 23:34:15 EST 2007


Author: ruz
Date: Sun Jan 14 23:34:14 2007
New Revision: 6749

Modified:
   rt/branches/3.7-EXPERIMENTAL/   (props changed)
   rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Row

Log:
 r4361 at cubic-pc:  cubic | 2007-01-15 06:49:36 +0300
 * get rid of warnings
 * drop one level of the code nesting


Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Row
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Row	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Row	Sun Jan 14 23:34:14 2007
@@ -57,7 +57,7 @@
 <%PERL>
 $m->out('<tr class="' . ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >' );
 my $item;
-foreach my $column (@Format) {
+foreach my $column ( @Format ) {
     if ( $column->{title} && $column->{title} eq 'NEWLINE' ) {
         while ( $item < $maxitems ) {
             $m->out(qq{<td class="collection-as-table">&nbsp;</td>\n});
@@ -75,45 +75,43 @@
 
     $m->out('<td class="collection-as-table" ');
     $m->out( 'align="' . $column->{align} . '"' ) if $column->{align};
-    $m->out( 'style="' . $column->{style} . '"' ) if ( $column->{style} );
+    $m->out( 'style="' . $column->{style} . '"' ) if $column->{style};
     $m->out('>');
 
     foreach my $subcol ( @{ $column->{output} } ) {
-        if ( $subcol =~ /^__(.*?)__$/o ) {
-            my $col   = $1;
+        unless ( $subcol =~ /^__(.*?)__$/ ) {
+            $m->out( $subcol );
+            next;
+        }
+
+        my $col = $1;
+        unless ( exists $ColumnMap->{ $col } ) {
+            $ColumnMap->{ $col } = $m->comp(
+                "/Elements/$Class/ColumnMap",
+                Name => $col,
+                Attr => 'value'
+            );
+        }
 
-            unless ( exists $ColumnMap->{ $col } ) {
-                $ColumnMap->{ $col } = $m->comp(
-                    "/Elements/$Class/ColumnMap",
-                    Name => $col,
-                    Attr => 'value'
-                );
-            }
-
-            my $value = $ColumnMap->{ $col };
-            my @out;
-
-            if ( $value && ref($value) ) {
-
-                # All HTML snippets are returned by the callback function
-                # as scalar references.  Data fetched from the objects are
-                # plain scalars, and needs to be escaped properly.
-                @out =
-                    map {
-                        ref($_) ? $$_ : $m->interp->apply_escapes( $_ => 'h' )
-                      } &{$value}( $record, $i );
-            }
-            else {
-
-                # Simple value; just escape it.
-                @out = $m->interp->apply_escapes( $value => 'h' );
-            }
-            s/\n/<br \/>/gs for @out;
-            $m->out( @out );
+        my $value = $ColumnMap->{ $col };
+        my @out;
+
+        if ( ref $value ) {
+
+            # All HTML snippets are returned by the callback function
+            # as scalar references.  Data fetched from the objects are
+            # plain scalars, and needs to be escaped properly.
+            @out = grep defined && length, map {
+                ref($_) ? $$_ : $m->interp->apply_escapes( $_ => 'h' )
+            } $value->( $record, $i );
         }
-        else {
-            $m->out($subcol);
+        elsif ( defined $value && length $value ) {
+
+            # Simple value; just escape it.
+            @out = $m->interp->apply_escapes( $value => 'h' );
         }
+        s/\n/<br \/>/gs for @out;
+        $m->out( @out ) if @out;
     }
     $m->out('</td>');
 }


More information about the Rt-commit mailing list