Show
Ignore:
Timestamp:
07/22/08 19:30:10 (6 months ago)
Author:
ogawa
Message:

Fix a bug for encode_urlplus().
Fix a little typo.
Now drop supporting MT 3.X.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • TagSupplementals/trunk/TagSupplementals.pl

    r472 r473  
    99package MT::Plugin::TagSupplementals; 
    1010use strict; 
    11 use MT; 
     11use warnings; 
     12 
     13use MT 4; 
    1214use base qw(MT::Plugin); 
    1315 
    14 use MT::Template::Context; 
    15 use MT::Entry; 
    16 use MT::Tag; 
    17 use MT::ObjectTag; 
    18 use MT::Promise qw(force); 
    19  
     16our $VERSION = '0.10'; 
    2017our $HAVE_MT_XSEARCH = 0; 
    21  
    22 my $plugin; 
    23  
    24 BEGIN { 
    25     our $VERSION = '0.10'; 
    26  
     18{ 
    2719    eval { require MT::XSearch; $HAVE_MT_XSEARCH = 1 }; 
    2820    if ($HAVE_MT_XSEARCH) { 
     
    3426        }); 
    3527    } 
    36  
    37     my $plugin = __PACKAGE__->new({ 
    38         name           => 'TagSupplementals', 
    39         description    => 'A plugin for providing supplemental "tag" features for MT 3.3+', 
    40         doc_link       => 'http://code.as-is.net/public/wiki/TagSupplementals_Plugin', 
    41         author_name    => 'Hirotaka Ogawa', 
    42         author_link    => 'http://profile.typekey.com/ogawa/', 
    43         version        => $VERSION, 
    44         registry       => { 
    45             tags => { 
    46                 block    => { 
    47                     RelatedEntries => \&related_entries, 
    48                     RelatedTags    => \&related_tags, 
    49                     ArchiveTags    => \&archive_tags, 
    50                     SearchTags     => \&search_tags, 
    51                     $HAVE_MT_XSEARCH ? (XSearchTags => \&xsearch_tags) : (), 
    52                 }, 
    53                 function => { 
    54                     EntryTagsCount => \&entry_tags_count, 
    55                     TagLastUpdated => \&tag_last_updated, 
    56                     $HAVE_MT_XSEARCH ? (TagXSearchLink => \&tag_xsearch_link) : (), 
    57                 }, 
    58                 modifier => { 
    59                     encode_urlplus => \&encode_urlplus, 
    60                 }, 
     28} 
     29 
     30my $plugin = __PACKAGE__->new({ 
     31    name           => 'TagSupplementals', 
     32    description    => 'A plugin for providing supplemental "tag" features for MT4', 
     33    doc_link       => 'http://code.as-is.net/public/wiki/TagSupplementals_Plugin', 
     34    author_name    => 'Hirotaka Ogawa', 
     35    author_link    => 'http://profile.typekey.com/ogawa/', 
     36    version        => $VERSION, 
     37    registry      => { 
     38        tags => { 
     39            block    => { 
     40                RelatedEntries => \&related_entries, 
     41                RelatedTags    => \&related_tags, 
     42                ArchiveTags    => \&archive_tags, 
     43                SearchTags     => \&search_tags, 
     44                $HAVE_MT_XSEARCH ? (XSearchTags => \&xsearch_tags) : (), 
     45            }, 
     46            function => { 
     47                EntryTagsCount => \&entry_tags_count, 
     48                TagLastUpdated => \&tag_last_updated, 
     49                $HAVE_MT_XSEARCH ? (TagXSearchLink => \&tag_xsearch_link) : (), 
     50            }, 
     51            modifier => { 
     52                encode_urlplus => \&encode_urlplus, 
    6153            }, 
    6254        }, 
    63         template_tags  => { 
    64             EntryTagsCount => \&entry_tags_count, 
    65             TagLastUpdated => \&tag_last_updated, 
    66             $HAVE_MT_XSEARCH ? (TagXSearchLink => \&tag_xsearch_link) : (), 
    67         }, 
    68         container_tags => { 
    69             RelatedEntries => \&related_entries, 
    70             RelatedTags    => \&related_tags, 
    71             ArchiveTags    => \&archive_tags, 
    72             SearchTags     => \&search_tags, 
    73             $HAVE_MT_XSEARCH ? (XSearchTags => \&xsearch_tags) : (), 
    74         }, 
    75         global_filters => { 
    76             encode_urlplus => \&encode_urlplus, 
    77         }, 
    78     }); 
    79     MT->add_plugin($plugin); 
    80 } 
     55    } 
     56}); 
     57MT->add_plugin($plugin); 
     58 
     59use MT::Template::Context; 
     60use MT::Entry; 
     61use MT::Tag; 
     62use MT::ObjectTag; 
     63use MT::Promise qw(force); 
    8164 
    8265sub entry_tags_count { 
     
    207190    delete $rank{$entry_id}; 
    208191 
     192    # sort by entry_id, and then sort by rank 
    209193    my @eids = sort { $b <=> $a } keys %rank; 
    210194    @eids = sort { $rank{$b} <=> $rank{$a} } @eids; 
     
    251235    my @otags = MT::ObjectTag->load({ 
    252236        %blog_terms, 
    253         tag_id            => $tag_id, 
     237        tag_id            => $tag->id, 
    254238        object_datasource => MT::Entry->datasource, 
    255239    }, { 
     
    324308    my $s = $_[0]; 
    325309    return $s unless $_[1]; 
     310    $s =~ s!([^ a-zA-Z0-9_.~-])!uc sprintf "%%%02x", ord($1)!eg; 
    326311    $s =~ tr/ /+/; 
    327     MT::Util::encode_url($s); 
     312    $s; 
    328313} 
    329314