| 24 | | our $VERSION = '0.04'; |
| 25 | | $plugin = __PACKAGE__->new({ |
| 26 | | name => 'TagSupplementals Plugin', |
| 27 | | description => 'A plugin for providing supplemental features for MT 3.3 tags.', |
| 28 | | doc_link => 'http://code.as-is.net/wiki/TagSupplementals_Plugin', |
| 29 | | author_name => 'Hirotaka Ogawa', |
| 30 | | author_link => 'http://profile.typekey.com/ogawa/', |
| 31 | | version => $VERSION, |
| 32 | | }); |
| 33 | | MT->add_plugin($plugin); |
| 34 | | MT::Template::Context->add_tag(EntryTagsCount => \&entry_tags_count); |
| 35 | | MT::Template::Context->add_tag(TagLastUpdated => \&tag_last_updated); |
| 36 | | MT::Template::Context->add_container_tag(RelatedEntries => \&related_entries); |
| 37 | | MT::Template::Context->add_container_tag(RelatedTags => \&related_tags); |
| 38 | | MT::Template::Context->add_global_filter(encode_urlplus => \&encode_urlplus); |
| 39 | | MT::Template::Context->add_container_tag(SearchTags => \&search_tags); |
| | 25 | our $VERSION = '0.05'; |
| 49 | | MT::Template::Context->add_tag(TagXSearchLink => \&tag_xsearch_link); |
| 50 | | MT::Template::Context->add_container_tag(XSearchTags => \&xsearch_tags); |
| 51 | | } |
| | 35 | } |
| | 36 | |
| | 37 | my $plugin = __PACKAGE__->new({ |
| | 38 | name => 'TagSupplementals Plugin', |
| | 39 | description => 'A plugin for providing supplemental features for MT 3.3 tags.', |
| | 40 | doc_link => 'http://code.as-is.net/wiki/TagSupplementals_Plugin', |
| | 41 | author_name => 'Hirotaka Ogawa', |
| | 42 | author_link => 'http://profile.typekey.com/ogawa/', |
| | 43 | version => $VERSION, |
| | 44 | template_tags => { |
| | 45 | EntryTagsCount => \&entry_tags_count, |
| | 46 | TagLastUpdated => \&tag_last_updated, |
| | 47 | $HAVE_MT_XSEARCH ? (TagXSearchLink => \&tag_xsearch_link) : (), |
| | 48 | }, |
| | 49 | container_tags => { |
| | 50 | RelatedEntries => \&related_entries, |
| | 51 | RelatedTags => \&related_tags, |
| | 52 | ArchiveTags => \&archive_tags, |
| | 53 | SearchTags => \&search_tags, |
| | 54 | $HAVE_MT_XSEARCH ? (XSearchTags => \&xsearch_tags) : (), |
| | 55 | }, |
| | 56 | global_filters => { |
| | 57 | encode_urlplus => \&encode_urlplus, |
| | 58 | }, |
| | 59 | }); |
| | 60 | MT->add_plugin($plugin); |
| | 240 | sub archive_tags { |
| | 241 | my ($ctx, $args, $cond) = @_; |
| | 242 | my $blog_id = $ctx->stash('blog_id') or return ''; |
| | 243 | my $entries = force($ctx->stash('entries')) or return ''; |
| | 244 | |
| | 245 | my @eids = map { $_->id } grep { $_->status == MT::Entry::RELEASE() } @$entries; |
| | 246 | |
| | 247 | my $iter = MT::Tag->load_iter(undef, { |
| | 248 | sort => 'name', |
| | 249 | join => ['MT::ObjectTag', 'tag_id', { |
| | 250 | blog_id => $blog_id, |
| | 251 | object_id => \@eids, |
| | 252 | object_datasource => MT::Entry->datasource, |
| | 253 | }, { |
| | 254 | unique => 1, |
| | 255 | } ] }); |
| | 256 | |
| | 257 | my @res; |
| | 258 | my $builder = $ctx->stash('builder'); |
| | 259 | my $tokens = $ctx->stash('tokens'); |
| | 260 | while (my $t = $iter->()) { |
| | 261 | next if $t->is_private; |
| | 262 | local $ctx->{__stash}{Tag} = $t; |
| | 263 | local $ctx->{__stash}{tag_count} = undef; |
| | 264 | local $ctx->{__stash}{tag_entry_count} = undef; |
| | 265 | defined(my $out = $builder->build($ctx, $tokens)) |
| | 266 | or return $ctx->error($ctx->errstr); |
| | 267 | push @res, $out; |
| | 268 | } |
| | 269 | my $glue = $args->{glue} || ''; |
| | 270 | join $glue, @res; |
| | 271 | } |
| | 272 | |