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

ruz at bestpractical.com ruz at bestpractical.com
Sun Dec 25 04:12:34 EST 2005


Author: ruz
Date: Sun Dec 25 02:45:14 2005
New Revision: 4350

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

Log:
 r1556 at cubic-pc:  cubic | 2005-12-25 10:48:44 +0300
  r1553 at cubic-pc:  cubic | 2005-12-24 09:13:14 +0300
  * allow callback in in column's title
 


Modified: rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Header
==============================================================================
--- rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Header	(original)
+++ rt/branches/3.7-EXPERIMENTAL/html/Elements/CollectionAsTable/Header	Sun Dec 25 02:45:14 2005
@@ -61,7 +61,6 @@
 
 my $item = 0;
 foreach my $col (@Format) {
-    $item++;
     if ( $col->{title} eq 'NEWLINE' ) {
         while ( $item < $maxitems ) {
             $m->out(qq{<th class="collection-as-table">&nbsp;</th>\n});
@@ -70,54 +69,74 @@
 
         $item = 0;
         $m->out(qq{</tr>\n<tr class="collection-as-table">});
+        next;
     }
-    else {
-        $m->out('<th class="collection-as-table">');
-        my $title = $col->{title};
-        $title =~ s/^__(.*)__$/$1/o;
-        $title = (
-            $m->comp(
-                '/Elements/RT__Ticket/ColumnMap',
-                Name => $title,
-                Attr => 'title'
-              )
-              || $title
-        );
-        if (
-               $AllowSorting
-            && $col->{'attribute'}
-            && $m->comp(
-                '/Elements/RT__Ticket/ColumnMap',
-                Name => $col->{'attribute'},
-                Attr => 'attribute'
-            )
-          )
-        {
-
-            $m->out(
-                '<a href="' . $BaseURL
-                  . $m->comp(
-                    '/Elements/QueryString',
-                    %generic_query_args,
-                    OrderBy => (
-                        $m->comp(
-                            '/Elements/RT__Ticket/ColumnMap',
-                            Name => $col->{'attribute'},
-                            Attr => 'attribute'
-                          )
-                          || $col->{'attribute'}
-                    ),
-                    Order => ( $ARGS{'Order'} eq 'ASC' ? 'DESC' : 'ASC' )
-                  )
-                  . '">'
-                  . loc($title) . '</a>'
-            );
+
+    $item++;
+
+    $m->out('<th class="collection-as-table">');
+    my $title = $col->{title};
+    $title =~ s/^__(.*)__$/$1/o;
+
+    my $tmp = $m->comp(
+        '/Elements/RT__Ticket/ColumnMap',
+        Name => $title,
+        Attr => 'title',
+    );
+
+    unless( $tmp ) {
+        $title = $m->interp->apply_escapes( loc($title), 'h' );
+    } else {
+        if ( UNIVERSAL::isa( $tmp, 'CODE' ) ) {
+            my @tmp = $tmp->( $title );
+            $title = @tmp > 1? \@tmp: shift @tmp || '';
+        } else {
+            $title = $tmp;
         }
-        else {
-            $m->out( loc($title) );
+        if( UNIVERSAL::isa( $title, 'ARRAY' ) ) {
+            $title = join '', map { ref $_? $$_: $m->interp->apply_escapes( $_, 'h' ) } @$title;
+        } elsif( UNIVERSAL::isa( $title, 'SCALAR' ) ) {
+            $title = $$title;
+        } else {
+            $title = $m->interp->apply_escapes( $title, 'h' );
         }
-        $m->out('</th>');
     }
+
+    if (
+           $AllowSorting
+        && $col->{'attribute'}
+        && $m->comp(
+            '/Elements/RT__Ticket/ColumnMap',
+            Name => $col->{'attribute'},
+            Attr => 'attribute'
+        )
+      )
+    {
+
+        $m->out(
+            '<a href="' . $BaseURL
+              . $m->comp(
+                '/Elements/QueryString',
+                %generic_query_args,
+                OrderBy => (
+                    $m->comp(
+                        '/Elements/RT__Ticket/ColumnMap',
+                        Name => $col->{'attribute'},
+                        Attr => 'attribute'
+                      )
+                      || $col->{'attribute'}
+                ),
+                Order => ( $ARGS{'Order'} eq 'ASC' ? 'DESC' : 'ASC' )
+              )
+              . '">'
+              . $title
+              . '</a>'
+        );
+    }
+    else {
+        $m->out( $title );
+    }
+    $m->out('</th>');
 }
 </%perl>
 </tr>

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 Dec 25 02:45:14 2005
@@ -68,10 +68,13 @@
               . '" >' );
         next;
     }
+
     $item++;
+
     $m->out('<td class="collection-as-table" ');
-    $m->out( 'align="' . $column->{align} . '"' ) if ( $column->{align} );
+    $m->out( 'align="' . $column->{align} . '"' ) if $column->{align};
     $m->out('>');
+
     foreach my $subcol ( @{ $column->{output} } ) {
         if ( $subcol =~ /^__(.*?)__$/o ) {
             my $col   = $1;
@@ -98,7 +101,7 @@
                 # Simple value; just escape it.
                 @out = $m->interp->apply_escapes( $value => 'h' );
             }
-            s/\n/<br>/gs for @out;
+            s/\n/<br \/>/gs for @out;
             $m->out( @out );
         }
         else {


More information about the Rt-commit mailing list