| 1 | package App::ZofCMS::Plugin::GetRemotePageTitle; | ||||||||||||||||||||||||||||
| 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 base 'App::ZofCMS::Plugin::Base'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use WWW::GetPageTitle; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub _key { | ||||||||||||||||||||||||||
|
Subroutine
_key: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 12 | 0 | 'plug_get_remote_page_title' | |||||||||||||||||||||||||||
| 13 | } | ||||||||||||||||||||||||||||
| 14 | 0 | ▶ | sub _defaults { | ||||||||||||||||||||||||||
|
Subroutine
_defaults: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||
| 15 | 0 | ua => LWP::UserAgent->new( | |||||||||||||||||||||||||||
| 16 | agent => "Opera 9.5", | ||||||||||||||||||||||||||||
| 17 | timeout => 30, | ||||||||||||||||||||||||||||
| 18 | max_size => 2000, | ||||||||||||||||||||||||||||
| 19 | ), | ||||||||||||||||||||||||||||
| 20 | uri => undef, | ||||||||||||||||||||||||||||
| 21 | } | ||||||||||||||||||||||||||||
| 22 | 0 | ▶ | sub _do { | ||||||||||||||||||||||||||
|
Subroutine
_do: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||
| 23 | 0 | my ( $self, $conf, $t, $q, $config ) = @_; | |||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||
| 25 | $conf->{uri} = $conf->{uri}->( $t, $q, $config ) | ||||||||||||||||||||||||||||
| 26 | 0 | ▶ | if ref $conf->{uri} eq 'CODE'; | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 27 | |||||||||||||||||||||||||||||
| 28 | return | ||||||||||||||||||||||||||||
| 29 | unless defined $conf->{uri} | ||||||||||||||||||||||||||||
| 30 | 0 | ▶ | and length $conf->{uri}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $conf->{"uri"} and length $conf->{"uri"}
MC/DC0%0/2
defined $conf->{"uri"} and length $conf->{"uri"}
defined $conf->{"uri"}
length $conf->{"uri"}
Truth table0%0/3
A and B
A= defined $conf->{"uri"}B= length $conf->{"uri"}
| |||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | my $title = WWW::GetPageTitle->new( ua => $conf->{ua} ); | |||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||
| 35 | 0 | ▶ | if ( ref $conf->{uri} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 36 | 0 | my @results; | |||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||
| 38 | 0 | for ( @{ $conf->{uri} } ) { | |||||||||||||||||||||||||||
| 39 | 0 | my $page_title = $title->get_title( $_ ); | |||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | 0 | ▶ | if ( defined $page_title ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 42 | 0 | push @results, { title => $page_title }; | |||||||||||||||||||||||||||
| 43 | } | ||||||||||||||||||||||||||||
| 44 | else { | ||||||||||||||||||||||||||||
| 45 | 0 | push @results, { error => $title->error }; | |||||||||||||||||||||||||||
| 46 | } | ||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||
| 48 | 0 | $t->{t}{plug_remote_page_title} = \@results; | |||||||||||||||||||||||||||
| 49 | } | ||||||||||||||||||||||||||||
| 50 | } | ||||||||||||||||||||||||||||
| 51 | else { | ||||||||||||||||||||||||||||
| 52 | 0 | my $page_title = $title->get_title( $conf->{uri} ); | |||||||||||||||||||||||||||
| 53 | 0 | ▶ | if ( defined $page_title ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 54 | 0 | $t->{t}{plug_remote_page_title} = $page_title; | |||||||||||||||||||||||||||
| 55 | } | ||||||||||||||||||||||||||||
| 56 | else { | ||||||||||||||||||||||||||||
| 57 | 0 | $t->{t}{plug_remote_page_title_error} = $title->error; | |||||||||||||||||||||||||||
| 58 | } | ||||||||||||||||||||||||||||
| 59 | } | ||||||||||||||||||||||||||||
| 60 | } | ||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||
| 62 | 1 | 1; | |||||||||||||||||||||||||||
| 63 | __END__ | ||||||||||||||||||||||||||||