| 1 | package App::ZofCMS::Plugin::LinkifyText; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 1 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||
| 6 | 1 | our $VERSION = '1.001010'; # VERSION | |||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 1 | ▶ | use URI::Find::Schemeless; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use HTML::Entities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | 1 | ▶ | use base 'App::ZofCMS::Plugin::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | 0 | ▶ | sub _key { 'plug_linkify_text' } | ||||||||||||||||||||||||||
|
Subroutine
_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub _defaults { | ||||||||||||||||||||||||||
|
Subroutine
_defaults: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 14 | cell => 't', | ||||||||||||||||||||||||||||
| 15 | key => 'plug_linkify_text', | ||||||||||||||||||||||||||||
| 16 | encode_entities => 1, | ||||||||||||||||||||||||||||
| 17 | new_lines_as_br => 1, | ||||||||||||||||||||||||||||
| 18 | text => undef, | ||||||||||||||||||||||||||||
| 19 | 0 | ▶ | callback => sub { | ||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 20 | 0 | my $uri = encode_entities $_[0]; | |||||||||||||||||||||||||||
| 21 | 0 | return qq|<a href="$uri">$uri</a>|; | |||||||||||||||||||||||||||
| 22 | }, | ||||||||||||||||||||||||||||
| 23 | 0 | } | |||||||||||||||||||||||||||
| 24 | 0 | ▶ | sub _do { | ||||||||||||||||||||||||||
|
Subroutine
_do: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||
| 25 | 0 | my ( $self, $conf, $t, $q, $config ) = @_; | |||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( ref $conf->{text} eq 'CODE' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | 0 | $conf->{text} = $conf->{text}->( $t, $q, $config ); | |||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | return | ||||||||||||||||||||||||||||
| 32 | unless defined $conf->{text} | ||||||||||||||||||||||||||||
| 33 | 0 | ▶ | and length $conf->{text}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $conf->{"text"} and length $conf->{"text"}
MC/DC0%0/2
defined $conf->{"text"} and length $conf->{"text"}
defined $conf->{"text"}
length $conf->{"text"}
Truth table0%0/3
A and B
A= defined $conf->{"text"}B= length $conf->{"text"}
| |||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ( ref $conf->{text} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||
| 36 | 0 | my @results; | |||||||||||||||||||||||||||
| 37 | 0 | for ( @{ $conf->{text} } ) { | |||||||||||||||||||||||||||
| 38 | 0 | push @results, { text => process_text( $conf, $_ ) }; | |||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||
| 40 | 0 | $t->{ $conf->{cell} }{ $conf->{key} } = \@results; | |||||||||||||||||||||||||||
| 41 | } | ||||||||||||||||||||||||||||
| 42 | elsif ( ref $conf->{text} eq 'REF' ) { | ||||||||||||||||||||||||||||
| 43 | 0 | process_in_place_edits( $conf, $t ); | |||||||||||||||||||||||||||
| 44 | } | ||||||||||||||||||||||||||||
| 45 | else { | ||||||||||||||||||||||||||||
| 46 | $t->{ $conf->{cell} }{ $conf->{key} } | ||||||||||||||||||||||||||||
| 47 | 0 | = process_text( $conf, $conf->{text} ); | |||||||||||||||||||||||||||
| 48 | } | ||||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | 0 | ▶ | sub process_in_place_edits { | ||||||||||||||||||||||||||
|
Subroutine
process_in_place_edits: not called CC=8 SCAR=42.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 52 | 0 | my ( $conf, $t ) = @_; | |||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | 0 | my @text_keys = grep /^text\d*$/, keys %$conf; | |||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 0 | for my $conf_key ( @text_keys ) { | |||||||||||||||||||||||||||
| 57 | my $text_ref = ref $conf->{$conf_key} eq 'REF' ? | ||||||||||||||||||||||||||||
| 58 | 0 | ▶ | ${ $conf->{$conf_key} } : $conf->{$conf_key}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||
| 60 | 0 | ▶ | if ( ref $text_ref eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 61 | 0 | my ( $data_key, @text_keys ) = @$text_ref; | |||||||||||||||||||||||||||
| 62 | 0 | ▶ | for my $text_hashref ( @{ $t->{t}{$data_key} || [] } ) { | ||||||||||||||||||||||||||
|
Condition0%0/2
$t->{'t'}{$data_key} || []
MC/DC0%0/1
$t->{'t'}{$data_key} || []
$t->{'t'}{$data_key}
Truth table0%0/2
A
A= $t->{'t'}{$data_key}
| |||||||||||||||||||||||||||||
| 63 | 0 | for ( @text_keys ) { | |||||||||||||||||||||||||||
| 64 | $text_hashref->{$_} | ||||||||||||||||||||||||||||
| 65 | 0 | = process_text( $conf, $text_hashref->{$_} ); | |||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||
| 68 | } | ||||||||||||||||||||||||||||
| 69 | else { | ||||||||||||||||||||||||||||
| 70 | 0 | ▶ | $text_ref = $$text_ref | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 71 | if ref $text_ref; | ||||||||||||||||||||||||||||
| 72 | |||||||||||||||||||||||||||||
| 73 | 0 | $t->{t}{$text_ref} = process_text( $conf, $t->{t}{$text_ref} ); | |||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||
| 75 | } | ||||||||||||||||||||||||||||
| 76 | } | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 0 | ▶ | sub process_text { | ||||||||||||||||||||||||||
|
Subroutine
process_text: not called CC=3 SCAR=24.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 79 | 0 | my ( $conf, $text ) = @_; | |||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||
| 81 | 0 | ▶ | if ( $conf->{encode_entities} ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 82 | 0 | encode_entities $text; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | $text =~ s/\r?\n/<br>/g | ||||||||||||||||||||||||||||
| 85 | 0 | ▶ | if $conf->{new_lines_as_br}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 86 | } | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | 0 | URI::Find::Schemeless->new( $conf->{callback} )->find( \$text ); | |||||||||||||||||||||||||||
| 89 | 0 | return $text; | |||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | 1 | 1; | |||||||||||||||||||||||||||
| 93 | __END__ | ||||||||||||||||||||||||||||