AjaxCommentsをUTF-8以外のcharsetに対応させる
こういう改造は…。
The blog of H.Fujimoto:AjaxComments for MT4プラグインの利用法
まず、Comments.pmを継承するAjaxComments.pmクラスを作り、lib/MT/Appかextlib/MT/Appの下に置きます。
package MT::App::AjaxComments;
use strict;
use base 'MT::App::Comments';
sub init_request {
my $app = shift;
$app->SUPER::init_request(@_);
my $q = $app->param;
if ($q->param('ajax') || $q->param('charset')) {
require MT::I18N;
my $post_charset = $q->param('charset') || 'utf-8';
my $mt_charset = MT::ConfigMgr->instance->PublishCharset || 'utf-8';
if ($post_charset ne $mt_charset) {
for my $name ($q->param) {
my $value = $q->param($name);
$value = MT::I18N::encode_text($value, $post_charset, $mt_charset);
$q->param($name, $value);
}
}
}
}
1;
次にMTのルートディレクトリにmt-ajax-comments.cgiを作ります。
#!/usr/bin/perl -w
use strict;
use lib $ENV{MT_HOME} ? "$ENV{MT_HOME}/lib" : 'lib';
use MT::Bootstrap App => 'MT::App::AjaxComments';
最後にmt-config.cgiに以下のように追加し、再構築します。
CommentScript mt-ajax-comments.cgi
動くかどうかはしらん。
このエントリーのトラックバックURL: http://as-is.net/mt/mt-tb.cgi/558
Comments (0)