]> git.sesse.net Git - pr0n/blob - perl/Sesse/pr0n/Index.pm
Render the infobox on the client side.
[pr0n] / perl / Sesse / pr0n / Index.pm
1 package Sesse::pr0n::Index;
2 use strict;
3 use warnings;
4
5 use Sesse::pr0n::Common qw(error dberror);
6 use POSIX;
7
8 sub handler {
9         my $r = shift;
10         my $dbh = Sesse::pr0n::Common::get_dbh();
11
12         my ($event, $abspath, $datesort);
13         if ($r->path_info =~ /^\/\+all\/?/) {
14                 $event = '+all';
15                 $abspath = 1;
16
17                 $datesort = 'DESC NULLS LAST';
18         } else {
19                 # Find the event
20                 $r->path_info =~ /^\/([a-zA-Z0-9-]+)\/?$/
21                         or return error($r, "Could not extract event");
22                 $event = $1;
23                 $abspath = 0;
24                 $datesort = 'ASC NULLS LAST';
25         }
26
27         # Fix common error: pr0n.sesse.net/event -> pr0n.sesse.net/event/
28         if ($r->path_info !~ /\/$/) {
29                 my $res = Plack::Response->new(301);
30                 $res->header('Location' => $r->path_info . "/");
31                 return $res;
32         }
33
34         # Internal? (Ugly?) 
35         if (Sesse::pr0n::Common::get_server_name($r) =~ /internal/ ||
36             Sesse::pr0n::Common::get_server_name($r) =~ /skoyen\.bilder\.knatten\.com/ ||
37             Sesse::pr0n::Common::get_server_name($r) =~ /lia\.heimdal\.org/) {
38                 my $user = Sesse::pr0n::Common::check_access($r);
39                 return Sesse::pr0n::Common::generate_401($r) if (!defined($user));
40         }
41
42         # Read the appropriate settings from the query string into the settings hash
43         my %defsettings = (
44                 thumbxres => 320,
45                 thumbyres => 256,
46                 xres => -1,
47                 yres => -1,
48                 start => 1,
49                 num => 250,
50                 all => 1,
51                 rot => 0,
52                 sel => 0,
53                 fullscreen => 0,
54                 model => undef,
55                 lens => undef,
56                 author => undef
57         );
58         
59         my $where;
60         if ($event eq '+all') {
61                 $where = ' AND (event,vhost) IN ( SELECT event,vhost FROM events WHERE NOT hidden )';
62         } else {
63                 $where = ' AND event=' . $dbh->quote($event);
64         }
65         
66         # Any NEF files with no non-NEF renders => default to processing
67         my $ref = $dbh->selectrow_hashref("SELECT * FROM images WHERE vhost=? $where AND ( LOWER(filename) LIKE '%.nef' OR LOWER(filename) LIKE '%.cr2' ) AND render_id IS NULL LIMIT 1",
68                 undef, Sesse::pr0n::Common::get_server_name($r))
69                 and $defsettings{'xres'} = $defsettings{'yres'} = undef;
70         
71         my %settings = %defsettings;
72
73         for my $s (qw(thumbxres thumbyres xres yres start num all rot sel fullscreen model lens author)) {
74                 my $val = $r->param($s);
75                 if (defined($val) && $val =~ /^(\d+)$/) {
76                         $settings{$s} = $val;
77                 }
78                 if ($s eq "num" && defined($val) && $val == -1) {
79                         $settings{$s} = $val;
80                 }
81                 if (($s eq "xres" || $s eq "yres") && defined($val) && ($val == -1 || $val == -2)) {
82                         $settings{$s} = $val;
83                 }
84                 if (($s eq "model" || $s eq "lens" || $s eq "author") && defined($val)) {
85                         $settings{$s} = Sesse::pr0n::Common::pretty_unescape($val);
86                 }
87         }
88
89         my $thumbxres = $settings{'thumbxres'};
90         my $thumbyres = $settings{'thumbyres'};
91         my $xres = $settings{'xres'};
92         my $yres = $settings{'yres'};
93         my $start = $settings{'start'};
94         my $num = $settings{'num'};
95         my $all = $settings{'all'};
96         my $rot = $settings{'rot'};
97         my $sel = $settings{'sel'};
98         my $model = $settings{'model'};
99         my $lens = $settings{'lens'};
100         my $author = $settings{'author'};
101
102         # Construct SQL for this filter
103         if ($all == 0) {
104                 $where .= ' AND selected=\'t\'';        
105         }
106         if (defined($model) && defined($lens)) {
107                 my $mq = $dbh->quote($model);
108                 my $lq = $dbh->quote($lens);
109
110                 if ($model eq '') {
111                         # no defined model
112                         $where .= " AND model IS NULL";
113                 } else {
114                         $where .= " AND model=$mq";
115                 }
116         
117                 if ($lens eq '') {
118                         # no defined lens
119                         $where .= " AND lens IS NULL";
120                 } else {
121                         $where .= " AND lens=$lq";
122                 }
123         }
124         if (defined($author)) {
125                 my @authors = split /,/, $author;
126                 $where .= " AND takenby IN (" . join(', ', map { $dbh->quote($_) } @authors) . ")";
127         }
128
129         if (defined($num) && $num == -1) {
130                 $num = undef;
131         }
132
133         my ($date, $name);
134
135         if ($event eq '+all') {
136                 $ref = $dbh->selectrow_hashref("SELECT EXTRACT(EPOCH FROM MAX(last_update)) AS last_update FROM last_picture_cache WHERE vhost=?",
137                         undef, Sesse::pr0n::Common::get_server_name($r))
138                         or return error($r, "Could not list events", 404, "File not found");
139                 $date = undef;
140                 $name = Sesse::pr0n::Templates::fetch_template($r, 'all-event-title');
141                 Sesse::pr0n::Common::set_last_modified($r, $ref->{'last_update'});
142         } else {
143                 $ref = $dbh->selectrow_hashref("SELECT name,date,EXTRACT(EPOCH FROM last_update) AS last_update FROM events NATURAL JOIN last_picture_cache WHERE vhost=? AND event=?",
144                         undef, Sesse::pr0n::Common::get_server_name($r), $event)
145                         or return error($r, "Could not find event $event", 404, "File not found");
146
147                 $date = HTML::Entities::encode_entities($ref->{'date'});
148                 $name = HTML::Entities::encode_entities($ref->{'name'});
149                 Sesse::pr0n::Common::set_last_modified($r, $ref->{'last_update'});
150         }
151                                 
152         # # If the client can use cache, do so
153         # if ((my $rc = $r->meets_conditions) != Apache2::Const::OK) {
154         #       return $rc;
155         # }
156         
157         # Count the number of selected images.
158         $ref = $dbh->selectrow_hashref("SELECT COUNT(*) AS num_selected FROM images WHERE vhost=? $where AND selected AND NOT is_render", undef, Sesse::pr0n::Common::get_server_name($r));
159         my $num_selected = $ref->{'num_selected'};
160
161         # Find all images related to this event.
162         my $limit = (defined($start) && defined($num) && !$settings{'fullscreen'}) ? (" LIMIT $num OFFSET " . ($start-1)) : "";
163
164         my $extra_joins = "";
165         my $extra_fields = "";
166         if ($settings{'fullscreen'}) {
167                 $extra_joins = <<"EOF";
168     LEFT JOIN exif_info exif_prog ON images.id=exif_prog.image AND exif_prog.key = 'ExposureProgram'
169     LEFT JOIN exif_info exif_focal ON images.id=exif_focal.image AND exif_focal.key = 'FocalLength'
170     LEFT JOIN exif_info exif_shutter ON images.id=exif_shutter.image AND exif_shutter.key = 'ExposureTime'
171     LEFT JOIN exif_info exif_fnum ON images.id=exif_fnum.image AND exif_fnum.key = 'FNumber'
172     LEFT JOIN exif_info exif_iso1 ON images.id=exif_iso1.image AND exif_iso1.key = 'ISO'
173     LEFT JOIN exif_info exif_iso2 ON images.id=exif_iso2.image AND exif_iso2.key = 'ISOSetting'
174     LEFT JOIN exif_info exif_ev1 ON images.id=exif_ev1.image AND exif_ev1.key = 'ExposureBiasValue'
175     LEFT JOIN exif_info exif_ev2 ON images.id=exif_ev2.image AND exif_ev2.key = 'ExposureCompensation'
176     LEFT JOIN exif_info exif_date ON images.id=exif_date.image AND exif_date.key = 'DateTimeOriginal'
177     LEFT JOIN exif_info exif_model ON images.id=exif_model.image AND exif_model.key = 'Model'
178     LEFT JOIN exif_info exif_flash ON images.id=exif_flash.image AND exif_flash.key = 'Flash'
179 EOF
180                 $extra_fields = <<"EOF";
181     exif_prog.value AS "ExposureProgram",
182     exif_focal.value AS "FocalLength",
183     exif_shutter.value AS "ExposureTime",
184     exif_fnum.value AS "FNumber",
185     exif_iso1.value AS "ISO",
186     exif_iso2.value AS "ISOSetting",
187     exif_ev1.value AS "ExposureBiasValue",
188     exif_ev2.value AS "ExposureCompensation",
189     exif_date.value AS "DateTimeOriginal",
190     exif_model.value AS "Model",
191     exif_flash.value AS "Flash",
192 EOF
193         }
194
195         my $q = $dbh->prepare(<<"EOF")
196 SELECT *,
197   $extra_fields
198   (date - INTERVAL '6 hours')::date AS day
199 FROM
200   images
201   $extra_joins
202 WHERE
203   vhost=?
204   $where
205   AND NOT is_render
206 ORDER BY (date - INTERVAL '6 hours')::date $datesort,takenby,date,filename
207 $limit
208 EOF
209                 or return dberror($r, "prepare()");
210         $q->execute(Sesse::pr0n::Common::get_server_name($r))
211                 or return dberror($r, "image enumeration");
212
213         # Print the page itself
214         my $res = Plack::Response->new(200);
215         my $io = IO::String->new;
216         if ($settings{'fullscreen'}) {
217                 $res->content_type("text/html; charset=utf-8");
218
219                 Sesse::pr0n::Templates::print_template($r, $io, "fullscreen-header", { title => "$name [$event]" });
220
221                 my @files = ();
222                 while (my $ref = $q->fetchrow_hashref()) {
223                         my $width = defined($ref->{'width'}) ? $ref->{'width'} : -1;
224                         my $height = defined($ref->{'height'}) ? $ref->{'height'} : -1;
225                         my @parts = Sesse::pr0n::Common::make_infobox_parts($ref);
226                         @parts = map { $_->[1] ? "<strong>" . HTML::Entities::encode_entities($_->[0]) . "</strong>" : HTML::Entities::encode_entities($_->[0]) } @parts;
227                         push @files, [ $ref->{'event'}, $ref->{'filename'}, $width, $height, join('', @parts) ];
228                 }
229                 
230                 for my $i (0..$#files) {
231                         my $line = sprintf "        [ \"%s\", \"%s\", %d, %d, \"%s\" ]", @{$files[$i]};
232                         $line .= "," unless ($i == $#files);
233                         $io->print($line . "\n");
234                 }
235
236                 my %settings_no_fullscreen = %settings;
237                 $settings_no_fullscreen{'fullscreen'} = 0;
238
239                 my $returnurl = "http://" . Sesse::pr0n::Common::get_server_name($r) . "/" . $event . "/" .
240                         Sesse::pr0n::Common::get_query_string(\%settings_no_fullscreen, \%defsettings);
241                 
242                 # *whistle*
243                 $returnurl =~ s/&amp;/&/g;
244
245                 Sesse::pr0n::Templates::print_template($r, $io, "fullscreen-footer", {
246                         returnurl => $returnurl,
247                         start => $settings{'start'} - 1,
248                         sel => $settings{'sel'}
249                 });
250         } else {
251                 Sesse::pr0n::Common::header($r, $io, "$name [$event]");
252                 if (defined($date)) {
253                         Sesse::pr0n::Templates::print_template($r, $io, "date", { date => $date });
254                 }
255
256                 if (Sesse::pr0n::Overload::is_in_overload($r)) {
257                         Sesse::pr0n::Templates::print_template($r, $io, "overloadmode");
258                 }
259
260                 print_selected($r, $io, $event, \%settings, \%defsettings) if ($num_selected > 0);
261                 print_fullscreen($r, $io, $event, \%settings, \%defsettings);
262                 print_nextprev($r, $io, $event, $where, \%settings, \%defsettings);
263         
264                 if (1 || $event ne '+all') {
265                         # Find the equipment used
266                         my $eq = $dbh->prepare("
267                                 SELECT
268                                         model,
269                                         lens,
270                                         COUNT(*) AS num
271                                 FROM images
272                                 WHERE vhost=? $where
273                                 AND NOT is_render
274                                 GROUP BY 1,2
275                                 ORDER BY 1,2")
276                                 or die "Couldn't prepare to find equipment: $!";
277                         $eq->execute(Sesse::pr0n::Common::get_server_name($r))
278                                 or die "Couldn't find equipment: $!";
279
280                         my @equipment = ();
281                         my %cameras_seen = ();
282                         while (my $ref = $eq->fetchrow_hashref) {
283                                 if (!defined($ref->{'lens'}) && exists($cameras_seen{$ref->{'model'}})) {
284                                         #
285                                         # Some compact cameras seem to add lens info sometimes and not at other
286                                         # times; if we have seen a camera with at least one specific lens earlier,
287                                         # just combine entries without a lens with the previous one.
288                                         #
289                                         $equipment[$#equipment]->{'num'} += $ref->{'num'};
290                                         next;
291                                 }
292                                 push @equipment, $ref;
293                                 $cameras_seen{$ref->{'model'}} = 1;
294                         }
295                         $eq->finish;
296
297                         if (scalar @equipment > 0) {
298                                 Sesse::pr0n::Templates::print_template($r, $io, "equipment-start");
299                                 for my $e (@equipment) {
300                                         my $eqspec = $e->{'model'};
301                                         $eqspec .= ', ' . $e->{'lens'} if (defined($e->{'lens'}));
302                                         $eqspec = HTML::Entities::encode_entities($eqspec);
303
304                                         my %newsettings = %settings;
305
306                                         my $action;
307                                         if (defined($model) && defined($lens)) {
308                                                 chomp ($action = Sesse::pr0n::Templates::fetch_template($r, "unfilter"));
309                                                 $newsettings{'model'} = undef;
310                                                 $newsettings{'lens'} = undef;
311                                                 $newsettings{'start'} = 1;
312                                         } else {
313                                                 chomp ($action = Sesse::pr0n::Templates::fetch_template($r, "filter"));
314                                                 $newsettings{'model'} = $e->{'model'};
315                                                 $newsettings{'lens'} = defined($e->{'lens'}) ? $e->{'lens'} : '';
316                                                 $newsettings{'start'} = 1;
317                                         }
318                                         
319                                         my $url = "/$event/" . Sesse::pr0n::Common::get_query_string(\%newsettings, \%defsettings);
320
321                                         # This isn't correct for all languages. Fix if we ever need to care. :-)
322                                         if ($e->{'num'} == 1) {
323                                                 Sesse::pr0n::Templates::print_template($r, $io, "equipment-item-singular", { eqspec => $eqspec, filterurl => $url, action => $action });
324                                         } else {
325                                                 Sesse::pr0n::Templates::print_template($r, $io, "equipment-item", { eqspec => $eqspec, num => $e->{'num'}, filterurl => $url, action => $action });
326                                         }
327                                 }
328                                 Sesse::pr0n::Templates::print_template($r, $io, "equipment-end");
329                         }
330                 }
331
332                 my $toclose = 0;
333                 my $lastupl = "";
334                 my $img_num = (defined($start) && defined($num)) ? $start : 1;
335                 
336                 # Print out all thumbnails
337                 if ($rot == 1) {
338                         $io->print("    <form method=\"post\" action=\"/rotate\">\n");
339                         $io->print("      <input type=\"hidden\" name=\"event\" value=\"$event\" />\n");
340                 }
341
342                 while (my $ref = $q->fetchrow_hashref()) {
343                         my $imgsz = "";
344                         my $takenby = $ref->{'takenby'};
345                         my $day = '';
346                         if (defined($ref->{'day'})) {
347                                 $day = ", " . $ref->{'day'};
348                         }
349
350                         my $groupkey = $takenby . $day;
351
352                         if ($groupkey ne $lastupl) {
353                                 $io->print("    </p>\n\n") if ($lastupl ne "" && $rot != 1);
354                                 $lastupl = $groupkey;
355
356                                 my %newsettings = %settings;
357
358                                 my $action;
359                                 if (defined($author)) {
360                                         chomp ($action = Sesse::pr0n::Templates::fetch_template($r, "unfilter"));
361                                         $newsettings{'author'} = undef;
362                                         $newsettings{'start'} = 1;
363                                 } else {
364                                         chomp ($action = Sesse::pr0n::Templates::fetch_template($r, "filter"));
365                                         $newsettings{'author'} = $ref->{'takenby'};
366                                         $newsettings{'start'} = 1;
367                                 }
368
369                                 my $url = "/$event/" . Sesse::pr0n::Common::get_query_string(\%newsettings, \%defsettings);
370                                 
371                                 $io->print("    <h2>");
372                                 Sesse::pr0n::Templates::print_template($r, $io, "submittedby", { author => $takenby, action => $action, filterurl => $url, date => $day });
373                                 print_fullscreen_fromhere($r, $io, $event, \%settings, \%defsettings, $img_num);
374                                 $io->print("</h2>\n");
375
376                                 if ($rot != 1) {
377                                         $io->print("    <p class=\"photos\">\n");
378                                 }
379                         }
380
381                         if (defined($ref->{'width'}) && defined($ref->{'height'})) {
382                                 my $width = $ref->{'width'};
383                                 my $height = $ref->{'height'};
384                                         
385                                 ($width, $height) = Sesse::pr0n::Common::scale_aspect($width, $height, $thumbxres, $thumbyres);
386                                 $imgsz = " width=\"$width\" height=\"$height\"";
387                         }
388
389                         # Add fullscreen link.
390                         my %fssettings = %settings;
391                         $fssettings{'fullscreen'} = 1;
392                         my $fsquery = Sesse::pr0n::Common::get_query_string(\%fssettings, \%defsettings);
393                         $fsquery .= '#' . $img_num;
394
395                         my $filename = $ref->{'filename'};
396                         my $uri = $filename;
397                         if (defined($xres) && defined($yres) && $xres != -1 && $xres != -2) {
398                                 $uri = "${xres}x$yres/$filename";
399                         } elsif (defined($xres) && $xres == -1) {
400                                 $uri = "original/$filename";
401                         }
402                         
403                         my $prefix = "";
404                         if ($abspath) {
405                                 $prefix = "/" . $ref->{'event'} . "/";
406                         }
407                 
408                         if ($rot == 1) {        
409                                 $io->print("    <p>");
410                         } else {
411                                 $io->print("     ");
412                         }
413                         $io->print("<a href=\"$prefix$uri\" id=\"$img_num\" onclick=\"location.href='$prefix$fsquery';return false;\"><img src=\"$prefix${thumbxres}x${thumbyres}/$filename\" alt=\"\"$imgsz /></a>\n");
414                 
415                         if ($rot == 1) {
416                                 $io->print("      90 <input type=\"checkbox\" name=\"rot-" .
417                                         $ref->{'id'} . "-90\" />\n");
418                                 $io->print("      180 <input type=\"checkbox\" name=\"rot-" .
419                                         $ref->{'id'} . "-180\" />\n");
420                                 $io->print("      270 <input type=\"checkbox\" name=\"rot-" .
421                                         $ref->{'id'} . "-270\" />\n");
422                                 $io->print("      &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" .
423                                         "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Del <input type=\"checkbox\" name=\"del-" . $ref->{'id'} . "\" /></p>\n");
424                         }
425                         
426                         ++$img_num;
427                 }
428
429                 if ($rot == 1) {
430                         $io->print("      <input type=\"submit\" value=\"Rotate\" />\n");
431                         $io->print("    </form>\n");
432                 } else {
433                         $io->print("    </p>\n");
434                 }
435
436                 print_nextprev($r, $io, $event, $where, \%settings, \%defsettings);
437                 Sesse::pr0n::Common::footer($r, $io);
438         }
439
440         $io->setpos(0);
441         $res->body($io);
442         return $res;
443 }
444
445 sub eq_with_undef {
446         my ($a, $b) = @_;
447         
448         return 1 if (!defined($a) && !defined($b));
449         return 0 unless (defined($a) && defined($b));
450         return ($a eq $b);
451 }
452
453 sub print_changes {
454         my ($r, $io, $event, $template, $settings, $defsettings, $var1, $var2, $alternatives) = @_;
455
456         my $title = Sesse::pr0n::Templates::fetch_template($r, $template);
457         chomp $title;
458         $io->print("    <p>$title:\n");
459
460         for my $a (@$alternatives) {
461                 my $text;
462                 my %newsettings = %$settings;
463
464                 if (ref $a) {
465                         my ($v1, $v2);
466                         ($text, $v1, $v2) = @$a;
467                         
468                         $newsettings{$var1} = $v1;
469                         $newsettings{$var2} = $v2;
470                 } else {
471                         $text = $a;
472
473                         # Parse the current alternative
474                         my ($v1, $v2) = split /x/, $a;
475
476                         $newsettings{$var1} = $v1;
477                         $newsettings{$var2} = $v2;
478                 }
479
480                 $io->print("      ");
481
482                 # Check if these settings are current (print only label)
483                 if (eq_with_undef($settings->{$var1}, $newsettings{$var1}) &&
484                     eq_with_undef($settings->{$var2}, $newsettings{$var2})) {
485                         $io->print($text);
486                 } else {
487                         Sesse::pr0n::Common::print_link($io, $text, "/$event/", \%newsettings, $defsettings);
488                 }
489                 $io->print("\n");
490         }
491         $io->print("    </p>\n");
492 }
493
494 sub print_nextprev {
495         my ($r, $io, $event, $where, $settings, $defsettings) = @_;
496         my $start = $settings->{'start'};
497         my $num = $settings->{'num'};
498         my $dbh = Sesse::pr0n::Common::get_dbh();
499
500         $num = undef if (defined($num) && $num == -1);
501         return unless (defined($start) && defined($num));
502
503         # determine total number
504         my $ref = $dbh->selectrow_hashref("SELECT count(*) AS num_images FROM images WHERE vhost=? $where AND NOT is_render",
505                 undef, Sesse::pr0n::Common::get_server_name($r))
506                 or return dberror($r, "image enumeration");
507         my $num_images = $ref->{'num_images'};
508
509         return if ($start == 1 && $start + $num >= $num_images);
510
511         my $end = $start + $num - 1;
512         if ($end > $num_images) {
513                 $end = $num_images;
514         }
515
516         $io->print("    <p class=\"nextprev\">\n");
517
518         # Previous
519         if ($start > 1) {
520                 my $newstart = $start - $num;
521                 if ($newstart < 1) {
522                         $newstart = 1;
523                 }
524                 my $newend = $newstart + $num - 1;
525                 if ($newend > $num_images) {
526                         $newend = $num_images;
527                 }
528
529                 my %newsettings = %$settings;
530                 $newsettings{'start'} = $newstart;
531                 chomp (my $title = Sesse::pr0n::Templates::fetch_template($r, 'prevpage'));
532                 chomp (my $accesskey = Sesse::pr0n::Templates::fetch_template($r, 'prevaccesskey'));
533                 Sesse::pr0n::Common::print_link($io, "$title ($newstart-$newend)\n", "/$event/", \%newsettings, $defsettings, $accesskey);
534         }
535
536         # This
537         chomp (my $title = Sesse::pr0n::Templates::fetch_template($r, 'thispage'));
538         $io->print("    $title ($start-$end)\n");
539
540         # Next
541         if ($end < $num_images) {
542                 my $newstart = $start + $num;
543                 my $newend = $newstart + $num - 1;
544                 if ($newend > $num_images) {
545                         $newend = $num_images;
546                 }
547                 
548                 my %newsettings = %$settings;
549                 $newsettings{'start'} = $newstart;
550                 chomp (my $title = Sesse::pr0n::Templates::fetch_template($r, 'nextpage'));
551                 chomp (my $accesskey = Sesse::pr0n::Templates::fetch_template($r, 'nextaccesskey'));
552                 Sesse::pr0n::Common::print_link($io, "$title ($newstart-$newend)", "/$event/", \%newsettings, $defsettings, $accesskey);
553         }
554
555         $io->print("    </p>\n");
556 }
557
558 sub print_selected {
559         my ($r, $io, $event, $settings, $defsettings) = @_;
560
561         chomp (my $title = Sesse::pr0n::Templates::fetch_template($r, 'show'));
562         chomp (my $all = Sesse::pr0n::Templates::fetch_template($r, 'show-all'));
563         chomp (my $sel = Sesse::pr0n::Templates::fetch_template($r, 'show-selected'));
564
565         $io->print("    <p>$title:\n");
566
567         my %newsettings = %$settings;
568
569         if ($settings->{'all'} == 0) {
570                 $io->print($sel);
571         } else {
572                 $newsettings{'all'} = 0;
573                 Sesse::pr0n::Common::print_link($io, $sel, "/$event/", \%newsettings, $defsettings);
574         }
575
576         $io->print(' ');
577
578         if ($settings->{'all'} == 1) {
579                 $io->print($all);
580         } else {
581                 $newsettings{'all'} = 1;
582                 Sesse::pr0n::Common::print_link($io, $all, "/$event/", \%newsettings, $defsettings);
583         }
584         
585         $io->print('</p>');
586 }
587
588 sub print_fullscreen {
589         my ($r, $io, $event, $settings, $defsettings) = @_;
590
591         chomp (my $title = Sesse::pr0n::Templates::fetch_template($r, 'fullscreen'));
592
593         my %newsettings = %$settings;
594         $newsettings{'fullscreen'} = 1;
595
596         $io->print("    <p>");
597         Sesse::pr0n::Common::print_link($io, $title, "/$event/", \%newsettings, $defsettings);
598         $io->print("</p>\n");
599 }
600
601 sub print_fullscreen_fromhere {
602         my ($r, $io, $event, $settings, $defsettings, $start) = @_;
603
604         chomp (my $title = Sesse::pr0n::Templates::fetch_template($r, 'fullscreen-fromhere'));
605
606         my %newsettings = %$settings;
607         $newsettings{'fullscreen'} = 1;
608         $newsettings{'start'} = $start;
609
610         $io->print("    <span class=\"fsfromhere\">");
611         Sesse::pr0n::Common::print_link($io, $title, "/$event/", \%newsettings, $defsettings);
612         $io->print("</span>\n");
613 }
614         
615 1;
616
617