| 1 | package Labyrinth::Plugin::Album::Pages; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | |||||||||||||||||||||||||||||||||||||||||||
| 6 | 3 | our $VERSION = '1.12'; | |||||||||||||||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||||||||||||
| 10 | Labyrinth::Plugin::Album::Pages - Photo album pages handler for Labyrinth | ||||||||||||||||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | Contains all the photo album handling functionality for the Labyrinth | ||||||||||||||||||||||||||||||||||||||||||
| 15 | framework. | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 20 | # Libraries | ||||||||||||||||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||||||||||||||||
| 22 | 3 | ▶ | use base qw(Labyrinth::Plugin::Base); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||
| 24 | 3 | ▶ | use File::Path; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 25 | |||||||||||||||||||||||||||||||||||||||||||
| 26 | 3 | ▶ | use Labyrinth::Audit; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 27 | 3 | ▶ | use Labyrinth::DBUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 28 | 3 | ▶ | use Labyrinth::DTUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 29 | 3 | ▶ | use Labyrinth::Media; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 30 | 3 | ▶ | use Labyrinth::Metadata; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 31 | 3 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 32 | 3 | ▶ | use Labyrinth::Support; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 33 | 3 | ▶ | use Labyrinth::Variables; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 34 | |||||||||||||||||||||||||||||||||||||||||||
| 35 | 3 | ▶ | use Labyrinth::Plugin::Hits; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | # ------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 38 | # Constants | ||||||||||||||||||||||||||||||||||||||||||
| 39 | |||||||||||||||||||||||||||||||||||||||||||
| 40 | 3 | ▶ | use constant MaxPhotoWidth => 1024; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 41 | 3 | ▶ | use constant MaxPhotoHeight => 1024; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 42 | 3 | ▶ | use constant MaxThumbWidth => 200; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 43 | 3 | ▶ | use constant MaxThumbHeight => 200; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 46 | # Variables | ||||||||||||||||||||||||||||||||||||||||||
| 47 | |||||||||||||||||||||||||||||||||||||||||||
| 48 | # type: 0 = optional, 1 = mandatory | ||||||||||||||||||||||||||||||||||||||||||
| 49 | # html: 0 = none, 1 = text, 2 = textarea | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | 3 | my %fields = ( | |||||||||||||||||||||||||||||||||||||||||
| 52 | title => { type => 1, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 53 | summary => { type => 0, html => 2 }, | ||||||||||||||||||||||||||||||||||||||||||
| 54 | area => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 55 | year => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 56 | month => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 57 | pageid => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 58 | parent => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 59 | hide => { type => 0, html => 1 }, | ||||||||||||||||||||||||||||||||||||||||||
| 60 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 61 | |||||||||||||||||||||||||||||||||||||||||||
| 62 | 3 | my (@mandatory,@allfields); | |||||||||||||||||||||||||||||||||||||||||
| 63 | 3 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 64 | 24 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 65 | 24 | push @allfields, $_; | |||||||||||||||||||||||||||||||||||||||||
| 66 | } | ||||||||||||||||||||||||||||||||||||||||||
| 67 | |||||||||||||||||||||||||||||||||||||||||||
| 68 | 3 | my @savefields = qw(parent title summary year month hide pageid); | |||||||||||||||||||||||||||||||||||||||||
| 69 | 3 | my @addfields = qw(parent title summary year month hide area path); | |||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | 3 | my $INDEXKEY = 'pageid'; | |||||||||||||||||||||||||||||||||||||||||
| 72 | 3 | my $LEVEL = PUBLISHER; | |||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | 3 | my $hits = Labyrinth::Plugin::Hits->new(); | |||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 77 | # Public Interface Functions | ||||||||||||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||||||||||||
| 79 | =head1 PUBLIC INTERFACE METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 80 | |||||||||||||||||||||||||||||||||||||||||||
| 81 | =head2 Public Methods | ||||||||||||||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||||||||||||
| 83 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 84 | |||||||||||||||||||||||||||||||||||||||||||
| 85 | =item List | ||||||||||||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||||||||||||
| 87 | Provides a list of all the public photo albums. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | =item Children | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Provides a list of photo albums for which the specified photo album is their | ||||||||||||||||||||||||||||||||||||||||||
| 92 | parent. | ||||||||||||||||||||||||||||||||||||||||||
| 93 | |||||||||||||||||||||||||||||||||||||||||||
| 94 | =item Search | ||||||||||||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||||||||||||
| 96 | Search for photo albums matching a given set of metadata. | ||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||
| 98 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 99 | |||||||||||||||||||||||||||||||||||||||||||
| 100 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||||||||||||||||
| 102 | 0 | ▶ | sub List { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
List: not called CC=22 SCAR=62.3
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 103 | 0 | my ($key,@args); | |||||||||||||||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||||||||||||||||
| 105 | 0 | my $now = time() - 2419200; # seconds in a 4 week month | |||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | my ($where,@where); | |||||||||||||||||||||||||||||||||||||||||
| 108 | 0 | ▶ | if($cgiparams{all}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | $key = 'SearchPages'; | |||||||||||||||||||||||||||||||||||||||||
| 110 | } elsif($cgiparams{latest}) { | ||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $key = 'SearchPagesLatest'; | |||||||||||||||||||||||||||||||||||||||||
| 112 | ▶ | } elsif($cgiparams{month} || $cgiparams{year} || $cgiparams{metadata}) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/6
$Labyrinth::Plugin::Album::Pages::cgiparams{"month"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"year"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"metadata"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"month"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"year"}
MC/DC0%0/3
$Labyrinth::Plugin::Album::Pages::cgiparams{"month"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"year"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"metadata"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"month"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"year"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"metadata"}
Truth table0%0/4
A or B or C
A= $Labyrinth::Plugin::Album::Pages::cgiparams{"month"}B= $Labyrinth::Plugin::Album::Pages::cgiparams{"year"}C= $Labyrinth::Plugin::Album::Pages::cgiparams{"metadata"}
| |||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | push @where, "p.month=$cgiparams{month}" if($cgiparams{month}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | ▶ | push @where, "p.year=$cgiparams{year}" if($cgiparams{year}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | push @where, "p.title='%$cgiparams{metadata}%'" if($cgiparams{metadata}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $key = 'SearchPages'; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 118 | 0 | $cgiparams{year} = formatDate(1); | |||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | push @where, "p.year=$cgiparams{year}"; | |||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $key = 'SearchPages'; | |||||||||||||||||||||||||||||||||||||||||
| 121 | } | ||||||||||||||||||||||||||||||||||||||||||
| 122 | |||||||||||||||||||||||||||||||||||||||||||
| 123 | 0 | ▶ | $where = ' AND ' . join(' AND ',@where) if(@where); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my @rs = $dbi->GetQuery('hash',$key,{where=>$where}); | |||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | for my $rec (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $rec->{month} = isMonth($rec->{month}); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | ▶ | $rec->{new} = ($rec->{now} > $now ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 129 | #LogDebug( "$now < $rec->{now} = ".localtime($rec->{now})) if($rec->{new}); | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | ▶ | if($fields{$_}->{html} == 1) { $rec->{$_} = CleanHTML($rec->{$_}); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | elsif($fields{$_}->{html} == 2) { $rec->{$_} = CleanTags($rec->{$_}); } | |||||||||||||||||||||||||||||||||||||||||
| 133 | } | ||||||||||||||||||||||||||||||||||||||||||
| 134 | |||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | ▶ | my $dw = $settings{gallerythumbwidth} || MaxThumbWidth; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbwidth'} || 200
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbwidth'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbwidth'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'gallerythumbwidth'}
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | ▶ | my $dh = $settings{gallerythumbheight} || MaxThumbHeight; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbheight'} || 200
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbheight'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbheight'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'gallerythumbheight'}
| |||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||
| 138 | 0 | ▶ | if($rec->{dimensions}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 139 | 0 | my ($w,$h) = split('x',$rec->{dimensions}); | |||||||||||||||||||||||||||||||||||||||||
| 140 | 0 | ▶ | if($w/$dw > $h/$dh) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 141 | 0 | $rec->{width} = $dw; | |||||||||||||||||||||||||||||||||||||||||
| 142 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | $rec->{height} = $dh; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | } | ||||||||||||||||||||||||||||||||||||||||||
| 147 | |||||||||||||||||||||||||||||||||||||||||||
| 148 | 0 | ▶ | $tvars{records} = \@rs if(@rs); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | ▶ | $tvars{month} = $cgiparams{month} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{'month'}
| |||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | $tvars{year} = $cgiparams{year} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{'year'}
| |||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $tvars{ddmonths} = MonthSelect($cgiparams{month},1); | |||||||||||||||||||||||||||||||||||||||||
| 152 | 0 | $tvars{ddyears} = YearSelect($cgiparams{year},2,1); | |||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $tvars{pid} = 4; | |||||||||||||||||||||||||||||||||||||||||
| 154 | 0 | $tvars{iid} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 155 | } | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | 0 | ▶ | sub Children { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Children: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | $cgiparams{'pageid'} ||= $cgiparams{'pid'}; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"} ||= $Labyrinth::Plugin::Album::Pages::cgiparams{"pid"}
MC/DC0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"} ||= $Labyrinth::Plugin::Album::Pages::cgiparams{"pid"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"pid"}
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}B= $Labyrinth::Plugin::Album::Pages::cgiparams{"pid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | my @rs = $dbi->GetQuery('hash','GetChildPages',$cgiparams{pageid}); | |||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | ▶ | $tvars{album}{children} = \@rs if(@rs); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 161 | } | ||||||||||||||||||||||||||||||||||||||||||
| 162 | |||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | sub Search { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Search: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 164 | 0 | my $limit = $settings{limit}; | |||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||
| 166 | 0 | my $now = time() - 2419200; # seconds in a 4 week month | |||||||||||||||||||||||||||||||||||||||||
| 167 | 0 | my @rs; | |||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | if($cgiparams{metadata}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | my @data = split(qr/[ ,]+/,$cgiparams{metadata}); | |||||||||||||||||||||||||||||||||||||||||
| 171 | 0 | ▶ | @rs = MetaSearch( 'keys' => ['PagePhoto','Photo'], | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$limit || ''
MC/DC0%0/1
$limit || ''
$limit
Truth table0%0/2
A
A= $limit
| |||||||||||||||||||||||||||||||||||||||||||
| 172 | 'meta' => \@data, | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 'where' => "hide=0", | ||||||||||||||||||||||||||||||||||||||||||
| 174 | 'limit' => ($limit || '')); | ||||||||||||||||||||||||||||||||||||||||||
| 175 | 0 | for my $rec (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $rec->{month} = isMonth($rec->{month}); | |||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | ▶ | $rec->{new} = ($rec->{now} > $now ? 1 : 0); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 178 | #LogDebug( "$now < $rec->{now} = ".localtime($rec->{now})) if($rec->{new}); | ||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 180 | 0 | ▶ | if($fields{$_}->{html} == 1) { $rec->{$_} = CleanHTML($rec->{$_}); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 0 | elsif($fields{$_}->{html} == 2) { $rec->{$_} = SafeHTML($rec->{$_}); } | |||||||||||||||||||||||||||||||||||||||||
| 182 | } | ||||||||||||||||||||||||||||||||||||||||||
| 183 | } | ||||||||||||||||||||||||||||||||||||||||||
| 184 | } | ||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | 0 | ▶ | $tvars{records} = \@rs if(@rs); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 187 | 0 | ▶ | $tvars{month} = $cgiparams{month} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{'month'}
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | $tvars{year} = $cgiparams{year} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{'year'}
| |||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | $tvars{ddmonths} = MonthSelect($cgiparams{month},1); | |||||||||||||||||||||||||||||||||||||||||
| 190 | 0 | $tvars{ddyears} = YearSelect($cgiparams{year},2,1); | |||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | $tvars{pid} = 4; | |||||||||||||||||||||||||||||||||||||||||
| 192 | 0 | $tvars{iid} = 0; | |||||||||||||||||||||||||||||||||||||||||
| 193 | } | ||||||||||||||||||||||||||||||||||||||||||
| 194 | |||||||||||||||||||||||||||||||||||||||||||
| 195 | #---------------------------------------------------------------------------- | ||||||||||||||||||||||||||||||||||||||||||
| 196 | # Administration Interface Functions | ||||||||||||||||||||||||||||||||||||||||||
| 197 | |||||||||||||||||||||||||||||||||||||||||||
| 198 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | =head2 Administration Methods | ||||||||||||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||||||||||||
| 202 | =over 4 | ||||||||||||||||||||||||||||||||||||||||||
| 203 | |||||||||||||||||||||||||||||||||||||||||||
| 204 | =item Admin | ||||||||||||||||||||||||||||||||||||||||||
| 205 | |||||||||||||||||||||||||||||||||||||||||||
| 206 | Provides a list of all the current photo albums, with additional administrator | ||||||||||||||||||||||||||||||||||||||||||
| 207 | functions. | ||||||||||||||||||||||||||||||||||||||||||
| 208 | |||||||||||||||||||||||||||||||||||||||||||
| 209 | =item Add | ||||||||||||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||||||||||||
| 211 | Prep for adding a photo album. | ||||||||||||||||||||||||||||||||||||||||||
| 212 | |||||||||||||||||||||||||||||||||||||||||||
| 213 | =item ArchiveEdit | ||||||||||||||||||||||||||||||||||||||||||
| 214 | |||||||||||||||||||||||||||||||||||||||||||
| 215 | Delete archived photos or Move photos to public albums. | ||||||||||||||||||||||||||||||||||||||||||
| 216 | |||||||||||||||||||||||||||||||||||||||||||
| 217 | =item Edit | ||||||||||||||||||||||||||||||||||||||||||
| 218 | |||||||||||||||||||||||||||||||||||||||||||
| 219 | Edit details of a photo album. | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =item Save | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | Save the details of a photo album. | ||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =item Delete | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | Delete a public album, moving all photos to the archive album. | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | =item PageSelect | ||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||
| 231 | Provides a HTML drop-down list of available pages. | ||||||||||||||||||||||||||||||||||||||||||
| 232 | |||||||||||||||||||||||||||||||||||||||||||
| 233 | =item Selection | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | Shortcut to PageSelect, automatically selecting the current album. | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 240 | |||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | ▶ | sub Admin { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Admin: not called CC=38 SCAR=73.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 242 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | 0 | my (%current,$where,@rs); | |||||||||||||||||||||||||||||||||||||||||
| 245 | 0 | ▶ | if($cgiparams{doaction} || $cgiparams{order}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"order"}
MC/DC0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"order"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"order"}
Truth table0%0/3
A or B
A= $Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"}B= $Labyrinth::Plugin::Album::Pages::cgiparams{"order"}
| |||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | $where = ''; | |||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | ▶ | if($cgiparams{was}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | my @was; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | my ($this,$that) = split("/",$cgiparams{was}); | |||||||||||||||||||||||||||||||||||||||||
| 250 | 0 | ▶ | push @was, "month=$cgiparams{month}" if($this); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | push @was, "year=$cgiparams{year}" if($that); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 252 | 0 | ▶ | $where = 'WHERE ' . join(' AND ',@was) if(@was); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | @rs = $dbi->GetQuery('hash','AdminPages',{where=>$where}); | |||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | $current{$_->{pageid}} = $_ for(@rs); | |||||||||||||||||||||||||||||||||||||||||
| 257 | } | ||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | ▶ | if($cgiparams{doaction}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | ▶ | if($cgiparams{doaction} eq 'Update') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 261 | |||||||||||||||||||||||||||||||||||||||||||
| 262 | # check whether we need to hide/show any pages | ||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | my @ids = CGIArray('HIDE'); | |||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | my %hide = map {$_ => 1} @ids; | |||||||||||||||||||||||||||||||||||||||||
| 265 | 0 | my @show; | |||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | my $where = ''; | |||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | for(keys %hide) { | |||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | if($current{$_}->{hide}) { delete $current{$_}; delete $hide{$_}; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||
| 271 | 0 | for(keys %current) { | |||||||||||||||||||||||||||||||||||||||||
| 272 | 0 | ▶ | if($current{$_}->{hide}) { push @show, $_; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | ▶ | $dbi->DoQuery('HidePages',{list=>join(",",keys %hide)}) if(keys %hide); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | $dbi->DoQuery('ShowPages',{list=>join(",",@show)}) if(@show); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | ▶ | $hits->SetUpdates('album',0,@show) if(@show); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | } | ||||||||||||||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | # reorder a specific page | ||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | ▶ | if($cgiparams{'order'} && $cgiparams{'pageid'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::cgiparams{"order"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
MC/DC0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{"order"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"order"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
Truth table0%0/3
A and B
A= $Labyrinth::Plugin::Album::Pages::cgiparams{"order"}B= $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | my $order = $cgiparams{'order'}; | |||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my $pageid = $cgiparams{'pageid'}; | |||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | my (@was,%order,%pages) = (); | |||||||||||||||||||||||||||||||||||||||||
| 286 | |||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | push @was, "month=$current{$pageid}->{month}"; | |||||||||||||||||||||||||||||||||||||||||
| 288 | 0 | push @was, "year=$current{$pageid}->{year}"; | |||||||||||||||||||||||||||||||||||||||||
| 289 | 0 | $where = 'WHERE ' . join(' AND ',@was); | |||||||||||||||||||||||||||||||||||||||||
| 290 | 0 | @rs = $dbi->GetQuery('hash','AdminPages',{where=>$where}); | |||||||||||||||||||||||||||||||||||||||||
| 291 | 0 | ▶ | if(@rs > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 292 | 0 | my $max = my $inx = @rs; | |||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | for(@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | $order{$inx} = $_->{pageid}; | |||||||||||||||||||||||||||||||||||||||||
| 295 | 0 | $pages{$_->{pageid}} = $inx--; | |||||||||||||||||||||||||||||||||||||||||
| 296 | } | ||||||||||||||||||||||||||||||||||||||||||
| 297 | |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $changed = 0; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if($order =~ /up/i) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | # LogDebug("max=$inx, this=$pages{$pageid}"); | ||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | ▶ | if($pages{$pageid} < $max) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | $inx = $pages{$pageid}; | |||||||||||||||||||||||||||||||||||||||||
| 303 | 0 | $order{$inx} = $order{$inx + 1}; | |||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | $order{$inx + 1} = $pageid; | |||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | $changed = 1; | |||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||
| 307 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | ▶ | if($pages{$pageid} > 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | $inx = $pages{$pageid}; | |||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | $order{$inx} = $order{$inx - 1}; | |||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | $order{$inx - 1} = $pageid; | |||||||||||||||||||||||||||||||||||||||||
| 312 | 0 | $changed = 1; | |||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | ▶ | if($changed) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 317 | 0 | $dbi->DoQuery('ReorderPage',$_,$order{$_}) for(keys %order); | |||||||||||||||||||||||||||||||||||||||||
| 318 | } | ||||||||||||||||||||||||||||||||||||||||||
| 319 | } | ||||||||||||||||||||||||||||||||||||||||||
| 320 | } | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | # now show the latest settings :) | ||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $where = ''; | |||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | my @where; | |||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | ▶ | push @where, "month=$cgiparams{month}" if($cgiparams{month}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | ▶ | push @where, "year=$cgiparams{year}" if($cgiparams{year}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 327 | 0 | ▶ | $where = 'WHERE ' . join(' AND ',@where) if(@where); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | @rs = $dbi->GetQuery('hash','AdminPages',{where=>$where}); | |||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | foreach my $rec (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | $rec->{year} = '-' unless($rec->{year}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | $rec->{month} = isMonth($rec->{month}); | |||||||||||||||||||||||||||||||||||||||||
| 333 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | ▶ | if($fields{$_}->{html} == 1) { $rec->{$_} = CleanHTML($rec->{$_}); } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | elsif($fields{$_}->{html} == 2) { $rec->{$_} = CleanTags($rec->{$_}); } | |||||||||||||||||||||||||||||||||||||||||
| 336 | } | ||||||||||||||||||||||||||||||||||||||||||
| 337 | } | ||||||||||||||||||||||||||||||||||||||||||
| 338 | |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | ▶ | $tvars{month} = $cgiparams{month} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{'month'}
| |||||||||||||||||||||||||||||||||||||||||||
| 340 | 0 | ▶ | $tvars{year} = $cgiparams{year} || ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{'year'}
| |||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | $tvars{ddmonths} = MonthSelect($cgiparams{month},1); | |||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | $tvars{ddyears} = YearSelect($cgiparams{year},2,1); | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | ▶ | $tvars{records} = \@rs if(@rs); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | 0 | ▶ | sub Add { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 348 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||
| 350 | $tvars{data}->{senarios} = [ | ||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | { id=>2, title=>'Photos Section' }, | |||||||||||||||||||||||||||||||||||||||||
| 352 | ]; | ||||||||||||||||||||||||||||||||||||||||||
| 353 | |||||||||||||||||||||||||||||||||||||||||||
| 354 | 0 | $tvars{data}->{ddmonths} = MonthSelect($tvars{data}->{month}); | |||||||||||||||||||||||||||||||||||||||||
| 355 | 0 | $tvars{data}->{ddyears} = YearSelect($tvars{data}->{year},2); | |||||||||||||||||||||||||||||||||||||||||
| 356 | } | ||||||||||||||||||||||||||||||||||||||||||
| 357 | |||||||||||||||||||||||||||||||||||||||||||
| 358 | 0 | ▶ | sub ArchiveEdit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
ArchiveEdit: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 359 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 360 | |||||||||||||||||||||||||||||||||||||||||||
| 361 | 0 | ▶ | if($cgiparams{doaction}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | my @ids = CGIArray('LISTED'); | |||||||||||||||||||||||||||||||||||||||||
| 363 | |||||||||||||||||||||||||||||||||||||||||||
| 364 | 0 | ▶ | if($cgiparams{doaction} eq 'Delete') { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | for my $id (@ids) { | |||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my @rows = $dbi->GetQuery('hash','GetPhotoByID',$id); | |||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | unlink "$settings{webdir}/photos/".$rows[0]->{image}; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | unlink "$settings{webdir}/photos/".$rows[0]->{thumb}; | |||||||||||||||||||||||||||||||||||||||||
| 369 | } | ||||||||||||||||||||||||||||||||||||||||||
| 370 | |||||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | $dbi->DoQuery('DeletePhotos',1,{ids=>join(',',@ids)}); | |||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||
| 373 | } elsif($cgiparams{doaction} eq 'Move') { | ||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | ▶ | $cgiparams{'pageid'} ||= 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"} ||= 1
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"} ||= 1
$Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | 0 | ▶ | $dbi->DoQuery('MovePhotos',{ids=>join(',',@ids)},$cgiparams{'pageid'}) if(@ids); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 0 | $cgiparams{'pageid'} = 1; | |||||||||||||||||||||||||||||||||||||||||
| 380 | } | ||||||||||||||||||||||||||||||||||||||||||
| 381 | |||||||||||||||||||||||||||||||||||||||||||
| 382 | 0 | ▶ | sub Edit { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Edit: not called CC=32 SCAR=69.6
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | my $order = $cgiparams{'order'}; | |||||||||||||||||||||||||||||||||||||||||
| 386 | 0 | my $pageid = $cgiparams{'pageid'}; | |||||||||||||||||||||||||||||||||||||||||
| 387 | 0 | my $photoid = $cgiparams{'photoid'}; | |||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | my ($sql,@rs); | |||||||||||||||||||||||||||||||||||||||||
| 389 | |||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | ▶ | if($order && $photoid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$order and $photoid
MC/DC0%0/2
$order and $photoid
$order
$photoid
Truth table0%0/3
A and B
A= $orderB= $photoid
| |||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | @rs = $dbi->GetQuery('hash','GetPhotosInOrder',$pageid); | |||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | my ($old,$cnt) = (-1,-1); | |||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | foreach (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $cnt++; | |||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | ▶ | if($_->{photoid} == $photoid) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $old = $cnt; | |||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||
| 398 | } | ||||||||||||||||||||||||||||||||||||||||||
| 399 | } | ||||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | my $max = @rs; | |||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | ▶ | if($old >= 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | my $new = $old; | |||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | ▶ | if($order eq 'up' && $old > 0) { $new--; } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
$order eq "up" and $old > 0
MC/DC0%0/2
$order eq "up" and $old > 0
$order eq "up"
$old > 0
Truth table0%0/3
A and B
A= $order eq "up"B= $old > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | ▶ | elsif($order eq 'down' && $old < $max) { $new++; } | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$order eq "down" and $old < $max
MC/DC0%0/2
$order eq "down" and $old < $max
$order eq "down"
$old < $max
Truth table0%0/3
A and B
A= $order eq "down"B= $old < $max
| |||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | ▶ | if($old != $new) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | $dbi->DoQuery('ReorderPhoto',$rs[$old]->{orderno},$rs[$new]->{photoid}); | |||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $dbi->DoQuery('ReorderPhoto',$rs[$new]->{orderno},$rs[$old]->{photoid}); | |||||||||||||||||||||||||||||||||||||||||
| 410 | } | ||||||||||||||||||||||||||||||||||||||||||
| 411 | } | ||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||
| 413 | |||||||||||||||||||||||||||||||||||||||||||
| 414 | 0 | @rs = $dbi->GetQuery('hash','GetPage',$pageid); | |||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | ▶ | if(@rs) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 417 | 0 | ▶ | if($fields{$_}->{html} == 1) { $rs[0]->{$_} = CleanHTML($rs[0]->{$_}) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | elsif($fields{$_}->{html} == 2) { $rs[0]->{$_} = SafeHTML($rs[0]->{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | elsif($fields{$_}->{html} == 3) { $rs[0]->{$_} = SafeHTML($rs[0]->{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 420 | } | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | # $rs[0]->{title} =~ s/'/\'/g if $rs[0]->{title}; | ||||||||||||||||||||||||||||||||||||||||||
| 423 | # $rs[0]->{summary} =~ s/'/\'/g if $rs[0]->{summary}; | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $tvars{data} = $rs[0]; | |||||||||||||||||||||||||||||||||||||||||
| 425 | |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | @rs = $dbi->GetQuery('hash','GetPhotosInOrder',$pageid); | |||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | foreach my $rec (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 428 | 0 | ▶ | $rec->{tagline} =~ s/'/\'/g if $rec->{tagline}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 0 | $rec->{metadata} = MetaGet($rec->{photoid},'Photo'); | |||||||||||||||||||||||||||||||||||||||||
| 430 | } | ||||||||||||||||||||||||||||||||||||||||||
| 431 | |||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | ▶ | $tvars{photos} = \@rs if(@rs); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 433 | } | ||||||||||||||||||||||||||||||||||||||||||
| 434 | |||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | $tvars{data}->{ddmonths} = MonthSelect($tvars{data}->{month}); | |||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | $tvars{data}->{ddyears} = YearSelect($tvars{data}->{year},2); | |||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $tvars{data}->{ddpages} = PageSelect(undef,1,'parent',$tvars{data}->{pageid}); | |||||||||||||||||||||||||||||||||||||||||
| 438 | |||||||||||||||||||||||||||||||||||||||||||
| 439 | # check we have an accessible directory to store photos | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 0 | ▶ | if($tvars{data}->{path}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | $settings{webdir} ||= ''; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{"webdir"} ||= ""
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{"webdir"} ||= ""
$Labyrinth::Plugin::Album::Pages::settings{"webdir"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{"webdir"}
| |||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my $dir = "$settings{webdir}/$tvars{data}->{path}"; | |||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | ▶ | $tvars{data}->{exists} = -e "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | ▶ | $tvars{data}->{directory} = -d "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | $tvars{data}->{readable} = -r "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | ▶ | $tvars{data}->{writeable} = -w "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 447 | 0 | ▶ | $tvars{data}->{executable} = -x "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 448 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $tvars{data}->{$_} = 0 for(qw(exists directory readable writeable executable)); | |||||||||||||||||||||||||||||||||||||||||
| 450 | } | ||||||||||||||||||||||||||||||||||||||||||
| 451 | |||||||||||||||||||||||||||||||||||||||||||
| 452 | # default image sizes | ||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | ▶ | $tvars{dimensions}->{photowidth} = $settings{maxphotowidth} || MaxPhotoWidth; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'} || 1024
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'} || 1024
$Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'}
| |||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | ▶ | $tvars{dimensions}->{photoheight} = $settings{maxphotoheight} || MaxPhotoHeight; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'} || 1024
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'} || 1024
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'}
| |||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | ▶ | $tvars{dimensions}->{thumbwidth} = $settings{maxthumbwidth} || MaxThumbWidth; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'} || 200
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'}
| |||||||||||||||||||||||||||||||||||||||||||
| 456 | 0 | ▶ | $tvars{dimensions}->{thumbheight} = $settings{maxthumbheight} || MaxThumbHeight; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'} || 200
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'}
| |||||||||||||||||||||||||||||||||||||||||||
| 457 | |||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $tvars{timestamp} = formatDate(0); | |||||||||||||||||||||||||||||||||||||||||
| 459 | } | ||||||||||||||||||||||||||||||||||||||||||
| 460 | |||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | ▶ | sub Save { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Save: not called CC=36 SCAR=71.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 462 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 463 | 0 | ▶ | return unless AuthorCheck('GetPage','pageid',$LEVEL); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | for(keys %fields) { | |||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | my (undef,$month,$year) = split("/",formatDate(3)); | |||||||||||||||||||||||||||||||||||||||||
| 474 | 0 | ▶ | $tvars{data}->{year} ||= $year; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"year"} ||= $year
MC/DC0%0/2
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"year"} ||= $year
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"year"}
$year
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Album::Pages::tvars{"data"}{"year"}B= $year
| |||||||||||||||||||||||||||||||||||||||||||
| 475 | 0 | ▶ | $tvars{data}->{month} ||= $month; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"month"} ||= $month
MC/DC0%0/2
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"month"} ||= $month
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"month"}
$month
Truth table0%0/3
A ||= B
A= $Labyrinth::Plugin::Album::Pages::tvars{"data"}{"month"}B= $month
| |||||||||||||||||||||||||||||||||||||||||||
| 476 | |||||||||||||||||||||||||||||||||||||||||||
| 477 | # only create the path when a new page is created | ||||||||||||||||||||||||||||||||||||||||||
| 478 | 0 | ▶ | unless($tvars{data}->{pageid}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 479 | 0 | $tvars{data}->{path} = 'photos/' . formatDate(11); | |||||||||||||||||||||||||||||||||||||||||
| 480 | 0 | my $path = $settings{webdir} . '/' . $tvars{data}->{path}; | |||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | mkpath($path); | |||||||||||||||||||||||||||||||||||||||||
| 482 | } | ||||||||||||||||||||||||||||||||||||||||||
| 483 | |||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | ▶ | $tvars{data}->{parent} ||= 0; # no parent by default | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"parent"} ||= 0
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"parent"} ||= 0
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"parent"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::tvars{"data"}{"parent"}
| |||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | ▶ | $tvars{data}->{area} ||= 2; # photo album | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"area"} ||= 2
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"area"} ||= 2
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"area"}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::tvars{"data"}{"area"}
| |||||||||||||||||||||||||||||||||||||||||||
| 486 | 0 | ▶ | $tvars{data}->{hide} = $tvars{data}->{hide} ? 1 : 0; # visible by default | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 0 | ▶ | my @columns = $tvars{data}->{pageid} ? @savefields : @addfields; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 488 | 0 | ▶ | my @fields = map {(defined $tvars{data}->{$_} ? $tvars{data}->{$_} : undef)} @columns; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 489 | #LogDebug("columns=[@columns], fields=[@fields]"); | ||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | if($tvars{data}->{pageid}) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | { $dbi->DoQuery('UpdatePage',@fields) } | |||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | else {$tvars{data}->{pageid} = $dbi->IDQuery('InsertPage',@fields) } | |||||||||||||||||||||||||||||||||||||||||
| 493 | |||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | $cgiparams{pageid} = $tvars{data}->{pageid}; | |||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $hits->SetUpdates('album',0,$tvars{data}->{pageid}); | |||||||||||||||||||||||||||||||||||||||||
| 496 | 0 | $tvars{thanks_message} = 'Page saved successfully.'; | |||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | ▶ | return unless($tvars{data}->{pageid}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 498 | |||||||||||||||||||||||||||||||||||||||||||
| 499 | # archive unwanted photos | ||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | my @ids = grep { /^\d+$/ } CGIArray('DELETE'); | |||||||||||||||||||||||||||||||||||||||||
| 501 | # LogDebug("Delete IDs: @ids"); | ||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | ▶ | if(@ids) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 503 | 0 | ▶ | if($cgiparams{pageid} == 1) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 504 | # only delete photos in the archive | ||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | my @rows = $dbi->GetQuery('hash','CheckPhotos',{ids => join(',',@ids)},1); | |||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | for(@rows) { | |||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | my @photo = $dbi->GetQuery('hash','CheckPhoto',1,$_->{photoid}); | |||||||||||||||||||||||||||||||||||||||||
| 508 | 0 | ▶ | if(@photo && $photo[0]->{count} == 1) { # only delete if no others match | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
@photo and $photo[0]{"count"} == 1
MC/DC0%0/2
@photo and $photo[0]{"count"} == 1
@photo
$photo[0]{"count"} == 1
Truth table0%0/3
A and B
A= @photoB= $photo[0]{"count"} == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 509 | 0 | DeleteFile( file => "$settings{webdir}/photos/$_->{image}" ); | |||||||||||||||||||||||||||||||||||||||||
| 510 | 0 | DeleteFile( file => "$settings{webdir}/photos/$_->{thumb}" ); | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | $dbi->DoQuery('DeletePhoto',$_->{photoid}); | |||||||||||||||||||||||||||||||||||||||||
| 513 | } | ||||||||||||||||||||||||||||||||||||||||||
| 514 | } else { | ||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | $dbi->DoQuery('MovePhotos',{ids => join(',',@ids)},1) if(@ids); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 516 | } | ||||||||||||||||||||||||||||||||||||||||||
| 517 | } | ||||||||||||||||||||||||||||||||||||||||||
| 518 | |||||||||||||||||||||||||||||||||||||||||||
| 519 | # get fresh list | ||||||||||||||||||||||||||||||||||||||||||
| 520 | 0 | my @rs = $dbi->GetQuery('hash','GetPhotosInOrder',$tvars{data}->{pageid}); | |||||||||||||||||||||||||||||||||||||||||
| 521 | |||||||||||||||||||||||||||||||||||||||||||
| 522 | # store hidden photos | ||||||||||||||||||||||||||||||||||||||||||
| 523 | 0 | @ids = CGIArray('HIDE'); | |||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | my %hidden = map {$_ => 1} @ids; | |||||||||||||||||||||||||||||||||||||||||
| 525 | |||||||||||||||||||||||||||||||||||||||||||
| 526 | # update tags, order and metadata | ||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | my $order = 1; | |||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | foreach my $rec (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 529 | 0 | my $id = $rec->{photoid}; | |||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | ▶ | my $tag = defined $cgiparams{"TAG$id"} ? $cgiparams{"TAG$id"} : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 531 | 0 | ▶ | my $hide = $hidden{$id} ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | ▶ | my $cover = defined $cgiparams{"COVER"} && $cgiparams{"COVER"} == $id ? 1 : 0; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} == $id
MC/DC0%0/2
defined $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} == $id
defined $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"}
$Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} == $id
Truth table0%0/3
A and B
A= defined $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"}B= $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} == $id
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | |||||||||||||||||||||||||||||||||||||||||||
| 534 | 0 | $dbi->DoQuery('UpdatePhoto',$order,$hide,$tag,$cover,$id); | |||||||||||||||||||||||||||||||||||||||||
| 535 | 0 | $order++; | |||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||
| 537 | 0 | ▶ | my $data = defined $cgiparams{"META$id"} ? $cgiparams{"META$id"} : ''; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 538 | 0 | ▶ | MetaSave($id,['Photo'],split(/[ ,]+/,$data)) if($data); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 539 | } | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | # upload new photos | ||||||||||||||||||||||||||||||||||||||||||
| 542 | 0 | my $inx = 0; | |||||||||||||||||||||||||||||||||||||||||
| 543 | 0 | ▶ | while($cgiparams{"file_$inx"}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 544 | SavePhotoFile( | ||||||||||||||||||||||||||||||||||||||||||
| 545 | param => "file_$inx", | ||||||||||||||||||||||||||||||||||||||||||
| 546 | path => $tvars{data}->{path}, | ||||||||||||||||||||||||||||||||||||||||||
| 547 | page => $tvars{data}->{pageid}, | ||||||||||||||||||||||||||||||||||||||||||
| 548 | iwidth => $settings{maxphotowidth} || MaxPhotoWidth, | ||||||||||||||||||||||||||||||||||||||||||
| 549 | iheight => $settings{maxphotoheight} || MaxPhotoHeight, | ||||||||||||||||||||||||||||||||||||||||||
| 550 | twidth => $settings{maxthumbwidth} || MaxThumbWidth, | ||||||||||||||||||||||||||||||||||||||||||
| 551 | 0 | ▶ | theight => $settings{maxthumbheight} || MaxThumbHeight, | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/8
$Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'} || 1024
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'} || 1024
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'} || 200
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'} || 1024
$Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'}
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'} || 1024
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'}
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'}
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'} || 200
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxphotowidth'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'}
| |||||||||||||||||||||||||||||||||||||||||||
| 552 | order => $order++, | ||||||||||||||||||||||||||||||||||||||||||
| 553 | tag => '' | ||||||||||||||||||||||||||||||||||||||||||
| 554 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 555 | 0 | $inx++; | |||||||||||||||||||||||||||||||||||||||||
| 556 | } | ||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||
| 558 | 0 | $tvars{thanks_message} = 'Page saved successfully.'; | |||||||||||||||||||||||||||||||||||||||||
| 559 | } | ||||||||||||||||||||||||||||||||||||||||||
| 560 | |||||||||||||||||||||||||||||||||||||||||||
| 561 | 0 | ▶ | sub Delete { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Delete: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 562 | 0 | ▶ | return unless AccessUser(ADMIN); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 563 | 0 | ▶ | return unless $cgiparams{$INDEXKEY}; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 0 | ▶ | return unless $cgiparams{$INDEXKEY} > 2; # Cannot delete the Archive or Homepage folders | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | my @rows = $dbi->GetQuery('array','GetPhotos',$cgiparams{$INDEXKEY}); | |||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | $dbi->DoQuery('MovePhoto',1,$_->[0]) for(@rows); | |||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | $dbi->DoQuery('DeletePage',$cgiparams{$INDEXKEY}); | |||||||||||||||||||||||||||||||||||||||||
| 569 | |||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | $tvars{thanks_message} = 'Page deleted successfully.'; | |||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | |||||||||||||||||||||||||||||||||||||||||||
| 573 | 0 | ▶ | sub Selection { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
Selection: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 574 | 0 | ▶ | my $pageid = $tvars{data}->{pageid} || 1; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'pageid'} || 1
MC/DC0%0/1
$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'pageid'} || 1
$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'pageid'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::tvars{'data'}{'pageid'}
| |||||||||||||||||||||||||||||||||||||||||||
| 575 | 0 | $tvars{ddpages} = PageSelect($pageid,1); | |||||||||||||||||||||||||||||||||||||||||
| 576 | } | ||||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | ▶ | sub PageSelect { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
PageSelect: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my ($opt,$blank,$name,@ignore) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | my (@list,%ignore); | |||||||||||||||||||||||||||||||||||||||||
| 581 | |||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | ▶ | $name ||= 'pageid'; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$name ||= "pageid"
MC/DC0%0/1
$name ||= "pageid"
$name
Truth table0%0/2
A
A= $name
| |||||||||||||||||||||||||||||||||||||||||||
| 583 | 0 | %ignore = map {$_=>1} grep {$_} @ignore; | |||||||||||||||||||||||||||||||||||||||||
| 584 | |||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my @rs = $dbi->GetQuery('hash','AdminPages'); | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | for my $rec (@rs) { | |||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | next if($ignore{$rec->{pageid}}); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | push @list, {id=>$rec->{pageid},value=>"$rec->{title}"}; | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | |||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | ▶ | unshift @list, {id=>0,value=>'Select Gallery Page'} if(defined $blank && $blank == 1); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $blank and $blank == 1
MC/DC0%0/2
defined $blank and $blank == 1
defined $blank
$blank == 1
Truth table0%0/3
A and B
A= defined $blankB= $blank == 1
| |||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | return DropDownRows($opt,$name,'id','value',@list); | |||||||||||||||||||||||||||||||||||||||||
| 593 | } | ||||||||||||||||||||||||||||||||||||||||||
| 594 | |||||||||||||||||||||||||||||||||||||||||||
| 595 | 3 | 1; | |||||||||||||||||||||||||||||||||||||||||
| 596 | |||||||||||||||||||||||||||||||||||||||||||
| 597 | __END__ | ||||||||||||||||||||||||||||||||||||||||||