Changeset 83 for all-keywords/trunk

Show
Ignore:
Timestamp:
06/14/05 16:02:21 (4 years ago)
Author:
ogawa
Message:

Fix some bugs, and add "glue" option to MTAllKeywords tag.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • all-keywords/trunk/all-keywords.pl

    r47 r83  
    11# A plugin for adding keywords-handling tags 
    22# 
    3 # Release 0.12 (Mar 23, 2005) 
     3# Release 0.13 (Jun 11, 2005) 
    44# 
    55# This software is provided as-is. You may use it for commercial or  
     
    1212use MT::Template::Context; 
    1313 
    14 eval("use Storable;"); 
    15 if (!$@ && MT->can('add_plugin')) { 
     14my $plugin; 
     15eval { 
    1616    require MT::Plugin; 
    17     my $plugin = new MT::Plugin(); 
    18     $plugin->name("AllKeywords Plugin 0.12"); 
    19     $plugin->description("Add MTAllKeywords tags for listing blog-wide keywords and entry keywords"); 
     17    $plugin = new MT::Plugin(); 
     18    $plugin->name("AllKeywords Plugin"); 
     19    $plugin->description("MTAllKeywords tags for listing and handling blog-wide tags and entry tags. Version 0.13"); 
    2020    $plugin->doc_link("http://as-is.net/hacks/2005/03/allkeywords_plugin.html"); 
    2121    MT->add_plugin($plugin); 
    22 } 
     22}; 
    2323 
    2424MT::Template::Context->add_container_tag('AllKeywords' => \&all_keywords); 
     
    4646    my ($ctx, $args, $cond) = @_; 
    4747 
    48     # sort_by option (keyword/count, default = keyword) 
     48    # sort_by option (keyword/keyword-case/count, default = keyword) 
    4949    my $sort_by = $args->{sort_by} || 'keyword'; 
    5050    # sort_order option (ascend/descend, default = ascend) 
     
    5555    my $delimiter = $args->{delimiter} || ''; 
    5656    # case_sensitive option (0/1, default = 1) 
    57     my $case_sensitive = $args->{case_sensitive} || 1; 
     57    my $case_sensitive = defined $args->{case_sensitive} ? 
     58        $args->{case_sensitive} : 1; 
    5859 
    5960    my $blog_id = $ctx->stash('blog_id'); 
     
    7778    if ($sort_by eq 'keyword') { 
    7879        @list = $sort_order eq 'ascend' ? 
    79             sort { $a cmp $b } keys %all_keywords : 
    80             sort { $b cmp $a } keys %all_keywords; 
     80            sort { lc $a cmp lc $b } keys %all_keywords : 
     81            sort { lc $b cmp lc $a } keys %all_keywords; 
     82    } elsif ($sort_by eq 'keyword-case') { 
     83        @list = $sort_order eq 'ascend' ? 
     84            sort keys %all_keywords : 
     85            sort reverse keys %all_keywords; 
    8186    } else { 
    8287        @list = $sort_order eq 'ascend' ? 
     
    119124    my $delimiter = $args->{delimiter} || ''; 
    120125    # case_sensitive option (0/1, default = 1) 
    121     my $case_sensitive = $args->{case_sensitive} || 1; 
     126    my $case_sensitive = defined $args->{case_sensitive} ? 
     127        $args->{case_sensitive} : 1; 
    122128 
    123129    my @keywords = split_keywords($e->keywords, $delimiter, $case_sensitive);