package MT::Plugin::SKR::OmitDefaultMsgAddCategory;
# @see http://www.skyarc.co.jp/engineerblog/entry/omitdefaultmsgaddcategory.html

use strict;
use MT 4;

### Omit default label "Add Category"
MT->add_callback ('MT::App::CMS::template_source.category_selector', undef, 5, sub {
    my ($eh, $app, $tmpl) = @_;
    my $old = trimmed_quotemeta(<<'HTMLHEREDOC');
<input id="add-category-input" class="add-category-input input-hint" type="text" value="<$mt:var name="add_container_label"$>" mt:default="<$mt:var name="add_container_label_name"$>" mt:delegate="default-value" />
HTMLHEREDOC
    my $new = <<'HTMLHEREDOC';
<input id="add-category-input" class="add-category-input input-hint" type="text" />
HTMLHEREDOC
    $$tmpl =~ s/($old)/$new/;
});

### Space and CR,LF trimmed quotemeta
sub trimmed_quotemeta {
    my ($str) = @_;
    $str = quotemeta $str;
    $str =~ s/(\\\s)+/\\s+/g;
    $str;
}

1;