]> mj.ucw.cz Git - gallery.git/blob - lib/UCW/Gallery/Web/Plain.pm
gal-mj-digikam: Use image title
[gallery.git] / lib / UCW / Gallery / Web / Plain.pm
1 # Plain Theme for MJ's Photo Gallery
2 # (c) 2012 Martin Mares <mj@ucw.cz>; GPL'ed
3
4 package UCW::Gallery::Web::Plain;
5
6 use common::sense;
7
8 use UCW::Gallery;
9 use UCW::Gallery::Web;
10
11 our @ISA = qw(UCW::Gallery::Web);
12
13 my $theme_name = "plain";
14 my $navw = 48;
15 my $navh = 48;
16 my $box_w = 130;
17 my $box_h = 110;
18
19 sub theme_dir($) {
20         my ($self) = @_;
21         return $self->get('ThemeUrlPrefix') . $theme_name;
22 }
23
24 sub theme_head_extras($) {
25         my ($self) = @_;
26         my $stylesheet = $self->theme_dir . "/style.css";
27         return "<link rel=stylesheet href='$stylesheet' type='text/css' media=all>\n";
28 }
29
30 sub show_links($$$$) {
31         my ($self, $prev, $up, $next) = @_;
32         my $theme = $self->theme_dir;
33         print "<p class=parent>";
34         print "<span class=back style='width: ${navw}px; height: ${navh}px'>";
35         print "<a href='$prev'><img src='$theme/prev.png' width=${navw} height=${navh} alt='Back'></a>" if $prev ne "";
36         print "</span>\n";
37         printf "<span class=fwd style='width: ${navw}px; height: ${navh}px'>";
38         printf "<a href='$next'><img src='$theme/next.png' width=${navw} height=${navh} alt='Forward'></a>" if $next ne "";
39         print "</span>\n";
40         printf "<a href='$up'><img src='$theme/back.png' width=${navw} height=${navh} alt='Up'></a>" if $up ne "";
41 }
42
43 sub show_thumb($) {
44         my ($self, $meta, $photo_id, $click_url) = @_;
45         my $theme = $self->theme_dir;
46         my $m = $meta->{photo}->{$photo_id};
47         my $annot = UCW::CGI::html_escape($m->{title});
48         my $tf = $self->get('ThumbFormats')->[0];
49         my ($thumb_w, $thumb_h) = $self->{gal}->thumb_fmt_to_size($tf);
50         my $tm = $meta->{thumb}->{$tf}->{$photo_id} or die "No thumbnails for format $tf found!\n";
51         my $tw = $tm->{w};
52         my $th = $tm->{h};
53         my $thumb = $self->get('ThumbUrlPrefix') . "$tf/$photo_id.jpg";
54         print "<div class=thf><div class=thumb>\n";
55         my $ol = int(($box_w - $tw)/2);
56         my $ot = int(($box_h - $th)/2);
57         my $tit = ($annot ne "") ? " title=\"$annot\"" : "";
58         print "<a href='$click_url'><img src='$thumb' width=$tw height=$th alt='Photo'$tit class=ti style='left: ${ol}px; top: ${ot}px'></a>\n";
59         print "</div></div>\n\n";
60 }
61
62 sub run($$) {
63         my ($class, $gal) = @_;
64         my $self = $class->SUPER::attach($gal);
65         $self->dispatch();
66         return $self;
67 }
68
69 1;