diff options
author | ivan <ivan> | 2004-12-03 20:40:48 +0000 |
---|---|---|
committer | ivan <ivan> | 2004-12-03 20:40:48 +0000 |
commit | f7fd2a3e34da751cbc02bbf215e99c6dc89adc15 (patch) | |
tree | 495d4c785a1aac113236511cdf8c1e5ce2a4f5ee /rt/html/Elements/CollectionAsTable | |
parent | 2d98f7dcda48d4c38e748d3301cce956cb5e6c06 (diff) | |
parent | d39d52aac8f38ea9115628039f0df5aa3ac826de (diff) |
This commit was generated by cvs2svn to compensate for changes in r3921,
which included commits to RCS files with non-trunk default branches.
Diffstat (limited to 'rt/html/Elements/CollectionAsTable')
-rw-r--r-- | rt/html/Elements/CollectionAsTable/Header | 91 | ||||
-rw-r--r-- | rt/html/Elements/CollectionAsTable/ParseFormat | 81 | ||||
-rw-r--r-- | rt/html/Elements/CollectionAsTable/Row | 69 |
3 files changed, 241 insertions, 0 deletions
diff --git a/rt/html/Elements/CollectionAsTable/Header b/rt/html/Elements/CollectionAsTable/Header new file mode 100644 index 000000000..2d1574dea --- /dev/null +++ b/rt/html/Elements/CollectionAsTable/Header @@ -0,0 +1,91 @@ +%# BEGIN LICENSE BLOCK; +%# +%# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> +%# +%# (Except where explictly superceded by other copyright notices) +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# Unless otherwise specified, all modifications, corrections or +%# extensions to this work which alter its source code become the +%# property of Best Practical Solutions, LLC when submitted for +%# inclusion in the work. +%# +%# +%# END LICENSE BLOCK + +<%ARGS> +@Format => undef +$AllowSorting => undef +$Order=>undef +$BaseURL => undef +$Query => undef +$Rows => undef +$Page => undef +$maxitems => undef +</%ARGS> +<TR> +<%perl> + +my %generic_query_args = ( Query => $Query, Rows => $Rows, Page => $Page ); + +my $item = 0; +$$maxitems = 0; +foreach my $col (@Format) { + $item++; + $$maxitems = $item if $item > $$maxitems; + if ( $col->{title} eq 'NEWLINE' ) { + $m->out('</TR> <TR>'); + $item = 0; + } + else { + $m->out('<TH align="center">'); + 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>' + ); + } + else { + $m->out( loc($title) ); + } + $m->out('</TH>'); + } +} +</%perl> +</TR> diff --git a/rt/html/Elements/CollectionAsTable/ParseFormat b/rt/html/Elements/CollectionAsTable/ParseFormat new file mode 100644 index 000000000..c7b709bff --- /dev/null +++ b/rt/html/Elements/CollectionAsTable/ParseFormat @@ -0,0 +1,81 @@ +%# BEGIN LICENSE BLOCK; +%# +%# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> +%# +%# (Except where explictly superceded by other copyright notices) +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# Unless otherwise specified, all modifications, corrections or +%# extensions to this work which alter its source code become the +%# property of Best Practical Solutions, LLC when submitted for +%# inclusion in the work. +%# +%# +%# END LICENSE BLOCK + +<%ARGS> +$Format +</%ARGS> + +<%init> +use Regexp::Common qw(delimited); +my @Columns; +#my $quoted = qr[$RE{delimited}{-delim=>qq{\'\"}}|(?:\{|\}|\w|\.)+]; +my $justquoted = qr[$RE{delimited}{-delim=>qq{\'\"}}]; +#my $quoted = $RE{quoted}{-esc}; +my $word = qr [(?:\{|\}|\w|\.)+]; + +while ($Format =~ /($justquoted|$word)/igx) { + my $col = $1; + + if ($col =~ /^$RE{quoted}{-esc}$/) { + substr($col,0,1) = ""; + substr($col,-1,1) = ""; + } + + my $colref; + if ( $col =~ s/\/STYLE:(.*?)$//io ) { + $colref->{'style'} = $1; + } + if ( $col =~ s/\/CLASS:(.*?)$//io ) { + $colref->{'class'} = $1; + } + if ( $col =~ s/\/TITLE:(.*?)$//io ) { + $colref->{'title'} = $1; + } + if ( $col =~ /__(.*?)__/gio ) { + my @subcols; + while ( $col =~ s/^(.*?)__(.*?)__//o ) { + push ( @subcols, $1 ) if ($1); + push ( @subcols, "__$2__" ); + $colref->{'attribute'} = $2; + } + push ( @subcols, $col ); + @{ $colref->{'output'} } = @subcols; + } + else { + @{ $colref->{'output'} } = ( "__" . $col . "__" ); + $colref->{'attribute'} = $col; + } + + if ( !$colref->{'title'} && grep { /^__(.*?)__$/io } + @{ $colref->{'output'} } ) + { + $colref->{'title'} = $1; + $colref->{'attribute'} = $1; + } + + + push @Columns, $colref; +} + return(@Columns); +</%init> diff --git a/rt/html/Elements/CollectionAsTable/Row b/rt/html/Elements/CollectionAsTable/Row new file mode 100644 index 000000000..926317be9 --- /dev/null +++ b/rt/html/Elements/CollectionAsTable/Row @@ -0,0 +1,69 @@ +%# BEGIN LICENSE BLOCK; +%# +%# Copyright (c) 1996-2003 Jesse Vincent <jesse@bestpractical.com> +%# +%# (Except where explictly superceded by other copyright notices) +%# +%# This work is made available to you under the terms of Version 2 of +%# the GNU General Public License. A copy of that license should have +%# been provided with this software, but in any event can be snarfed +%# from www.gnu.org. +%# +%# This work is distributed in the hope that it will be useful, but +%# WITHOUT ANY WARRANTY; without even the implied warranty of +%# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%# General Public License for more details. +%# +%# Unless otherwise specified, all modifications, corrections or +%# extensions to this work which alter its source code become the +%# property of Best Practical Solutions, LLC when submitted for +%# inclusion in the work. +%# +%# +%# END LICENSE BLOCK + +<%ARGS> +$i => undef +@Format => undef +$record => undef +$maxitems => undef +$Depth => undef +$Warning => undef +</%ARGS> + +<%PERL> +$m->out( '<TR class="' . ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >' ); +my $item; +foreach my $column (@Format) { + if ( $column->{title} eq 'NEWLINE' ) { + while ($item < $maxitems) { + $m->out("<td> </td>\n"); + $item++; + } + $item = 0; + $m->out('</TR>'); + $m->out( '<TR class="' . + ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >' ); + next; + } + $item++; + $m->out('<td align="left">'); + foreach my $subcol ( @{ $column->{output} } ) { + if ( $subcol =~ /^__(.*?)__$/o ) { + my $col = $1; + my $value = $m->comp('/Elements/RT__Ticket/ColumnMap', Name => $col, Attr => 'value'); + + if ( $value && ref($value)) { + $m->out( &{ $value } ( $record, $i ) ); + } else { + $m->out($value ); + } + } + else { + $m->out( Encode::decode_utf8($subcol) ); + } + } + $m->out('</td>'); +} +$m->out('</TR>'); +</%PERL> |