| 1 | package Labyrinth::Plugin::Images; | ||||||||||||||||||
| 2 | |||||||||||||||||||
| 3 | 4 | ▶ | use warnings; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 4 | 4 | ▶ | use strict; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 5 | |||||||||||||||||||
| 6 | 4 | our $VERSION = '5.19'; | |||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | =head1 NAME | ||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | Labyrinth::Plugin::Images - Plugin Images handler for Labyrinth | ||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | =head1 DESCRIPTION | ||||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | Contains all the image handling functionality for the Labyrinth | ||||||||||||||||||
| 15 | framework. | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | =cut | ||||||||||||||||||
| 18 | |||||||||||||||||||
| 19 | # ------------------------------------- | ||||||||||||||||||
| 20 | # Library Modules | ||||||||||||||||||
| 21 | |||||||||||||||||||
| 22 | 4 | ▶ | use base qw(Labyrinth::Plugin::Base); | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 4 | ▶ | use Image::Size; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 25 | 4 | ▶ | use File::Copy; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 26 | 4 | ▶ | use File::Basename; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | 4 | ▶ | use Labyrinth::Audit; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 29 | 4 | ▶ | use Labyrinth::Globals; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 30 | 4 | ▶ | use Labyrinth::DBUtils; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 31 | 4 | ▶ | use Labyrinth::DIUtils; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 32 | 4 | ▶ | use Labyrinth::Media; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 33 | 4 | ▶ | use Labyrinth::Metadata; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 34 | 4 | ▶ | use Labyrinth::MLUtils; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 35 | 4 | ▶ | use Labyrinth::Support; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 36 | 4 | ▶ | use Labyrinth::Variables; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 37 | |||||||||||||||||||
| 38 | # ------------------------------------- | ||||||||||||||||||
| 39 | # Constants | ||||||||||||||||||
| 40 | |||||||||||||||||||
| 41 | 4 | ▶ | use constant MaxDefaultWidth => 120; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 42 | 4 | ▶ | use constant MaxDefaultHeight => 120; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 43 | 4 | ▶ | use constant MaxDefaultThumb => 120; | ||||||||||||||||
|
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 | 4 | my %fields = ( | |||||||||||||||||
| 52 | imageid => { type => 1, html => 0 }, | ||||||||||||||||||
| 53 | image => { type => 0, html => 0 }, | ||||||||||||||||||
| 54 | tag => { type => 0, html => 1 }, | ||||||||||||||||||
| 55 | link => { type => 0, html => 1 }, | ||||||||||||||||||
| 56 | type => { type => 1, html => 0 }, | ||||||||||||||||||
| 57 | href => { type => 0, html => 0 }, | ||||||||||||||||||
| 58 | metadata => { type => 0, html => 1 }, | ||||||||||||||||||
| 59 | ); | ||||||||||||||||||
| 60 | |||||||||||||||||||
| 61 | 4 | my (@mandatory,@allfields); | |||||||||||||||||
| 62 | 4 | for(keys %fields) { | |||||||||||||||||
| 63 | 28 | ▶ | push @mandatory, $_ if($fields{$_}->{type}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 64 | 28 | push @allfields, $_; | |||||||||||||||||
| 65 | } | ||||||||||||||||||
| 66 | |||||||||||||||||||
| 67 | 4 | my $LEVEL = ADMIN; | |||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | # ------------------------------------- | ||||||||||||||||||
| 70 | # The Subs | ||||||||||||||||||
| 71 | |||||||||||||||||||
| 72 | =head1 PUBLIC INTERFACE METHODS | ||||||||||||||||||
| 73 | |||||||||||||||||||
| 74 | The following are convience methods to provide the appropriate functionality | ||||||||||||||||||
| 75 | to list the require number of random images for the page. | ||||||||||||||||||
| 76 | |||||||||||||||||||
| 77 | These are to be deprecated in the future, in favour of using configuration | ||||||||||||||||||
| 78 | settings and/or parameter values. | ||||||||||||||||||
| 79 | |||||||||||||||||||
| 80 | =over 4 | ||||||||||||||||||
| 81 | |||||||||||||||||||
| 82 | =item Random() | ||||||||||||||||||
| 83 | |||||||||||||||||||
| 84 | Stores a random image in template variable 'irandX', where X is 1. | ||||||||||||||||||
| 85 | |||||||||||||||||||
| 86 | =item Random4() | ||||||||||||||||||
| 87 | |||||||||||||||||||
| 88 | Stores 4 random images in template variable 'irandX', where X is 1 to 4. | ||||||||||||||||||
| 89 | |||||||||||||||||||
| 90 | =item Random6() | ||||||||||||||||||
| 91 | |||||||||||||||||||
| 92 | Stores 6 random images in template variable 'irandX', where X is 1 to 6. | ||||||||||||||||||
| 93 | |||||||||||||||||||
| 94 | =item Random8() | ||||||||||||||||||
| 95 | |||||||||||||||||||
| 96 | Stores 8 random images in template variable 'irandX', where X is 1 to 8. | ||||||||||||||||||
| 97 | |||||||||||||||||||
| 98 | =back | ||||||||||||||||||
| 99 | |||||||||||||||||||
| 100 | =cut | ||||||||||||||||||
| 101 | |||||||||||||||||||
| 102 | 0 | ▶ | sub Random { RandomN(1); } | ||||||||||||||||
|
Subroutine
Random: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 103 | 0 | ▶ | sub Random4 { RandomN(4); } | ||||||||||||||||
|
Subroutine
Random4: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 104 | 0 | ▶ | sub Random6 { RandomN(6); } | ||||||||||||||||
|
Subroutine
Random6: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 105 | 0 | ▶ | sub Random8 { RandomN(8); } | ||||||||||||||||
|
Subroutine
Random8: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||
| 106 | |||||||||||||||||||
| 107 | =head1 LOCAL INTERFACE METHODS | ||||||||||||||||||
| 108 | |||||||||||||||||||
| 109 | =over 4 | ||||||||||||||||||
| 110 | |||||||||||||||||||
| 111 | =item RandomN() | ||||||||||||||||||
| 112 | |||||||||||||||||||
| 113 | Provide 'n' random images, prefixed in a template variable with 'irand'. | ||||||||||||||||||
| 114 | |||||||||||||||||||
| 115 | =back | ||||||||||||||||||
| 116 | |||||||||||||||||||
| 117 | =cut | ||||||||||||||||||
| 118 | |||||||||||||||||||
| 119 | 0 | ▶ | sub RandomN { | ||||||||||||||||
|
Subroutine
RandomN: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||
| 120 | 0 | my $count = shift; | |||||||||||||||||
| 121 | 0 | my @rows = $dbi->GetQuery('hash','GetImagesByType',2); | |||||||||||||||||
| 122 | 0 | my $max = @rows; | |||||||||||||||||
| 123 | |||||||||||||||||||
| 124 | 0 | my %blank = (link=>$settings{blank},tag=>''); | |||||||||||||||||
| 125 | |||||||||||||||||||
| 126 | 0 | ▶ | if($max <= $count) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 127 | 0 | foreach my $inx (1..$max) { $tvars{"irand$inx"} = $rows[($inx-1)]; } | |||||||||||||||||
| 128 | 0 | return; | |||||||||||||||||
| 129 | } | ||||||||||||||||||
| 130 | |||||||||||||||||||
| 131 | 0 | my (%done,@random); | |||||||||||||||||
| 132 | 0 | srand; | |||||||||||||||||
| 133 | 0 | while(1) { | |||||||||||||||||
| 134 | 0 | my $index = int((rand) * $max); | |||||||||||||||||
| 135 | 0 | ▶ | next if($done{$index}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 136 | 0 | push @random, $rows[$index]; | |||||||||||||||||
| 137 | 0 | $done{$index} = 1; | |||||||||||||||||
| 138 | 0 | ▶ | last if(@random >= $count); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 139 | } | ||||||||||||||||||
| 140 | |||||||||||||||||||
| 141 | 0 | foreach my $inx (1..$count) { $tvars{"irand$inx"} = $random[($inx-1)]; } | |||||||||||||||||
| 142 | } | ||||||||||||||||||
| 143 | |||||||||||||||||||
| 144 | =head1 ADMIN INTERFACE METHODS | ||||||||||||||||||
| 145 | |||||||||||||||||||
| 146 | Note that in all cases the images referred to do not include photos uploaded | ||||||||||||||||||
| 147 | via the Album plugin, for photo albums. | ||||||||||||||||||
| 148 | |||||||||||||||||||
| 149 | =over 4 | ||||||||||||||||||
| 150 | |||||||||||||||||||
| 151 | =item List | ||||||||||||||||||
| 152 | |||||||||||||||||||
| 153 | List all uploaded images. | ||||||||||||||||||
| 154 | |||||||||||||||||||
| 155 | =item Add | ||||||||||||||||||
| 156 | |||||||||||||||||||
| 157 | Create a template variable hash for a new image. | ||||||||||||||||||
| 158 | |||||||||||||||||||
| 159 | =item Edit | ||||||||||||||||||
| 160 | |||||||||||||||||||
| 161 | Edit the attributes of a given image. | ||||||||||||||||||
| 162 | |||||||||||||||||||
| 163 | =item EditAmendments | ||||||||||||||||||
| 164 | |||||||||||||||||||
| 165 | Additional drop downs and fields for editing. | ||||||||||||||||||
| 166 | |||||||||||||||||||
| 167 | =item Save | ||||||||||||||||||
| 168 | |||||||||||||||||||
| 169 | Save a given image. | ||||||||||||||||||
| 170 | |||||||||||||||||||
| 171 | =item Delete | ||||||||||||||||||
| 172 | |||||||||||||||||||
| 173 | Delete a given image. | ||||||||||||||||||
| 174 | |||||||||||||||||||
| 175 | =item Gallery | ||||||||||||||||||
| 176 | |||||||||||||||||||
| 177 | Provide a set of images as a gallery for selection. | ||||||||||||||||||
| 178 | |||||||||||||||||||
| 179 | =back | ||||||||||||||||||
| 180 | |||||||||||||||||||
| 181 | =cut | ||||||||||||||||||
| 182 | |||||||||||||||||||
| 183 | 0 | ▶ | sub List { | ||||||||||||||||
|
Subroutine
List: not called CC=9 SCAR=45.0
Pod
documented
| |||||||||||||||||||
| 184 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 185 | |||||||||||||||||||
| 186 | 0 | my @delete = CGIArray('DELETE'); | |||||||||||||||||
| 187 | 0 | ▶ | if(@delete) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 188 | 0 | $cgiparams{'imageid'} = $_; | |||||||||||||||||
| 189 | 0 | Delete(); | |||||||||||||||||
| 190 | } | ||||||||||||||||||
| 191 | |||||||||||||||||||
| 192 | 0 | ▶ | my $key = $cgiparams{'searchmeta'} ? 'MetaImages' : 'AllImages'; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 193 | 0 | $cgiparams{'searchmeta'} =~ s/[,\s]+/,/g; | |||||||||||||||||
| 194 | |||||||||||||||||||
| 195 | 0 | my @where = (); | |||||||||||||||||
| 196 | 0 | ▶ | push @where, "i.type=$cgiparams{'stockid'}" if($cgiparams{'stockid'}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 197 | 0 | ▶ | push @where, "m.tag IN ($cgiparams{'searchmeta'})" if($cgiparams{'searchmeta'}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 198 | 0 | ▶ | my $where = @where ? 'WHERE '.join(' AND ',@where) : ''; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 199 | |||||||||||||||||||
| 200 | 0 | my @rows = $dbi->GetQuery('hash',$key,{where=>$where}); | |||||||||||||||||
| 201 | 0 | foreach (@rows) { $_->{typename} = StockName($_->{type}); } | |||||||||||||||||
| 202 | 0 | ▶ | $tvars{data} = \@rows if(@rows); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 203 | |||||||||||||||||||
| 204 | 0 | $tvars{ddstock} = StockSelect(); | |||||||||||||||||
| 205 | } | ||||||||||||||||||
| 206 | |||||||||||||||||||
| 207 | 0 | ▶ | sub Add { | ||||||||||||||||
|
Subroutine
Add: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||
| 208 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 209 | |||||||||||||||||||
| 210 | my %data = ( | ||||||||||||||||||
| 211 | imageid => 0, | ||||||||||||||||||
| 212 | tag => '', | ||||||||||||||||||
| 213 | metadata => '', | ||||||||||||||||||
| 214 | link => $settings{blank}, | ||||||||||||||||||
| 215 | 0 | ddstock => StockSelect(), | |||||||||||||||||
| 216 | ); | ||||||||||||||||||
| 217 | |||||||||||||||||||
| 218 | 0 | $tvars{data} = \%data; | |||||||||||||||||
| 219 | } | ||||||||||||||||||
| 220 | |||||||||||||||||||
| 221 | 0 | ▶ | sub Edit { | ||||||||||||||||
|
Subroutine
Edit: not called CC=4 SCAR=30.0
Pod
documented
| |||||||||||||||||||
| 222 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 223 | 0 | ▶ | return unless $cgiparams{'imageid'}; | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 224 | |||||||||||||||||||
| 225 | 0 | my @rows = $dbi->GetQuery('hash','GetImageByID',$cgiparams{'imageid'}); | |||||||||||||||||
| 226 | 0 | ▶ | return unless(@rows); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 227 | |||||||||||||||||||
| 228 | 0 | $tvars{data} = $rows[0]; | |||||||||||||||||
| 229 | 0 | EditAmendments(); | |||||||||||||||||
| 230 | } | ||||||||||||||||||
| 231 | |||||||||||||||||||
| 232 | 0 | ▶ | sub EditAmendments { | ||||||||||||||||
|
Subroutine
EditAmendments: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||
| 233 | 0 | ▶ | $tvars{data}->{metadata} = MetaGet($cgiparams{'imageid'},['Image']) if($cgiparams{'imageid'}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 234 | 0 | $tvars{data}->{typename} = StockName($tvars{data}->{type}); | |||||||||||||||||
| 235 | 0 | $tvars{data}->{ddstock} = StockSelect($tvars{data}->{type}); | |||||||||||||||||
| 236 | |||||||||||||||||||
| 237 | 0 | for(keys %fields) { | |||||||||||||||||
| 238 | 0 | ▶ | if($fields{$_}->{html} == 1) { $tvars{data}->{$_} = CleanHTML($tvars{data}->{$_}) } | ||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||
| 239 | 0 | elsif($fields{$_}->{html} == 2) { $tvars{data}->{$_} = SafeHTML($tvars{data}->{$_}) } | |||||||||||||||||
| 240 | } | ||||||||||||||||||
| 241 | |||||||||||||||||||
| 242 | 0 | ▶ | return unless($tvars{data}->{link}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 243 | |||||||||||||||||||
| 244 | # Get the size of image | ||||||||||||||||||
| 245 | ($tvars{data}->{x_resize},$tvars{data}->{y_resize}) | ||||||||||||||||||
| 246 | 0 | = ResizeDimensions($tvars{data}->{dimensions},"$settings{webdir}/$tvars{data}->{link}",$tvars{maxpicwidth},$tvars{maxpicheight}); | |||||||||||||||||
| 247 | } | ||||||||||||||||||
| 248 | |||||||||||||||||||
| 249 | 0 | ▶ | sub Save { | ||||||||||||||||
|
Subroutine
Save: not called CC=11 SCAR=48.8
Pod
documented
| |||||||||||||||||||
| 250 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 251 | 0 | ▶ | return unless AuthorCheck('GetImageByID','imageid',$LEVEL); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 252 | 0 | EditAmendments(); | |||||||||||||||||
| 253 | |||||||||||||||||||
| 254 | 0 | for(keys %fields) { | |||||||||||||||||
| 255 | 0 | ▶ | if($fields{$_}->{html} == 1) { $cgiparams{$_} = CleanHTML($cgiparams{$_}) } | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 256 | 0 | elsif($fields{$_}->{html} == 2) { $cgiparams{$_} = CleanTags($cgiparams{$_}) } | |||||||||||||||||
| 257 | 0 | elsif($fields{$_}->{html} == 3) { $cgiparams{$_} = CleanLink($cgiparams{$_}) } | |||||||||||||||||
| 258 | } | ||||||||||||||||||
| 259 | |||||||||||||||||||
| 260 | 0 | my $link = $tvars{data}->{link}; | |||||||||||||||||
| 261 | 0 | ▶ | return if FieldCheck(\@allfields,\@mandatory); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 262 | |||||||||||||||||||
| 263 | 0 | ▶ | if($cgiparams{image}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 264 | 0 | my ($name,$filename) = CGIFile('image',$tvars{data}->{type}); | |||||||||||||||||
| 265 | 0 | ▶ | unless($name) { # blank if anything goes wrong | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 266 | 0 | $tvars{errcode} = 'ERROR'; | |||||||||||||||||
| 267 | 0 | return; | |||||||||||||||||
| 268 | } | ||||||||||||||||||
| 269 | |||||||||||||||||||
| 270 | 0 | my $i = Labyrinth::DIUtils->new("$settings{webdir}/$filename"); | |||||||||||||||||
| 271 | 0 | $i->reduce(MaxDefaultWidth,MaxDefaultHeight); | |||||||||||||||||
| 272 | |||||||||||||||||||
| 273 | 0 | $tvars{data}->{link} = $filename; | |||||||||||||||||
| 274 | } else { | ||||||||||||||||||
| 275 | 0 | $tvars{data}->{link} = $link; | |||||||||||||||||
| 276 | } | ||||||||||||||||||
| 277 | |||||||||||||||||||
| 278 | $cgiparams{imageid} = SaveImage( $cgiparams{imageid}, | ||||||||||||||||||
| 279 | $tvars{data}->{tag}, | ||||||||||||||||||
| 280 | $tvars{data}->{link}, | ||||||||||||||||||
| 281 | $tvars{data}->{type}, | ||||||||||||||||||
| 282 | 0 | $tvars{data}->{href}); | |||||||||||||||||
| 283 | |||||||||||||||||||
| 284 | 0 | ▶ | my @metadata = $tvars{data}->{metadata} ? split(qr/[, ]+/,$tvars{data}->{metadata}) : (); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 285 | 0 | MetaSave($cgiparams{imageid},['Image'],@metadata); | |||||||||||||||||
| 286 | } | ||||||||||||||||||
| 287 | |||||||||||||||||||
| 288 | 0 | ▶ | sub Delete { | ||||||||||||||||
|
Subroutine
Delete: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||
| 289 | 0 | ▶ | return unless AccessUser($LEVEL); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 290 | 0 | ▶ | return unless($cgiparams{'imageid'}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 291 | |||||||||||||||||||
| 292 | # check whether image still referenced | ||||||||||||||||||
| 293 | 0 | ▶ | if(ImageCheck($cgiparams{'imageid'})) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 294 | 0 | $tvars{errcode} = 'MESSAGE'; | |||||||||||||||||
| 295 | 0 | $tvars{errmess} = 'Sorry cannot delete that image, it is used within other areas of the site.'; | |||||||||||||||||
| 296 | 0 | return; | |||||||||||||||||
| 297 | } | ||||||||||||||||||
| 298 | |||||||||||||||||||
| 299 | 0 | my @rows = $dbi->GetQuery('hash','GetImageByID',$cgiparams{'imageid'}); | |||||||||||||||||
| 300 | |||||||||||||||||||
| 301 | # do the delete | ||||||||||||||||||
| 302 | 0 | ▶ | if($dbi->DoQuery('DeleteImage',$cgiparams{'imageid'})) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 303 | 0 | unlink "$settings{webdir}/" . $rows[0]->{link}; | |||||||||||||||||
| 304 | } | ||||||||||||||||||
| 305 | } | ||||||||||||||||||
| 306 | |||||||||||||||||||
| 307 | my @blanks = ( | ||||||||||||||||||
| 308 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 309 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 310 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 311 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 312 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 313 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 314 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 315 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | ||||||||||||||||||
| 316 | 4 | { imageid=>1,link=>$settings{blank},tag=>'',height=>100,width=>100 }, | |||||||||||||||||
| 317 | ); | ||||||||||||||||||
| 318 | |||||||||||||||||||
| 319 | 0 | ▶ | sub Gallery { | ||||||||||||||||
|
Subroutine
Gallery: not called CC=10 SCAR=47.0
Pod
documented
| |||||||||||||||||||
| 320 | 0 | ▶ | return unless AccessUser(EDITOR); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 321 | 0 | ▶ | my $start = $cgiparams{'start'} || 2; | ||||||||||||||||
|
Condition0%0/2
$Labyrinth::Plugin::Images::cgiparams{'start'} || 2
MC/DC0%0/1
$Labyrinth::Plugin::Images::cgiparams{'start'} || 2
$Labyrinth::Plugin::Images::cgiparams{'start'}
Truth table0%0/2
A
A= $Labyrinth::Plugin::Images::cgiparams{'start'}
| |||||||||||||||||||
| 322 | 0 | my $key = ''; | |||||||||||||||||
| 323 | |||||||||||||||||||
| 324 | 0 | ▶ | if($cgiparams{'searchmeta'}) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 325 | 0 | $key = 'Meta'; | |||||||||||||||||
| 326 | 0 | $cgiparams{'searchmeta'} =~ s/[,\s]+/,/g; | |||||||||||||||||
| 327 | 0 | $cgiparams{'searchmeta'} = join(",", map {"'$_'"} split(",",$cgiparams{'searchmeta'})); | |||||||||||||||||
| 328 | } | ||||||||||||||||||
| 329 | |||||||||||||||||||
| 330 | 0 | my $where; | |||||||||||||||||
| 331 | 0 | ▶ | $where .= " AND i.type IN ($cgiparams{'imagetype'})" if($cgiparams{'imagetype'}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 332 | 0 | ▶ | $where .= " AND m.tag IN ($cgiparams{'searchmeta'})" if($cgiparams{'searchmeta'}); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 333 | |||||||||||||||||||
| 334 | 0 | my @rows = $dbi->GetQuery('hash',$key.'Gallery',{where=>$where},$start); | |||||||||||||||||
| 335 | 0 | for(@rows) { | |||||||||||||||||
| 336 | ($_->{width},$_->{heigth}) | ||||||||||||||||||
| 337 | 0 | = ResizeDimensions($_->{dimensions},"$settings{webdir}/$_->{link}",100,100); | |||||||||||||||||
| 338 | } | ||||||||||||||||||
| 339 | |||||||||||||||||||
| 340 | 0 | ▶ | $tvars{next} = $rows[9]->{imageid} unless(@rows < 10); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 341 | 0 | push @rows, @blanks; | |||||||||||||||||
| 342 | 0 | ▶ | $tvars{data} = \@rows if(@rows); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 343 | 0 | my @prev = $dbi->GetQuery('hash',$key.'GalleryMin',{where=>$where},$start); | |||||||||||||||||
| 344 | |||||||||||||||||||
| 345 | 0 | ▶ | $tvars{prev} = $prev[8]->{imageid} unless(@prev < 9); | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 346 | 0 | $tvars{imagetype} = $cgiparams{'imagetype'}; | |||||||||||||||||
| 347 | 0 | $tvars{ddstock} = StockSelect(); | |||||||||||||||||
| 348 | } | ||||||||||||||||||
| 349 | |||||||||||||||||||
| 350 | 4 | 1; | |||||||||||||||||
| 351 | |||||||||||||||||||
| 352 | __END__ | ||||||||||||||||||