| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*- perl -*- |
|
2
|
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
# |
|
4
|
|
|
|
|
|
|
# $Id: HtmlNum.pm,v 1.4 2005/02/03 00:06:29 eserte Exp $ |
|
5
|
|
|
|
|
|
|
# Author: Slaven Rezic |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Copyright (C) 2004 Slaven Rezic. |
|
8
|
|
|
|
|
|
|
# This is free software; you can redistribute it and/or modify it under the |
|
9
|
|
|
|
|
|
|
# terms of the GNU General Public License, see the file COPYING. |
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
# |
|
12
|
|
|
|
|
|
|
# Mail: slaven@rezic.de |
|
13
|
|
|
|
|
|
|
# WWW: http://we-framework.sourceforge.net |
|
14
|
|
|
|
|
|
|
# |
|
15
|
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
package WE_Frontend::Plugin::HtmlNum; |
|
17
|
2
|
|
|
2
|
|
369171
|
use base qw(Template::Plugin::Filter); |
|
|
2
|
|
|
|
|
6
|
|
|
|
2
|
|
|
|
|
1046
|
|
|
18
|
|
|
|
|
|
|
|
|
19
|
2
|
|
|
2
|
|
2530
|
use strict; |
|
|
2
|
|
|
|
|
5
|
|
|
|
2
|
|
|
|
|
54
|
|
|
20
|
2
|
|
|
2
|
|
11
|
use vars qw($VERSION); |
|
|
2
|
|
|
|
|
4
|
|
|
|
2
|
|
|
|
|
147
|
|
|
21
|
|
|
|
|
|
|
$VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/); |
|
22
|
|
|
|
|
|
|
|
|
23
|
2
|
|
|
2
|
|
10
|
use HTML::Entities 1.27 (); # numeric entities |
|
|
2
|
|
|
|
|
54
|
|
|
|
2
|
|
|
|
|
220
|
|
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
=head1 NAME |
|
26
|
|
|
|
|
|
|
|
|
27
|
|
|
|
|
|
|
WE_Frontend::Plugin::HtmlNum - numeric html/xml entities |
|
28
|
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
=head1 SYNOPSIS |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
# In the calling script (normally already done by WebEditor::OldController) |
|
32
|
|
|
|
|
|
|
my $t = Template->new({PLUGIN_BASE => "WE_Frontend::Plugin"}); |
|
33
|
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
# In the template |
|
35
|
|
|
|
|
|
|
[% USE HtmlNum %] |
|
36
|
|
|
|
|
|
|
[% FILTER html_num %] |
|
37
|
|
|
|
|
|
|
... |
|
38
|
|
|
|
|
|
|
[% END %] |
|
39
|
|
|
|
|
|
|
[% variable | html_num %] |
|
40
|
|
|
|
|
|
|
|
|
41
|
|
|
|
|
|
|
=head1 DESCRIPTION |
|
42
|
|
|
|
|
|
|
|
|
43
|
|
|
|
|
|
|
Like the html_entities filter, but use numeric entities instead. The |
|
44
|
|
|
|
|
|
|
usage of this filter over the "html" or "html_entities" filters is |
|
45
|
|
|
|
|
|
|
highly recommended to avoid all kind of utf-8 vs. 8 bit charset |
|
46
|
|
|
|
|
|
|
problems. |
|
47
|
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
=cut |
|
49
|
|
|
|
|
|
|
|
|
50
|
|
|
|
|
|
|
sub init { |
|
51
|
2
|
|
|
2
|
0
|
68010
|
my $self = shift; |
|
52
|
2
|
|
|
|
|
30
|
$self->install_filter("html_num"); |
|
53
|
2
|
|
|
|
|
98
|
$self; |
|
54
|
|
|
|
|
|
|
} |
|
55
|
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub filter { |
|
57
|
4
|
|
|
4
|
0
|
313
|
my($self, $text) = @_; |
|
58
|
4
|
|
|
|
|
18
|
return HTML::Entities::encode_entities_numeric($text); |
|
59
|
|
|
|
|
|
|
} |
|
60
|
|
|
|
|
|
|
|
|
61
|
|
|
|
|
|
|
1; |
|
62
|
|
|
|
|
|
|
|
|
63
|
|
|
|
|
|
|
__END__ |