[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Patch for gnatsweb.pl
From: |
Robert Lupton the Good |
Subject: |
Patch for gnatsweb.pl |
Date: |
Thu, 26 Sep 2002 09:40:10 -0400 |
I don't think that I ever posted my custom sort routine. Thinking
about it, this might go better in gnatsweb.pl itself, as the custom
sort itself uses cb('sort_keys') for customization.
R
elsif ($reason eq 'sort_keys')
{
return qw(Severity Priority Class State Category Scheduled);
}
elsif ($reason eq 'sort_query')
{
my($sortby) = shift @args;
if(defined($sortby) && $sortby eq "custom") {
if($args[0] ne 'checking_if_custom_sort_exists') {
my(@fields) = $q->param('columns');
#
# Sort by these fields in this order; PR is always added
# as a final key. We'll start by figuring out which
# field is which, and whether they are numeric or string valued
#
my(@sort_keys) = cb('sort_keys');
my($field, $i, @keys);
my($whichfield) = 1; # field counter (0 is PR)
for $field (@fields) {
$field = param2field($field);
$i = 0;
foreach (@sort_keys) {
if($_ eq $field) {
my $fieldtype =
fieldinfo($field, 'fieldtype') || '';
$keys[$i] = {};
$keys[$i]->{field} = $field;
$keys[$i]->{i} = $whichfield;
if ($fieldtype eq 'enum' ||
$fieldtype eq 'integer') {
$keys[$i]->{cmp} = "<=>"
} else {
$keys[$i]->{cmp} = "cmp";
}
}
$i++;
}
$whichfield++;
}
#
# OK, @keys is now an array telling us how to sort.
# Generate the sort BLOCK
#
my($sort_block) = "";
for (@keys) {
if(defined($_->{field})) {
$sort_block .=
" \$a->[$_->{i}] $_->{cmp} \$b->[$_->{i}] or \#
$_->{field}\n";
}
}
$sort_block .= " \$a->[0] <=> \$b->[0]; \# PR\n";
my($debug) = 0;
if($debug) {
print_header();
print "<BR>sort_block: <PRE>$sort_block</PRE>\n";
}
eval "address@hidden = sort({ $sort_block } address@hidden)";
if($@) {
print $@;
}
}
return @args;
} else {
return undef;
}
}
- Patch for gnatsweb.pl, Robert Lupton the Good, 2002/09/16
- Patch for gnatsweb.pl, Robert Lupton the Good, 2002/09/16
- Re: Patch for gnatsweb.pl, Yngve Svendsen, 2002/09/17
- Re: Patch for gnatsweb.pl, Lars Henriksen, 2002/09/22
- Re: Patch for gnatsweb.pl, Lars Henriksen, 2002/09/25
- Re: Patch for gnatsweb.pl, Yngve Svendsen, 2002/09/25
- Re: Patch for gnatsweb.pl, Lars Henriksen, 2002/09/25
- Patch for gnatsweb.pl, Robert Lupton the Good, 2002/09/26
- Patch for gnatsweb.pl,
Robert Lupton the Good <=
- Re: Patch for gnatsweb.pl, Lars Henriksen, 2002/09/29
Patch for gnatsweb.pl, Robert Lupton the Good, 2002/09/16
patch for gnatsweb.pl, Robert Lupton the Good, 2002/09/16
patch for gnatsweb.pl, Robert Lupton the Good, 2002/09/16