[Rt-commit] [svn] r1858 - in rt/branches/PLATANO-EXPERIMENTAL-CSS:
. html/Search/Elements
jesse at pallas.eruditorum.org
jesse at pallas.eruditorum.org
Thu Nov 11 03:45:56 EST 2004
Author: jesse
Date: Thu Nov 11 03:45:56 2004
New Revision: 1858
Modified:
rt/branches/PLATANO-EXPERIMENTAL-CSS/ (props changed)
rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Elements/BuildFormatString
Log:
r9120 at tinbook: jesse | 2004-11-11T04:07:29.821876Z
r6225 at tinbook: jesse | 2004-11-07T14:44:15.591492Z
Web
* Refactore BuildFormatString to simplify logic and improve reliability
Modified: rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Elements/BuildFormatString
==============================================================================
--- rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Elements/BuildFormatString (original)
+++ rt/branches/PLATANO-EXPERIMENTAL-CSS/html/Search/Elements/BuildFormatString Thu Nov 11 03:45:56 2004
@@ -46,36 +46,48 @@
<%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
</%args>
<%init>
unless ($Format) {
$Format = $RT::DefaultSearchResultFormat;
}
-
-my @fields = (
- "QueueName", "OwnerName",
- "id", "Status",
- "Subject", "ExtendedStatus",
- "Priority", "InitialPriority",
- "FinalPriority",
- "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(
+ QueueName
+ OwnerName
+ id Status
+ Subject ExtendedStatus
+ Priority InitialPriority
+ FinalPriority 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'});
@@ -117,8 +129,8 @@
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 +142,9 @@
}
}
}
-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;
@@ -142,60 +154,55 @@
foreach my $col (@columns) {
my %column = ();
$column{Column} = $col;
-
- if ( $ARGS{Face} eq "Bold" ) {
- $column{Prefix} .= "<B>";
- }
- if ( $ARGS{Face} eq "Italic" ) {
- $column{Prefix} .= "<I>";
- }
- if ( $ARGS{Size} ) {
- $column{Prefix} .= "<" . $ARGS{Size} . ">";
- }
- if ( $ARGS{Link} eq "Display" ) {
- $column{Prefix} .= "<A HREF=\"".$RT::WebPath."/Ticket/Display.html?id=__id__\">";
- }
- elsif ( $ARGS{Link} eq "Take" ) {
- $column{Prefix} .=
- "<A HREF=\"".$RT::WebPath."/Ticket/Display.html?Action=Take&id=__id__\">";
- }
-
- my $suffix;
- if ( $ARGS{'Link'} eq "Display" || $ARGS{'Link'} eq "Take" ) {
- $column{Suffix} .= "</a>";
- }
- if ( $ARGS{Size} ) {
- $column{Suffix} .= "</" . $ARGS{Size} . ">";
- }
- if ( $ARGS{Face} eq "Italic" ) {
- $column{Suffix} .= "</I>";
- }
- if ( $ARGS{Face} eq "Bold" ) {
- $column{Suffix} .= "</B>";
- }
- if ( $ARGS{Title} ) {
- $column{Suffix} .= "/TITLE:" . $ARGS{Title};
- }
- push @seen, \%column;
- }
+
+ if ( $Face eq "Bold" ) {
+ $column{Prefix} .= "<B>";
+ $column{Suffix} .= "</B>";
+ }
+ if ( $Face eq "Italic" ) {
+ $column{Prefix} .= "<I>";
+ $column{Suffix} .= "</I>";
+ }
+ if ($Size) {
+ $column{Prefix} .= "<" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
+ $column{Suffix} .= "</" . $m->interp->apply_escapes( $Size, 'h' ) . ">";
+ }
+ if ( $Link eq "Display" ) {
+ $column{Prefix} .=
+ "<A HREF=\"" . $RT::WebPath . "/Ticket/Display.html?id=__id__\">";
+ $column{Suffix} .= "</a>";
+ }
+ elsif ( $Link eq "Take" ) {
+ $column{Prefix} .=
+ "<A HREF=\""
+ . $RT::WebPath
+ . "/Ticket/Display.html?Action=Take&id=__id__\">";
+ $column{Suffix} .= "</a>";
+ }
+
+ 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;
}
}
@@ -203,10 +210,11 @@
my @format_string;
foreach my $field (@seen) {
next unless $field;
- my $row = "'" . $field->{Prefix};
- $row .= "__" . $field->{Column} . "__" if ( $field->{Column} ne "<blank>" ) ;
+ my $row = "'" . $field->{Prefix};
+ $row .= "__" . $m->interp->apply_escapes( $field->{Column}, 'h' ) . "__"
+ unless ( $field->{Column} eq "<blank>" );
$row .= $field->{Suffix} . "'";
- push (@format_string, $row);
+ push( @format_string, $row );
}
$Format = join(",\n", @format_string);
More information about the Rt-commit
mailing list