Changeset 949

Show
Ignore:
Timestamp:
12/19/06 05:07:59 (2 years ago)
Author:
takayama
Message:

Fixed BugId:45909

* Added checks for given attributes

Files:

Legend:

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

    r930 r949  
    14921492            $terms{created_on} = [ $ago ]; 
    14931493            $args{range_incl}{created_on} = 1; 
    1494         } elsif (!%$args) { 
    1495             if (my $days = $ctx->stash('blog')->days_on_index) { 
    1496                 my @ago = offset_time_list(time - 3600 * 24 * $days, 
    1497                     $ctx->stash('blog_id')); 
    1498                 my $ago = sprintf "%04d%02d%02d%02d%02d%02d", 
    1499                     $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0]; 
    1500                 $terms{created_on} = [ $ago ]; 
    1501                 $args{range_incl}{created_on} = 1; 
    1502             } elsif (my $limit = $ctx->stash('blog')->entries_on_index) { 
    1503                 $args->{lastn} = $limit; 
     1494        } else { 
     1495            # Check attributes 
     1496            my $found_valid_args = 0; 
     1497            foreach my $valid_key ('lastn', 'offset', 'category', 'categories', 'tag', 'tags', 'author', 'days', 'recently_commented_on') { 
     1498                if (exists($args->{$valid_key})) { 
     1499                    $found_valid_args = 1; 
     1500                    last; 
     1501                } 
     1502            } 
     1503 
     1504            if (!$found_valid_args) { 
     1505                # Uses weblog settings 
     1506                if (my $days = $ctx->stash('blog')->days_on_index) { 
     1507                    my @ago = offset_time_list(time - 3600 * 24 * $days, 
     1508                        $ctx->stash('blog_id')); 
     1509                    my $ago = sprintf "%04d%02d%02d%02d%02d%02d", 
     1510                        $ago[5]+1900, $ago[4]+1, @ago[3,2,1,0]; 
     1511                    $terms{created_on} = [ $ago ]; 
     1512                    $args{range_incl}{created_on} = 1; 
     1513                } elsif (my $limit = $ctx->stash('blog')->entries_on_index) { 
     1514                    $args->{lastn} = $limit; 
     1515                } 
    15041516            } 
    15051517        } 
    15061518        $args{'sort'} = 'created_on'; 
    15071519        $args{direction} = 'descend'; 
     1520 
    15081521        if (!@filters) { 
    15091522            if (my $last = $args->{lastn}) {