| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | package App::ZofCMS::Plugin::AntiSpamMailTo; | 
| 2 |  |  |  |  |  |  |  | 
| 3 | 1 |  |  | 1 |  | 4 | use warnings; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 23 |  | 
| 4 | 1 |  |  | 1 |  | 3 | use strict; | 
|  | 1 |  |  |  |  | 1 |  | 
|  | 1 |  |  |  |  | 29 |  | 
| 5 |  |  |  |  |  |  |  | 
| 6 |  |  |  |  |  |  | our $VERSION = '1.001006'; # VERSION | 
| 7 |  |  |  |  |  |  |  | 
| 8 | 1 |  |  | 1 |  | 409 | use HTML::Entities; | 
|  | 1 |  |  |  |  | 3506 |  | 
|  | 1 |  |  |  |  | 303 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 | 1 |  |  | 1 | 0 | 2 | sub new { bless {}, shift } | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | sub process { | 
| 13 | 1 |  |  | 1 | 0 | 2 | my ( $self, $template, $config ) = @_[0,1,3]; | 
| 14 |  |  |  |  |  |  |  | 
| 15 |  |  |  |  |  |  | return | 
| 16 | 1 | 50 | 33 |  |  | 6 | unless $template->{plug_anti_spam_mailto} | 
| 17 |  |  |  |  |  |  | or $config->conf->{plug_anti_spam_mailto}; | 
| 18 |  |  |  |  |  |  |  | 
| 19 | 1 |  |  |  |  | 2 | my $c_data = delete $config->conf->{plug_anti_spam_mailto}; | 
| 20 | 1 |  |  |  |  | 1 | my $t_data = delete $template->{plug_anti_spam_mailto}; | 
| 21 |  |  |  |  |  |  |  | 
| 22 | 1 |  |  |  |  | 1 | my $data; | 
| 23 | 1 | 50 | 33 |  |  | 5 | if ( defined $c_data and defined $t_data ) { | 
|  |  | 0 |  |  |  |  |  | 
| 24 | 1 | 50 |  |  |  | 2 | if ( ref $c_data ne ref $t_data ) { | 
| 25 | 0 |  |  |  |  | 0 | $data = $t_data; | 
| 26 |  |  |  |  |  |  | } | 
| 27 |  |  |  |  |  |  | else { | 
| 28 | 1 | 50 |  |  |  | 7 | $data = ref $t_data eq 'ARRAY' | 
|  |  | 50 |  |  |  |  |  | 
| 29 |  |  |  |  |  |  | ? $data = [ @$t_data, @$c_data ] | 
| 30 |  |  |  |  |  |  | : ref $t_data eq 'HASH' | 
| 31 |  |  |  |  |  |  | ? $data = { %$c_data, %$t_data } | 
| 32 |  |  |  |  |  |  | : [ $t_data, $c_data ]; | 
| 33 |  |  |  |  |  |  | } | 
| 34 |  |  |  |  |  |  | } | 
| 35 |  |  |  |  |  |  | elsif ( defined $t_data ) { | 
| 36 | 0 |  |  |  |  | 0 | $data = $t_data; | 
| 37 |  |  |  |  |  |  | } | 
| 38 |  |  |  |  |  |  | else { | 
| 39 | 0 |  |  |  |  | 0 | $data = $c_data; | 
| 40 |  |  |  |  |  |  | } | 
| 41 |  |  |  |  |  |  |  | 
| 42 | 1 | 50 |  |  |  | 4 | if ( ref $data eq 'ARRAY' ) { | 
|  |  | 50 |  |  |  |  |  | 
| 43 | 0 |  |  |  |  | 0 | $data = { | 
| 44 |  |  |  |  |  |  | map +( "mailto_$_" => $data->[$_] ), | 
| 45 |  |  |  |  |  |  | 0.. $#$data | 
| 46 |  |  |  |  |  |  | }; | 
| 47 |  |  |  |  |  |  | } | 
| 48 |  |  |  |  |  |  | elsif ( not ref $data ) { | 
| 49 | 0 |  |  |  |  | 0 | $data = { 'mailto' => $data }; | 
| 50 |  |  |  |  |  |  | } | 
| 51 |  |  |  |  |  |  |  | 
| 52 |  |  |  |  |  |  | encode_entities $_, '\w\W' | 
| 53 | 1 |  |  |  |  | 4 | for values %$data; | 
| 54 |  |  |  |  |  |  |  | 
| 55 | 1 |  |  |  |  | 143 | @{ $template->{t} }{ keys %$data } = values %$data; | 
|  | 1 |  |  |  |  | 3 |  | 
| 56 |  |  |  |  |  |  |  | 
| 57 | 1 |  |  |  |  | 3 | return 1; | 
| 58 |  |  |  |  |  |  | } | 
| 59 |  |  |  |  |  |  |  | 
| 60 |  |  |  |  |  |  | 1; | 
| 61 |  |  |  |  |  |  | __END__ |