diff options
author | ivan <ivan> | 2009-12-31 13:16:41 +0000 |
---|---|---|
committer | ivan <ivan> | 2009-12-31 13:16:41 +0000 |
commit | b4b0c7e72d7eaee2fbfc7022022c9698323203dd (patch) | |
tree | ba4cd21399e412c32fe3737eaa8478e3271509f9 /rt/share/html/Elements/CollectionAsTable | |
parent | 2dfda73eeb3eae2d4f894099754794ef07d060dd (diff) |
import rt 3.8.7
Diffstat (limited to 'rt/share/html/Elements/CollectionAsTable')
-rw-r--r-- | rt/share/html/Elements/CollectionAsTable/Header | 142 | ||||
-rw-r--r-- | rt/share/html/Elements/CollectionAsTable/ParseFormat | 108 | ||||
-rw-r--r-- | rt/share/html/Elements/CollectionAsTable/Row | 143 |
3 files changed, 393 insertions, 0 deletions
diff --git a/rt/share/html/Elements/CollectionAsTable/Header b/rt/share/html/Elements/CollectionAsTable/Header new file mode 100644 index 000000000..550ce9f3f --- /dev/null +++ b/rt/share/html/Elements/CollectionAsTable/Header @@ -0,0 +1,142 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# 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. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%ARGS> +$Class => 'RT__Ticket' + +@Format => undef +$FormatString => undef +@OrderBy => () +@Order => () +$Query => undef +$Rows => undef +$Page => undef +$GenericQueryArgs => undef +$maxitems => undef + +$AllowSorting => undef +$BaseURL => undef +@PassArguments => qw(Query Format Rows Page Order OrderBy) +</%ARGS> +<tr class="collection-as-table"> +<%PERL> + +my $generic_query_args = $GenericQueryArgs || {map { $_ => $ARGS{$_} } @PassArguments}; +# backward compatibility workaround +$generic_query_args->{'Format'} = $FormatString if grep $_ eq 'Format', @PassArguments; + +my $item = 0; +foreach my $col ( @Format ) { + my $title = $col->{'title'} || ''; + if ( $title eq 'NEWLINE' ) { + while ( $item < $maxitems ) { + $m->out(qq{<th class="collection-as-table"> </th>\n}); + $item++; + } + + $item = 0; + $m->out(qq{</tr>\n<tr class="collection-as-table">}); + next; + } elsif ( $title eq 'NBSP' ) { + $item++; + $m->out(qq{<th class="collection-as-table"> </th>\n}); + next; + } + + my $span = $col->{'span'}; + $item += ($span || 1); + + $m->out('<th class="collection-as-table"'); + $m->out(' colspan="' . $m->interp->apply_escapes($span => 'h') . '"') + if $span; + $m->out('>'); + + # if title is not defined then use defined attribute or last + # one we saw in the format + unless ( defined $col->{'title'} ) { + my $attr = $col->{'attribute'} || $col->{'last_attribute'}; + my $tmp = $m->comp( '/Elements/ColumnMap', + Class => $Class, + Name => $attr, + Attr => 'title', + ); + $title = ProcessColumnMapValue( $tmp, Arguments => [ $attr ] ); + } else { + $title = $m->comp('/Elements/ScrubHTML', Content => $title); + } + + if ( $AllowSorting and $col->{'attribute'} + and my $attr = $m->comp( + "/Elements/ColumnMap", + Class => $Class, + Name => $col->{'attribute'}, + Attr => 'attribute' + ) + ) + { + $attr = ProcessColumnMapValue( $attr, Arguments => [ $col->{'attribute'} ], Escape => 0 ); + + my $new_order = 'ASC'; + $new_order = $Order[0] eq 'ASC'? 'DESC': 'ASC' + if $OrderBy[0] && $OrderBy[0] eq $attr; + + $m->out( + '<a href="' . $BaseURL + . $m->comp( '/Elements/QueryString', + %$generic_query_args, + OrderBy => $attr, Order => $new_order + ) + . '">'. loc($title) .'</a>' + ); + } + else { + $m->out( loc($title) ); + } + $m->out('</th>'); +} +</%PERL> +</tr> diff --git a/rt/share/html/Elements/CollectionAsTable/ParseFormat b/rt/share/html/Elements/CollectionAsTable/ParseFormat new file mode 100644 index 000000000..d58246fff --- /dev/null +++ b/rt/share/html/Elements/CollectionAsTable/ParseFormat @@ -0,0 +1,108 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# 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. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%ARGS> +$Format +</%ARGS> + +<%init> +use Regexp::Common qw/delimited/; +my @Columns; + +while ($Format =~ /($RE{delimited}{-delim=>qq{\'"}}|[{}\w.]+)/go) { + my $col = $1; + + if ($col =~ /^$RE{quoted}$/o) { + substr($col,0,1) = ""; + substr($col,-1,1) = ""; + } + + my $colref = { }; + + $m->callback(CallbackName => 'PreColumn', Column => $colref, col => \$col); + + while ( $col =~ s{/(STYLE|CLASS|TITLE|ALIGN|SPAN|ATTRIBUTE):([^/]*)}{}i ) { + $colref->{ lc $1 } = $2; + } + $colref->{'last_attribute'} = $colref->{'attribute'}; + + unless ( length $col ) { + $colref->{'output'} = []; + $colref->{'last_attribute'} = $colref->{'attribute'} = '' + unless defined $colref->{'attribute'}; + } + elsif ( $col =~ /^__(NEWLINE|NBSP)__$/ || $col =~ /^(NEWLINE|NBSP)$/ ) { + $colref->{'title'} = $1; + } + elsif ( $col =~ /__(.*?)__/io ) { + my @subcols; + while ( $col =~ s/^(.*?)__(.*?)__//o ) { + push ( @subcols, $1 ) if $1; + push ( @subcols, "__$2__" ); + $colref->{'last_attribute'} = $2; + } + push @subcols, $col; + $colref->{'output'} = \@subcols; + $colref->{'attribute'} = $colref->{'last_attribute'} + unless defined $colref->{'attribute'}; + } + else { + $colref->{'output'} = [ "__" . $col . "__" ]; + $colref->{'last_attribute'} = $col; + $colref->{'attribute'} = $col + unless defined $colref->{'attribute'}; + } + + $m->callback(CallbackName => 'PostColumn', Column => $colref, col => \$col); + + push @Columns, $colref; +} + +$m->callback(CallbackName => 'PostProcess', Columns => \@Columns, Format => $Format); + +return(@Columns); +</%init> diff --git a/rt/share/html/Elements/CollectionAsTable/Row b/rt/share/html/Elements/CollectionAsTable/Row new file mode 100644 index 000000000..fa7474b6c --- /dev/null +++ b/rt/share/html/Elements/CollectionAsTable/Row @@ -0,0 +1,143 @@ +%# BEGIN BPS TAGGED BLOCK {{{ +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2009 Best Practical Solutions, LLC +%# <jesse@bestpractical.com> +%# +%# (Except where explicitly superseded by other copyright notices) +%# +%# +%# LICENSE: +%# +%# 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. +%# +%# You should have received a copy of the GNU General Public License +%# along with this program; if not, write to the Free Software +%# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA +%# 02110-1301 or visit their web page on the internet at +%# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html. +%# +%# +%# CONTRIBUTION SUBMISSION POLICY: +%# +%# (The following paragraph is not intended to limit the rights granted +%# to you to modify and distribute this software under the terms of +%# the GNU General Public License and is only of importance to you if +%# you choose to contribute your changes and enhancements to the +%# community by submitting them to Best Practical Solutions, LLC.) +%# +%# By intentionally submitting any modifications, corrections or +%# derivatives to this work, or any other work intended for use with +%# Request Tracker, to Best Practical Solutions, LLC, you confirm that +%# you are the copyright holder for those contributions and you grant +%# Best Practical Solutions, LLC a nonexclusive, worldwide, irrevocable, +%# royalty-free, perpetual, license to use, copy, create derivative +%# works based on those contributions, and sublicense and distribute +%# those contributions and any derivatives thereof. +%# +%# END BPS TAGGED BLOCK }}} +<%ARGS> +$i => undef +@Format => undef +$record => undef +$maxitems => undef +$Depth => undef +$Warning => undef +$ColumnMap => {} +$Class => 'RT__Ticket' +</%ARGS> +<%init> +$m->out( '<tr class="' + . ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) . '" >' + . "\n" ); +use HTML::Entities; +my $item; +foreach my $column (@Format) { + if ( defined $column->{title} && $column->{title} eq 'NEWLINE' ) { + while ( $item < $maxitems ) { + $m->out(qq{<td class="collection-as-table"> </td>\n}); + $item++; + } + $item = 0; + $m->out( '</tr>' . "\n" ); + $m->out( '<tr class="' + . ( $Warning ? 'warnline' : $i % 2 ? 'oddline' : 'evenline' ) + . '" >' + . "\n" ); + next; + } + + my $class = $column->{class} ? encode_entities( $column->{class}, q{'"&<>} ) : 'collection-as-table'; + $m->out(qq{<td class="$class" }); + + my %attrs; + foreach my $attr (qw(style align)) { + if ( defined $column->{ $attr } ) { + $attrs{ $attr } = $column->{ $attr }; + next; + } + + # if it's not defined then use column map + my $col = $column->{'attribute'} || $column->{'last_attribute'}; + unless ( exists $ColumnMap->{$col}{$attr} ) { + next unless $col; + + $ColumnMap->{$col}{$attr} = $m->comp( + "/Elements/ColumnMap", + Class => $Class, + Name => $col, + Attr => $attr, + ); + } + $attrs{ $attr } = ProcessColumnMapValue( + $ColumnMap->{$col}{$attr}, + Arguments => [$record, $i], + Escape => 0, + ); + } + + $attrs{colspan} = $column->{span}; + $item += ($attrs{'colspan'} || 1); + + my @out; + foreach my $subcol ( @{ $column->{output} } ) { + my ($col) = ($subcol =~ /^__(.*?)__$/); + unless ( $col ) { + push @out, $subcol; + next; + } + + unless ( exists $ColumnMap->{$col}{'value'} ) { + $ColumnMap->{$col}{'value'} = $m->comp( + "/Elements/ColumnMap", + Class => $Class, + Name => $col, + Attr => 'value' + ); + } + + push @out, ProcessColumnMapValue( + $ColumnMap->{$col}{'value'}, + Arguments => [$record, $i], + ); + } + s/\n/<br \/>/gs for @out; + + $m->out( $_ .'="'. $m->interp->apply_escapes( $attrs{$_} => 'h' ) .'"' ) + foreach grep $attrs{$_}, qw(align style colspan); + + $m->out('>'); + $m->out(@out) if @out; + $m->out( '</td>' . "\n" ); +} +$m->out('</tr>'); +</%init> |