Changeset 953

Show
Ignore:
Timestamp:
12/19/06 21:01:30 (2 years ago)
Author:
bchoate
Message:

Updates for processing tag attributes populated through handlers. BugId: 45890

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/wheeljack/lib/MT/Template/Context.pm

    r752 r953  
    120120    sub stock_post_process_handler { 
    121121        my($ctx, $args, $str, $arglist) = @_; 
    122         # in the event that we don't have arglist, 
    123         # we'll build it using the hashref we do have 
    124         # we might as well preserve the original ordering 
    125         # of processing as well, since it's better than 
    126         # the pseudo random order we get from retrieving the 
    127         # keys from the hash. 
    128         unless ($arglist) { 
    129             $arglist = []; 
     122        $arglist ||= []; 
     123        if (@$arglist) { 
     124            # In the event that $args was manipulated by handlers, 
     125            # locate any new arguments and add them to $arglist for 
     126            # processing 
     127            my %arglist_keys = map { @$_ } @$arglist; 
     128            if (scalar keys %arglist_keys != scalar keys %$args) { 
     129                my %more_args = %$args; 
     130                for (keys %arglist_keys) { 
     131                    delete $more_args{$_} if exists $more_args{$_}; 
     132                } 
     133                if (%more_args) { 
     134                    push @$arglist, [ $_ => $more_args{$_} ] foreach 
     135                        grep { exists $Global_filters{$_} || exists $Filters{$_} } 
     136                        keys %more_args; 
     137                } 
     138            } 
     139        } elsif (keys %$args && !@$arglist) { 
     140            # in the event that we don't have arglist, 
     141            # we'll build it using the hashref we do have 
     142            # we might as well preserve the original ordering 
     143            # of processing as well, since it's better than 
     144            # the pseudo random order we get from retrieving the 
     145            # keys from the hash. 
    130146            push @$arglist, [ $_, $args->{$_} ] foreach 
    131                 sort { $order{$a} <=> $order{$b} } 
    132                 grep { exists $Filters{$_} } keys %$args; 
     147                sort { exists $order{$a} && exists $order{$b} ? $order{$a} <=> $order{$b} : 0 } 
     148                grep { exists $Global_filters{$_} || exists $Filters{$_} } 
     149                keys %$args; 
    133150        } 
    134151        for my $arg (@$arglist) {