Album/Pages.pm

filter: Statementstmt 18.3% 63 / 344 Branchbran 1.0% 2 / 196 Conditioncond 0.0% 0 / 85 MC/DCmcdc 0.0% 0 / 48 Subroutinesub 60.7% 17 / 28 Podpod 100% 11 / 11 totaltotal 13.0% 93 / 712 CC 155 SCAR 67.3
CC
155
Cov
10%
Admin
1482.0
Save
1332.0
Edit
1056.0
CRAP 833.5
↑ Summary Album/Photos.pm »
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
BranchTrueFalseTotal
if $fields{$_}{"type"} 3 21 24
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
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{'all'}) { } 0 0 0
elsif ($Labyrinth::Plugin::Album::Pages::cgiparams{'latest'}) { } 0 0 0
elsif ($Labyrinth::Plugin::Album::Pages::cgiparams{'month'} or $Labyrinth::Plugin::Album::Pages::cgiparams{'year'} or $Labyrinth::Plugin::Album::Pages::cgiparams{'metadata'}) { } 0 0 0
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"}
l!l&&r!l&&!r
000
$Labyrinth::Plugin::Album::Pages::cgiparams{"month"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"year"}
l!l&&r!l&&!r
000
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"}
ABCresult
1XX1
01X1
0011
0000
113 0 ▶ push @where, "p.month=$cgiparams{month}" if($cgiparams{month});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Album::Pages::cgiparams{"month"} 0 0 0
114 0 ▶ push @where, "p.year=$cgiparams{year}" if($cgiparams{year});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Album::Pages::cgiparams{"year"} 0 0 0
115 0 ▶ push @where, "p.title='%$cgiparams{metadata}%'" if($cgiparams{metadata});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Album::Pages::cgiparams{"metadata"} 0 0 0
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
BranchTrueFalseTotal
if @where 0 0 0
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
BranchTrueFalseTotal
$rec->{'now'} > $now ? : 0 0 0
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
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
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
l!l
00
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'}
Aresult
11
00
136 0 ▶ my $dh = $settings{gallerythumbheight} || MaxThumbHeight;
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'gallerythumbheight'} || 200
l!l
00
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'}
Aresult
11
00
137  
138 0 ▶ if($rec->{dimensions}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($rec->{"dimensions"}) 0 0 0
139 0 my ($w,$h) = split('x',$rec->{dimensions});
140 0 ▶ if($w/$dw > $h/$dh) {
Branch: 1 branch
BranchTrueFalseTotal
if ($w / $dw > $h / $dh) { } 0 0 0
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
BranchTrueFalseTotal
if @rs 0 0 0
149 0 ▶ $tvars{month} = $cgiparams{month} || '';
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
l!l
00
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'}
Aresult
11
00
150 0 ▶ $tvars{year} = $cgiparams{year} || '';
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
l!l
00
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'}
Aresult
11
00
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"}
l!l&&r!l&&!r
000
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"}
ABresult
1X1
011
000
159 0 my @rs = $dbi->GetQuery('hash','GetChildPages',$cgiparams{pageid});
160 0 ▶ $tvars{album}{children} = \@rs if(@rs);
Branch: 1 branch
BranchTrueFalseTotal
if @rs 0 0 0
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
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"metadata"}) 0 0 0
170 0 my @data = split(qr/[ ,]+/,$cgiparams{metadata});
171 0 ▶ @rs = MetaSearch( 'keys' => ['PagePhoto','Photo'],
Condition0%0/2
$limit || ''
l!l
00
MC/DC0%0/1
$limit || ''
$limit
Truth table0%0/2
A
A= $limit
Aresult
11
00
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
BranchTrueFalseTotal
$rec->{'now'} > $now ? : 0 0 0
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
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
181 0 elsif($fields{$_}->{html} == 2) { $rec->{$_} = SafeHTML($rec->{$_}); }
182 }
183 }
184 }
185  
186 0 ▶ $tvars{records} = \@rs if(@rs);
Branch: 1 branch
BranchTrueFalseTotal
if @rs 0 0 0
187 0 ▶ $tvars{month} = $cgiparams{month} || '';
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'month'} || ''
l!l
00
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'}
Aresult
11
00
188 0 ▶ $tvars{year} = $cgiparams{year} || '';
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
l!l
00
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'}
Aresult
11
00
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
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
243  
244 0 my (%current,$where,@rs);
245 0 ▶ if($cgiparams{doaction} || $cgiparams{order}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"order"}) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"} or $Labyrinth::Plugin::Album::Pages::cgiparams{"order"}
l!l&&r!l&&!r
000
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"}
ABresult
1X1
011
000
246 0 $where = '';
247 0 ▶ if($cgiparams{was}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"was"}) 0 0 0
248 0 my @was;
249 0 my ($this,$that) = split("/",$cgiparams{was});
250 0 ▶ push @was, "month=$cgiparams{month}" if($this);
Branch: 1 branch
BranchTrueFalseTotal
if $this 0 0 0
251 0 ▶ push @was, "year=$cgiparams{year}" if($that);
Branch: 1 branch
BranchTrueFalseTotal
if $that 0 0 0
252 0 ▶ $where = 'WHERE ' . join(' AND ',@was) if(@was);
Branch: 1 branch
BranchTrueFalseTotal
if @was 0 0 0
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
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"}) 0 0 0
260 0 ▶ if($cgiparams{doaction} eq 'Update') {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"} eq "Update") 0 0 0
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
BranchTrueFalseTotal
if ($current{$_}{"hide"}) 0 0 0
270 }
271 0 for(keys %current) {
272 0 ▶ if($current{$_}->{hide}) { push @show, $_; }
Branch: 1 branch
BranchTrueFalseTotal
if ($current{$_}{"hide"}) 0 0 0
273 }
274  
275 0 ▶ $dbi->DoQuery('HidePages',{list=>join(",",keys %hide)}) if(keys %hide);
Branch: 1 branch
BranchTrueFalseTotal
if keys %hide 0 0 0
276 0 ▶ $dbi->DoQuery('ShowPages',{list=>join(",",@show)}) if(@show);
Branch: 1 branch
BranchTrueFalseTotal
if @show 0 0 0
277 0 ▶ $hits->SetUpdates('album',0,@show) if(@show);
Branch: 1 branch
BranchTrueFalseTotal
if @show 0 0 0
278 }
279 }
280  
281 # reorder a specific page
282 0 ▶ if($cgiparams{'order'} && $cgiparams{'pageid'}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"order"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}) 0 0 0
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::cgiparams{"order"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"pageid"}
!ll&&!rl&&r
000
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"}
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if (@rs > 1) 0 0 0
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
BranchTrueFalseTotal
if ($order =~ /up/i) { } 0 0 0
300 # LogDebug("max=$inx, this=$pages{$pageid}");
301 0 ▶ if($pages{$pageid} < $max) {
Branch: 1 branch
BranchTrueFalseTotal
if ($pages{$pageid} < $max) 0 0 0
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
BranchTrueFalseTotal
if ($pages{$pageid} > 1) 0 0 0
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
BranchTrueFalseTotal
if ($changed) 0 0 0
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
BranchTrueFalseTotal
if $Labyrinth::Plugin::Album::Pages::cgiparams{"month"} 0 0 0
326 0 ▶ push @where, "year=$cgiparams{year}" if($cgiparams{year});
Branch: 1 branch
BranchTrueFalseTotal
if $Labyrinth::Plugin::Album::Pages::cgiparams{"year"} 0 0 0
327 0 ▶ $where = 'WHERE ' . join(' AND ',@where) if(@where);
Branch: 1 branch
BranchTrueFalseTotal
if @where 0 0 0
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
BranchTrueFalseTotal
unless $rec->{"year"} 0 0 0
332 0 $rec->{month} = isMonth($rec->{month});
333 0 for(keys %fields) {
334 0 ▶ if($fields{$_}->{html} == 1) { $rec->{$_} = CleanHTML($rec->{$_}); }
Branch: 2 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
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'} || ''
l!l
00
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'}
Aresult
11
00
340 0 ▶ $tvars{year} = $cgiparams{year} || '';
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::cgiparams{'year'} || ''
l!l
00
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'}
Aresult
11
00
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
BranchTrueFalseTotal
if @rs 0 0 0
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
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
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
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
360  
361 0 ▶ if($cgiparams{doaction}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"doaction"}) 0 0 0
362 0 my @ids = CGIArray('LISTED');
363  
364 0 ▶ if($cgiparams{doaction} eq 'Delete') {
Branch: 2 branches
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{'doaction'} eq 'Delete') { } 0 0 0
elsif ($Labyrinth::Plugin::Album::Pages::cgiparams{'doaction'} eq 'Move') { } 0 0 0
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
l!l
00
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"}
Aresult
11
00
375 0 ▶ $dbi->DoQuery('MovePhotos',{ids=>join(',',@ids)},$cgiparams{'pageid'}) if(@ids);
Branch: 1 branch
BranchTrueFalseTotal
if @ids 0 0 0
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
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
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
BranchTrueFalseTotal
if ($order and $photoid) 0 0 0
Condition0%0/3
$order and $photoid
!ll&&!rl&&r
000
MC/DC0%0/2
$order and $photoid
$order $photoid
Truth table0%0/3
A and B
A= $orderB= $photoid
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if ($_->{"photoid"} == $photoid) 0 0 0
396 0 $old = $cnt;
397 0 last;
398 }
399 }
400  
401 0 my $max = @rs;
402 0 ▶ if($old >= 0) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old >= 0) 0 0 0
403 0 my $new = $old;
404 0 ▶ if($order eq 'up' && $old > 0) { $new--; }
Branch: 2 branches
BranchTrueFalseTotal
if ($order eq 'up' and $old > 0) { } 0 0 0
elsif ($order eq 'down' and $old < $max) { } 0 0 0
Condition0%0/3
$order eq "up" and $old > 0
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
405 0 ▶ elsif($order eq 'down' && $old < $max) { $new++; }
Condition0%0/3
$order eq "down" and $old < $max
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
406  
407 0 ▶ if($old != $new) {
Branch: 1 branch
BranchTrueFalseTotal
if ($old != $new) 0 0 0
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
BranchTrueFalseTotal
if (@rs) 0 0 0
416 0 for(keys %fields) {
417 0 ▶ if($fields{$_}->{html} == 1) { $rs[0]->{$_} = CleanHTML($rs[0]->{$_}) }
Branch: 3 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
elsif ($fields{$_}{'html'} == 3) { } 0 0 0
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/&#39;/\'/g if $rs[0]->{title};
423 # $rs[0]->{summary} =~ s/&#39;/\'/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/&#39;/\'/g if $rec->{tagline};
Branch: 1 branch
BranchTrueFalseTotal
if $rec->{"tagline"} 0 0 0
429 0 $rec->{metadata} = MetaGet($rec->{photoid},'Photo');
430 }
431  
432 0 ▶ $tvars{photos} = \@rs if(@rs);
Branch: 1 branch
BranchTrueFalseTotal
if @rs 0 0 0
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
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::tvars{'data'}{'path'}) { } 0 0 0
441 0 ▶ $settings{webdir} ||= '';
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{"webdir"} ||= ""
l!l
00
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"}
Aresult
11
00
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
BranchTrueFalseTotal
-e "$Labyrinth::Plugin::Album::Pages::settings{'webdir'}/$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'path'}" ? : 0 0 0
444 0 ▶ $tvars{data}->{directory} = -d "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-d "$Labyrinth::Plugin::Album::Pages::settings{'webdir'}/$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'path'}" ? : 0 0 0
445 0 ▶ $tvars{data}->{readable} = -r "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-r "$Labyrinth::Plugin::Album::Pages::settings{'webdir'}/$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'path'}" ? : 0 0 0
446 0 ▶ $tvars{data}->{writeable} = -w "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-w "$Labyrinth::Plugin::Album::Pages::settings{'webdir'}/$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'path'}" ? : 0 0 0
447 0 ▶ $tvars{data}->{executable} = -x "$settings{webdir}/$tvars{data}->{path}" ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
-x "$Labyrinth::Plugin::Album::Pages::settings{'webdir'}/$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'path'}" ? : 0 0 0
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
l!l
00
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'}
Aresult
11
00
454 0 ▶ $tvars{dimensions}->{photoheight} = $settings{maxphotoheight} || MaxPhotoHeight;
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'} || 1024
l!l
00
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'}
Aresult
11
00
455 0 ▶ $tvars{dimensions}->{thumbwidth} = $settings{maxthumbwidth} || MaxThumbWidth;
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'} || 200
l!l
00
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'}
Aresult
11
00
456 0 ▶ $tvars{dimensions}->{thumbheight} = $settings{maxthumbheight} || MaxThumbHeight;
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'} || 200
l!l
00
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'}
Aresult
11
00
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
BranchTrueFalseTotal
unless AccessUser($LEVEL) 0 0 0
463 0 ▶ return unless AuthorCheck('GetPage','pageid',$LEVEL);
Branch: 1 branch
BranchTrueFalseTotal
unless AuthorCheck("GetPage", "pageid", $LEVEL) 0 0 0
464  
465 0 for(keys %fields) {
466 0 ▶ if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) }
Branch: 3 branches
BranchTrueFalseTotal
if ($fields{$_}{'html'} == 1) { } 0 0 0
elsif ($fields{$_}{'html'} == 2) { } 0 0 0
elsif ($fields{$_}{'html'} == 3) { } 0 0 0
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
BranchTrueFalseTotal
if FieldCheck(\@allfields, \@mandatory) 0 0 0
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
l!l&&r!l&&!r
000
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
ABresult
1X1
011
000
475 0 ▶ $tvars{data}->{month} ||= $month;
Condition0%0/3
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"month"} ||= $month
l!l&&r!l&&!r
000
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
ABresult
1X1
011
000
476  
477 # only create the path when a new page is created
478 0 ▶ unless($tvars{data}->{pageid}) {
Branch: 1 branch
BranchTrueFalseTotal
unless ($Labyrinth::Plugin::Album::Pages::tvars{"data"}{"pageid"}) 0 0 0
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
l!l
00
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"}
Aresult
11
00
485 0 ▶ $tvars{data}->{area} ||= 2; # photo album
Condition0%0/2
$Labyrinth::Plugin::Album::Pages::tvars{"data"}{"area"} ||= 2
l!l
00
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"}
Aresult
11
00
486 0 ▶ $tvars{data}->{hide} = $tvars{data}->{hide} ? 1 : 0; # visible by default
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'hide'} ? : 0 0 0
487 0 ▶ my @columns = $tvars{data}->{pageid} ? @savefields : @addfields;
Branch: 1 branch
BranchTrueFalseTotal
$Labyrinth::Plugin::Album::Pages::tvars{'data'}{'pageid'} ? : 0 0 0
488 0 ▶ my @fields = map {(defined $tvars{data}->{$_} ? $tvars{data}->{$_} : undef)} @columns;
Branch: 1 branch
BranchTrueFalseTotal
defined $Labyrinth::Plugin::Album::Pages::tvars{'data'}{$_} ? : 0 0 0
489 #LogDebug("columns=[@columns], fields=[@fields]");
490 0 ▶ if($tvars{data}->{pageid})
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::tvars{'data'}{'pageid'}) { } 0 0 0
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
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Album::Pages::tvars{"data"}{"pageid"} 0 0 0
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
BranchTrueFalseTotal
if (@ids) 0 0 0
503 0 ▶ if($cgiparams{pageid} == 1) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{'pageid'} == 1) { } 0 0 0
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
BranchTrueFalseTotal
if (@photo and $photo[0]{"count"} == 1) 0 0 0
Condition0%0/3
@photo and $photo[0]{"count"} == 1
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
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
BranchTrueFalseTotal
if @ids 0 0 0
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
BranchTrueFalseTotal
defined $Labyrinth::Plugin::Album::Pages::cgiparams{"TAG$id"} ? : 0 0 0
531 0 ▶ my $hide = $hidden{$id} ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
$hidden{$id} ? : 0 0 0
532 0 ▶ my $cover = defined $cgiparams{"COVER"} && $cgiparams{"COVER"} == $id ? 1 : 0;
Branch: 1 branch
BranchTrueFalseTotal
defined $Labyrinth::Plugin::Album::Pages::cgiparams{'COVER'} && $Labyrinth::Plugin::Album::Pages::cgiparams{'COVER'} == $id ? : 0 0 0
Condition0%0/3
defined $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} and $Labyrinth::Plugin::Album::Pages::cgiparams{"COVER"} == $id
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
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
BranchTrueFalseTotal
defined $Labyrinth::Plugin::Album::Pages::cgiparams{"META$id"} ? : 0 0 0
538 0 ▶ MetaSave($id,['Photo'],split(/[ ,]+/,$data)) if($data);
Branch: 1 branch
BranchTrueFalseTotal
if $data 0 0 0
539 }
540  
541 # upload new photos
542 0 my $inx = 0;
543 0 ▶ while($cgiparams{"file_$inx"}) {
Branch: 1 branch
BranchTrueFalseTotal
if ($Labyrinth::Plugin::Album::Pages::cgiparams{"file_$inx"}) 0 0 0
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
l!l
00
$Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'} || 1024
l!l
00
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'} || 200
l!l
00
$Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'} || 200
l!l
00
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'}
Aresult
11
00
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxphotoheight'}
Aresult
11
00
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxthumbwidth'}
Aresult
11
00
Truth table0%0/2
A
A= $Labyrinth::Plugin::Album::Pages::settings{'maxthumbheight'}
Aresult
11
00
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
BranchTrueFalseTotal
unless AccessUser(4) 0 0 0
563 0 ▶ return unless $cgiparams{$INDEXKEY};
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Album::Pages::cgiparams{$INDEXKEY} 0 0 0
564 0 ▶ return unless $cgiparams{$INDEXKEY} > 2; # Cannot delete the Archive or Homepage folders
Branch: 1 branch
BranchTrueFalseTotal
unless $Labyrinth::Plugin::Album::Pages::cgiparams{$INDEXKEY} > 2 0 0 0
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
l!l
00
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'}
Aresult
11
00
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"
l!l
00
MC/DC0%0/1
$name ||= "pageid"
$name
Truth table0%0/2
A
A= $name
Aresult
11
00
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
BranchTrueFalseTotal
if $ignore{$rec->{"pageid"}} 0 0 0
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
BranchTrueFalseTotal
if defined $blank and $blank == 1 0 0 0
Condition0%0/3
defined $blank and $blank == 1
!ll&&!rl&&r
000
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
ABresult
0X0
100
111
592 0 return DropDownRows($opt,$name,'id','value',@list);
593 }
594  
595 3 1;
596  
597 __END__
↑ Summary Album/Photos.pm »