# # InsertIcon.pl # 2006/7/16 1.10 For MT3.3 # # Copyright(c) by H.Fujimoto # package MT::Plugin::InsertIcon; use base 'MT::Plugin'; use strict; use MT::Plugin; use MT; # show plugin information to main menu my $plugin = MT::Plugin->new({ name => 'Insert Icon', version => '1.10', author_name => 'Hajime Fujimoto', author_link => 'http://www.h-fj.com/blog/', description => 'エントリー入力ページに絵文字を表示します' }); MT->add_plugin($plugin); # add callback MT->add_callback('bigpapi::template::edit_entry', 9, $plugin, \&add_insert_icon_button); MT->add_callback('bigpapi::template::bm_entry', 9, $plugin, \&add_insert_icon_button_bm); if (MT->version_number >= 3.3) { MT->add_callback('MT::App::CMS::AppTemplateSource.edit_entry', 9, $plugin, \&add_insert_icon_button); MT->add_callback('MT::App::CMS::AppTemplateSource.bm_entry', 9, $plugin, \&add_insert_icon_button_bm); } # insert icon button to entry page sub add_insert_icon_button { my ($cb, $app, $template) = @_; my ($old, $new); my $mt_ver = MT->version_number; # isnert javascript $old = < JS_OLD $old = quotemeta($old); $new = < JS_NEW $$template =~ s/$old/$new/; # replace text field if ($mt_ver >= 3.2 && $mt_ver < 3.3) { $old = "()"; } elsif ($mt_ver >= 3.3) { $old = "(
\n\n
)"; } if ($$template =~ /$old/) { $new = < HTML_TEXT_NEW $$template =~ s/$old/$new/; } # replace text_more field if ($mt_ver >= 3.2 && $mt_ver < 3.3) { $old = "()"; } elsif ($mt_ver >= 3.3) { $old = "(
\n\n
)"; } if ($$template =~ /$old/) { $new = < HTML_TEXT_NEW $$template =~ s/$old/$new/; } } sub add_insert_icon_button_bm { my ($cb, $app, $template) = @_; my ($old, $new); my $mt_ver = MT->version_number; # isnert javascript $old = < HTML_TEXT_NEW } elsif ($mt_ver >= 3.3) { $new = < HTML_TEXT_NEW } $$template =~ s/$old/$new/; } # replace text_more field if ($mt_ver >= 3.2 && $mt_ver < 3.3) { $old = "()"; } elsif ($mt_ver >= 3.3) { $old = "(
\n\n
)"; } if ($$template =~ /$old/) { if ($mt_ver >= 3.2 && $mt_ver < 3.3) { $new = < HTML_TEXT_NEW } elsif ($mt_ver >= 3.3) { $new = < HTML_TEXT_NEW } $$template =~ s/$old/$new/; } } 1;