From d39d52aac8f38ea9115628039f0df5aa3ac826de Mon Sep 17 00:00:00 2001 From: ivan Date: Fri, 3 Dec 2004 20:40:48 +0000 Subject: import rt 3.2.2 --- rt/html/Search/Elements/BuildFormatString | 215 ++++++++++++++++++++++++++++++ 1 file changed, 215 insertions(+) create mode 100644 rt/html/Search/Elements/BuildFormatString (limited to 'rt/html/Search/Elements/BuildFormatString') diff --git a/rt/html/Search/Elements/BuildFormatString b/rt/html/Search/Elements/BuildFormatString new file mode 100644 index 000000000..e5e131b6c --- /dev/null +++ b/rt/html/Search/Elements/BuildFormatString @@ -0,0 +1,215 @@ +%# {{{ BEGIN BPS TAGGED BLOCK +%# +%# COPYRIGHT: +%# +%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +%# +%# +%# (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., 675 Mass Ave, Cambridge, MA 02139, USA. +%# +%# +%# 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 => undef +%cfqueues => undef + +<%init> + +unless ($Format) { + $Format = $RT::DefaultSearchResultFormat; +} + +my @fields = ( + "QueueName", "OwnerName", + "id", "Status", + "Subject", "ExtendedStatus", + "Priority", "InitialPriority", + "FinalPriority", "EffectiveId", + "Type", "TimeWorked", + "TimeLeft", "TimeEstimated", + "Requestors", "Cc", + "AdminCc", "StartsRelative", + "StartedRelative", "CreatedRelative", + "LastUpdatedRelative", "ToldRelative", + "DueRelative", "ResolvedRelative", + "Starts", "Started", + "Created", "CreatedBy", + "LastUpdated", "LastUpdatedBy", + "Told", "Due", + "Resolved", "NEWLINE", + "RefersTo", "ReferredToBy", + "DependsOn", "DependedOnBy", + "MemberOf", "Members", + "Parents", "Children", + "-", +); + +my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'}); +foreach (keys %cfqueues) { + my $id = $_; + $id =~ s/^.'*(.*).'*$/$1/; + # Gotta load up the $queue object, since queues get stored by name now. + my $queue = RT::Queue->new($session{'CurrentUser'}); + $queue->Load($id); + $CustomFields->LimitToQueue($queue->Id); +} +$CustomFields->LimitToGlobal; + +while ( my $CustomField = $CustomFields->Next ) { + my $queuestr; + if ($CustomField->QueueObj && $CustomField->QueueObj->Id != 0) { + $queuestr = $CustomField->QueueObj->Name . "."; + } + push @fields, "CustomField." . $queuestr . "{" . $CustomField->Name . "}"; +} + +my ( @seen); + +my @format = split( /,\s*/, $Format ); +foreach my $field (@format) { + my %column = (); + $field =~ s/'(.*)'/$1/; + my ( $prefix, $suffix ); + if ( $field =~ m/(.*)__(.*)__(.*)/ ) { + $prefix = $1; + $suffix = $3; + $field = $2; + } + $field = "" if !$field; + $column{Prefix} = $prefix; + $column{Suffix} = $suffix; + $field =~ s/\s*(.*)\s*/$1/; + $column{Column} = $field; + push @seen, \%column; +} + +if ( $ARGS{"RemoveCol"} ) { + my $index = $ARGS{'CurrentDisplayColumns'}; + my $column = $seen[$index]; + if ($index) { + delete $seen[$index]; + my @temp = @seen; + @seen = (); + foreach my $element (@temp) { + next unless $element; + push @seen, $element; + } + } +} +elsif ( $ARGS{"AddCol"} ) { + if ( defined $ARGS{'SelectDisplayColumns'} ) { + my $selected = $ARGS{'SelectDisplayColumns'}; + my @columns; + if (ref($selected) eq 'ARRAY') { + @columns = @$selected; + } else { + push @columns, $selected; + } + foreach my $col (@columns) { + my %column = (); + $column{Column} = $fields[ $col ]; + + if ( $ARGS{Face} eq "Bold" ) { + $column{Prefix} .= ""; + } + if ( $ARGS{Face} eq "Italic" ) { + $column{Prefix} .= ""; + } + if ( $ARGS{Size} ) { + $column{Prefix} .= "<" . $ARGS{Size} . ">"; + } + if ( $ARGS{Link} eq "Display" ) { + $column{Prefix} .= ""; + } + elsif ( $ARGS{Link} eq "Take" ) { + $column{Prefix} .= + ""; + } + + my $suffix; + if ( $ARGS{'Link'} eq "Display" || $ARGS{'Link'} eq "Take" ) { + $column{Suffix} .= ""; + } + if ( $ARGS{Size} ) { + $column{Suffix} .= ""; + } + if ( $ARGS{Face} eq "Italic" ) { + $column{Suffix} .= ""; + } + if ( $ARGS{Face} eq "Bold" ) { + $column{Suffix} .= ""; + } + if ( $ARGS{Title} ) { + $column{Suffix} .= "/TITLE:" . $ARGS{Title}; + } + push @seen, \%column; + } + } +} +elsif ( $ARGS{"ColUp"} ) { + my $index = $ARGS{'CurrentDisplayColumns'}; + if ( defined $index && ( $index - 1 ) >= 0 ) { + my $column = $seen[$index]; + $seen[$index] = $seen[ $index - 1 ]; + $seen[ $index - 1 ] = $column; + $ARGS{CurrentDisplayColumns} = $index - 1; + } +} +elsif ( $ARGS{"ColDown"} ) { + my $index = $ARGS{'CurrentDisplayColumns'}; + if ( defined $index && ( $index + 1 ) < scalar @seen ) { + my $column = $seen[$index]; + $seen[$index] = $seen[ $index + 1 ]; + $seen[ $index + 1 ] = $column; + $ARGS{CurrentDisplayColumns} = $index + 1; + } +} + +$Format = ""; +foreach my $field (@seen) { + next unless $field; + $Format .= ", \n" if $Format; + $Format .= "'"; + $Format .= $field->{Prefix}; + $Format .= "__" . $field->{Column} . "__" if ( $field->{Column} ne "" ) ; + $Format .= $field->{Suffix}; + $Format .= "'"; +} +return($Format, \@fields, \@seen); + + + -- cgit v1.2.1 From d4d0590bef31071e8809ec046717444b95b3f30a Mon Sep 17 00:00:00 2001 From: ivan Date: Sat, 15 Oct 2005 09:11:20 +0000 Subject: import rt 3.4.4 --- rt/html/Search/Elements/BuildFormatString | 196 +++++++++++++++++------------- 1 file changed, 112 insertions(+), 84 deletions(-) (limited to 'rt/html/Search/Elements/BuildFormatString') diff --git a/rt/html/Search/Elements/BuildFormatString b/rt/html/Search/Elements/BuildFormatString index e5e131b6c..639e62c29 100644 --- a/rt/html/Search/Elements/BuildFormatString +++ b/rt/html/Search/Elements/BuildFormatString @@ -1,8 +1,8 @@ -%# {{{ BEGIN BPS TAGGED BLOCK +%# BEGIN BPS TAGGED BLOCK {{{ %# %# COPYRIGHT: %# -%# This software is Copyright (c) 1996-2004 Best Practical Solutions, LLC +%# This software is Copyright (c) 1996-2005 Best Practical Solutions, LLC %# %# %# (Except where explicitly superseded by other copyright notices) @@ -42,45 +42,76 @@ %# works based on those contributions, and sublicense and distribute %# those contributions and any derivatives thereof. %# -%# }}} END BPS TAGGED BLOCK +%# END BPS TAGGED BLOCK }}} <%args> $Format => undef %cfqueues => undef +$Face => undef +$Size => undef +$Link => undef +$Title => undef +$AddCol => undef +$RemoveCol => undef +$ColUp => undef +$ColDown => undef +$SelectDisplayColumns => undef +$CurrentDisplayColumns => undef <%init> unless ($Format) { $Format = $RT::DefaultSearchResultFormat; } - -my @fields = ( - "QueueName", "OwnerName", - "id", "Status", - "Subject", "ExtendedStatus", - "Priority", "InitialPriority", - "FinalPriority", "EffectiveId", - "Type", "TimeWorked", - "TimeLeft", "TimeEstimated", - "Requestors", "Cc", - "AdminCc", "StartsRelative", - "StartedRelative", "CreatedRelative", - "LastUpdatedRelative", "ToldRelative", - "DueRelative", "ResolvedRelative", - "Starts", "Started", - "Created", "CreatedBy", - "LastUpdated", "LastUpdatedBy", - "Told", "Due", - "Resolved", "NEWLINE", - "RefersTo", "ReferredToBy", - "DependsOn", "DependedOnBy", - "MemberOf", "Members", - "Parents", "Children", - "-", + + +# All the things we can display in the format string by default +my @fields = qw( + id + Status + ExtendedStatus + Subject + QueueName + OwnerName + Priority + InitialPriority + FinalPriority + Type + TimeWorked + TimeLeft + TimeEstimated + CreatedBy + LastUpdatedBy + Requestors + Cc + AdminCc + Starts + StartsRelative + Started + StartedRelative + Created + CreatedRelative + LastUpdated + LastUpdatedRelative + Told + ToldRelative + Due + DueRelative + Resolved + ResolvedRelative + RefersTo + ReferredToBy + DependsOn + DependedOnBy + MemberOf + Members + Parents + Children + NEWLINE ); my $CustomFields = RT::CustomFields->new( $session{'CurrentUser'}); -foreach (keys %cfqueues) { - my $id = $_; +foreach my $id (keys %cfqueues) { + # What does this _do_? What are the keys to cfqueues $id =~ s/^.'*(.*).'*$/$1/; # Gotta load up the $queue object, since queues get stored by name now. my $queue = RT::Queue->new($session{'CurrentUser'}); @@ -117,8 +148,8 @@ foreach my $field (@format) { push @seen, \%column; } -if ( $ARGS{"RemoveCol"} ) { - my $index = $ARGS{'CurrentDisplayColumns'}; +if ( $RemoveCol ) { + my $index = $CurrentDisplayColumns; my $column = $seen[$index]; if ($index) { delete $seen[$index]; @@ -130,9 +161,9 @@ if ( $ARGS{"RemoveCol"} ) { } } } -elsif ( $ARGS{"AddCol"} ) { - if ( defined $ARGS{'SelectDisplayColumns'} ) { - my $selected = $ARGS{'SelectDisplayColumns'}; +elsif ( $AddCol ) { + if ( defined $SelectDisplayColumns ) { + my $selected = $SelectDisplayColumns; my @columns; if (ref($selected) eq 'ARRAY') { @columns = @$selected; @@ -141,74 +172,71 @@ elsif ( $ARGS{"AddCol"} ) { } foreach my $col (@columns) { my %column = (); - $column{Column} = $fields[ $col ]; - - if ( $ARGS{Face} eq "Bold" ) { - $column{Prefix} .= ""; - } - if ( $ARGS{Face} eq "Italic" ) { - $column{Prefix} .= ""; - } - if ( $ARGS{Size} ) { - $column{Prefix} .= "<" . $ARGS{Size} . ">"; - } - if ( $ARGS{Link} eq "Display" ) { - $column{Prefix} .= ""; - } - elsif ( $ARGS{Link} eq "Take" ) { - $column{Prefix} .= - ""; - } - - my $suffix; - if ( $ARGS{'Link'} eq "Display" || $ARGS{'Link'} eq "Take" ) { - $column{Suffix} .= ""; - } - if ( $ARGS{Size} ) { - $column{Suffix} .= ""; - } - if ( $ARGS{Face} eq "Italic" ) { - $column{Suffix} .= ""; - } - if ( $ARGS{Face} eq "Bold" ) { - $column{Suffix} .= ""; - } - if ( $ARGS{Title} ) { - $column{Suffix} .= "/TITLE:" . $ARGS{Title}; - } - push @seen, \%column; - } + $column{Column} = $col; + + if ( $Face eq "Bold" ) { + $column{Prefix} .= ""; + $column{Suffix} .= ""; + } + if ( $Face eq "Italic" ) { + $column{Prefix} .= ""; + $column{Suffix} .= ""; + } + if ($Size) { + $column{Prefix} .= "<" . $m->interp->apply_escapes( $Size, 'h' ) . ">"; + $column{Suffix} .= "interp->apply_escapes( $Size, 'h' ) . ">"; + } + if ( $Link eq "Display" ) { + $column{Prefix} .= + ""; + $column{Suffix} .= ""; + } + elsif ( $Link eq "Take" ) { + $column{Prefix} .= ""; + $column{Suffix} .= ""; + } + + if ($Title) { + $column{Suffix} .= "/TITLE:" . $m->interp->apply_escapes( $Title, 'h' ); } + push @seen, \%column; +} +} } -elsif ( $ARGS{"ColUp"} ) { - my $index = $ARGS{'CurrentDisplayColumns'}; +elsif ( $ColUp ) { + my $index = $CurrentDisplayColumns; if ( defined $index && ( $index - 1 ) >= 0 ) { my $column = $seen[$index]; $seen[$index] = $seen[ $index - 1 ]; $seen[ $index - 1 ] = $column; - $ARGS{CurrentDisplayColumns} = $index - 1; + $CurrentDisplayColumns = $index - 1; } } -elsif ( $ARGS{"ColDown"} ) { - my $index = $ARGS{'CurrentDisplayColumns'}; +elsif ( $ColDown ) { + my $index = $CurrentDisplayColumns; if ( defined $index && ( $index + 1 ) < scalar @seen ) { my $column = $seen[$index]; $seen[$index] = $seen[ $index + 1 ]; $seen[ $index + 1 ] = $column; - $ARGS{CurrentDisplayColumns} = $index + 1; + $CurrentDisplayColumns = $index + 1; } } -$Format = ""; + +my @format_string; foreach my $field (@seen) { next unless $field; - $Format .= ", \n" if $Format; - $Format .= "'"; - $Format .= $field->{Prefix}; - $Format .= "__" . $field->{Column} . "__" if ( $field->{Column} ne "" ) ; - $Format .= $field->{Suffix}; - $Format .= "'"; + my $row = "'" . $field->{Prefix}; + $row .= "__" . $m->interp->apply_escapes( $field->{Column}, 'h' ) . "__" + unless ( $field->{Column} eq "" ); + $row .= $field->{Suffix} . "'"; + push( @format_string, $row ); } + +$Format = join(",\n", @format_string); + + return($Format, \@fields, \@seen); -- cgit v1.2.1