| 1 | package App::ZofCMS::Plugin::AutoIMGSize; | ||||||||||||||||||||||||||||
| 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 HTML::Entities; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 9 | 1 | ▶ | use Image::Size (qw/html_imgsize/); | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 10 | |||||||||||||||||||||||||||||
| 11 | 0 | ▶ | sub new { bless {}, shift } | ||||||||||||||||||||||||||
|
Subroutine
new: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||
| 13 | 0 | ▶ | sub process { | ||||||||||||||||||||||||||
|
Subroutine
process: not called CC=11 SCAR=48.8
Pod
undocumented
| |||||||||||||||||||||||||||||
| 14 | 0 | my ( $self, $template, $query, $config ) = @_; | |||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||
| 16 | return | ||||||||||||||||||||||||||||
| 17 | unless $template->{plug_auto_img_size} | ||||||||||||||||||||||||||||
| 18 | 0 | ▶ | or $config->conf->{plug_auto_img_size}; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$template->{"plug_auto_img_size"} or $config->conf->{"plug_auto_img_size"}
MC/DC0%0/2
$template->{"plug_auto_img_size"} or $config->conf->{"plug_auto_img_size"}
$template->{"plug_auto_img_size"}
$config->conf->{"plug_auto_img_size"}
Truth table0%0/3
A or B
A= $template->{"plug_auto_img_size"}B= $config->conf->{"plug_auto_img_size"}
| |||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||
| 20 | my %conf = ( | ||||||||||||||||||||||||||||
| 21 | t_prefix => 'img_', | ||||||||||||||||||||||||||||
| 22 | xhtml => 0, | ||||||||||||||||||||||||||||
| 23 | 0 | ▶ | %{ delete $config->conf->{plug_auto_img_size} || {} }, | ||||||||||||||||||||||||||
|
Condition0%0/2
delete $config->conf->{'plug_auto_img_size'} || {}
MC/DC0%0/1
delete $config->conf->{'plug_auto_img_size'} || {}
delete $config->conf->{'plug_auto_img_size'}
Truth table0%0/2
A
A= delete $config->conf->{'plug_auto_img_size'}
| |||||||||||||||||||||||||||||
| 24 | 0 | ▶ | %{ delete $template->{plug_auto_img_size} || {} }, | ||||||||||||||||||||||||||
|
Condition0%0/2
delete $template->{'plug_auto_img_size'} || {}
MC/DC0%0/1
delete $template->{'plug_auto_img_size'} || {}
delete $template->{'plug_auto_img_size'}
Truth table0%0/2
A
A= delete $template->{'plug_auto_img_size'}
| |||||||||||||||||||||||||||||
| 25 | ); | ||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||
| 27 | 0 | ▶ | if ( ref $conf{imgs} eq 'ARRAY' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 28 | $conf{imgs} = { | ||||||||||||||||||||||||||||
| 29 | 0 | map +( $_ => $_ ), @{ $conf{imgs} } | |||||||||||||||||||||||||||
| 30 | }; | ||||||||||||||||||||||||||||
| 31 | } | ||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||
| 33 | 0 | keys %{ $conf{imgs} }; | |||||||||||||||||||||||||||
| 34 | 0 | ▶ | while ( my ( $name, $file ) = each %{ $conf{imgs} } ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 35 | 0 | my $extra = ''; | |||||||||||||||||||||||||||
| 36 | 0 | ▶ | if ( ref $file eq 'HASH' ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 37 | 0 | ( $file, $extra ) = %$file; | |||||||||||||||||||||||||||
| 38 | } | ||||||||||||||||||||||||||||
| 39 | 0 | ▶ | unless ( -e $file ) { | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 40 | 0 | $template->{t}{ $conf{t_prefix} . $name } = 'ERROR: File not found'; | |||||||||||||||||||||||||||
| 41 | 0 | next; | |||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | 0 | ▶ | $extra = ' alt=""' | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 45 | unless length $extra; | ||||||||||||||||||||||||||||
| 46 | |||||||||||||||||||||||||||||
| 47 | 0 | my $size = html_imgsize $file; | |||||||||||||||||||||||||||
| 48 | 0 | encode_entities $file; | |||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||
| 50 | $template->{t}{ $conf{t_prefix} . $name } | ||||||||||||||||||||||||||||
| 51 | 0 | ▶ | = qq|<img src="/$file" $size$extra| . ( $conf{xhtml} ? '/>' : '>' ); | ||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | } | ||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||
| 56 | 1 | 1; | |||||||||||||||||||||||||||
| 57 | __END__ | ||||||||||||||||||||||||||||