| | 60 | } |
| | 61 | |
| | 62 | sub tag_last_updated { |
| | 63 | my ($ctx, $args) = @_; |
| | 64 | my $tag = $ctx->stash('Tag') or return ''; |
| | 65 | my $blog_id = $ctx->stash('blog_id') or return ''; |
| | 66 | |
| | 67 | my ($e) = MT::Entry->load(undef, { |
| | 68 | sort => 'created_on', |
| | 69 | direction => 'descend', |
| | 70 | limit => 1, |
| | 71 | join => [ 'MT::ObjectTag', 'object_id', { |
| | 72 | tag_id => $tag->id, |
| | 73 | blog_id => $blog_id, |
| | 74 | object_datasource => MT::Entry->datasource, |
| | 75 | }, { |
| | 76 | unique => 1, |
| | 77 | } ] }) |
| | 78 | or return ''; |
| | 79 | |
| | 80 | $args->{ts} = $e->created_on; |
| | 81 | MT::Template::Context::_hdlr_date($ctx, $args); |
| | 207 | sub encode_urlplus { |
| | 208 | my $s = $_[0]; |
| | 209 | return $s unless $_[1]; |
| | 210 | $s =~ tr/ /+/; |
| | 211 | MT::Util::encode_url($s); |
| | 212 | } |
| | 213 | |
| | 214 | sub search_tags { |
| | 215 | my ($ctx, $args, $cond) = @_; |
| | 216 | |
| | 217 | return '' unless $ctx->stash('search_string') =~ /\S/; |
| | 218 | my $tags = $ctx->stash('search_string'); |
| | 219 | my @tag_names = MT::Tag->split(',', $tags); |
| | 220 | # my %tags = map { $_ => 1, MT::Tag->normalize($_) => 1 } @tag_names; |
| | 221 | # my @tags = MT::Tag->load({ name => [ keys %tags ] }); |
| | 222 | my @tags = MT::Tag->load({ name => @tag_names }); |
| | 223 | return '' unless scalar @tags; |
| | 224 | |
| | 225 | my @res; |
| | 226 | my $builder = $ctx->stash('builder'); |
| | 227 | my $tokens = $ctx->stash('tokens'); |
| | 228 | foreach (@tags) { |
| | 229 | local $ctx->{__stash}{'Tag'} = $_; |
| | 230 | local $ctx->{__stash}{tag_count} = undef; |
| | 231 | defined(my $out = $builder->build($ctx, $tokens, $cond)) |
| | 232 | or return $ctx->error($ctx->errstr); |
| | 233 | push @res, $out; |
| | 234 | } |
| | 235 | my $glue = $args->{glue} || ''; |
| | 236 | join $glue, @res; |
| | 237 | } |
| | 238 | |