/
TemplateNoteDebug.pl
49 lines (41 loc) · 1.38 KB
/
TemplateNoteDebug.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
package MT::Plugin::OMV::TemplateNoteDebug;
use vars qw( $MYNAME $VERSION $VERBOSE );
$MYNAME = 'TemplateNoteDebug';
$VERSION = '1.00';
use MT;
use base qw( MT::Plugin );
my $plugin = __PACKAGE__->new ({
name => $MYNAME,
version => $VERSION,
author_name => '<MT_TRANS phrase="Piroli YUKARINOMIYA">',
author_link => "http://www.magicvox.net/?$MYNAME",
# doc_link => "",
system_config_template => \&config_template,
settings => new MT::PluginSettings ([
['template', { Default => undef }],
]),
description => <<PERLHEREDOC,
<MT_TRANS phrase="Enable you to easily embed the debugging message with MTTemplateNote tag.">
PERLHEREDOC
});
MT->add_plugin ($plugin);
sub instance { $plugin; }
### Configuration template
sub config_template {
return <<PERLHEREDOC;
<mtapp:setting
id="template"
label="<__trans phrase="Template for debug">">
<textarea name="template" id="template" class="full-width" rows="10" cols="60"><TMPL_VAR NAME=TEMPLATE ESCAPE=HTML></textarea>
</mtapp:setting>
PERLHEREDOC
}
### Over-ride the function of MTTemplateNote tag
MT->instance->component('core')->registry('tags', 'function', 'TemplateNote', sub {
my ($ctx, $args) = @_;
my $tmpl = &instance->get_config_value ('template')
or return '';
$tmpl =~ s/%\{([^}]+)\}/$args->{$1} || ''/eg;
$tmpl;
});
1;