# # EncodeAjax.pl # 2006/8/10 2.00 New version # 2006/10/4 2.01 Added ajax function # # Copyright(c) by H.Fujimoto # package MT::Plugin::EncodeAjax; use base 'MT::Plugin'; use strict; use MT; use MT::Plugin; use MT::I18N; # show plugin information to main menu my $plugin = MT::Plugin::EncodeAjax->new({ name => 'EncodeAjax', version => '1.00', author_name => 'H.Fujimoto', author_link => 'http://www.h-fj.com/blog/', description => 'Encode text for Ajax.', }); MT->add_plugin($plugin); # add tag MT::Template::Context->add_container_tag(EncodeAjax => \&encode_ajax); # MTEncodeAjax tag main sub encode_ajax { my ($ctx, $args) = @_; my $tokens = $ctx->stash('tokens'); my $builder = $ctx->stash('builder'); my $app = MT->instance; defined(my $out = $builder->build($ctx, $tokens)) or return $ctx->error($ctx->errstr); $out = MT::I18N::encode_text($out, $app->{cfg}->PublishCharset, 'utf-8'); $out = "\xef\xbb\xbf" . $out; $out; } 1;