]> mj.ucw.cz Git - gallery.git/blob - lib/UCW/Gallery/Web/NrtBlue.pm
Merge branch 'master' of ssh://git.ucw.cz/home/mj/GIT/gallery
[gallery.git] / lib / UCW / Gallery / Web / NrtBlue.pm
1 # NRT Theme for MJ's Photo Gallery
2 # (c) 2003--2012 Martin Mares <mj@ucw.cz>; GPL'ed
3 # Theme images taken from the cthumb package (c) Carlos Puchol
4
5 package UCW::Gallery::Web::NrtBlue;
6
7 use common::sense;
8
9 use UCW::Gallery;
10 use UCW::Gallery::Web;
11
12 our @ISA = qw(UCW::Gallery::Web);
13
14 my $theme_name = "nrt-blue";
15 my $navw = 48;
16 my $navh = 48;
17 my $interior_margin = 4;
18 my $left_w = 14;
19 my $right_w = 18;
20 my $top_h = 14;
21 my $bot_h = 18;
22
23 sub theme_dir($) {
24         my ($self) = @_;
25         return $self->get('ThemeUrlPrefix') . $theme_name;
26 }
27
28 sub theme_head_extras($) {
29         my ($self) = @_;
30         my $stylesheet = $self->theme_dir . "/style.css";
31         return "<link rel=stylesheet href='$stylesheet' type='text/css' media=all>\n";
32 }
33
34 sub show_links($$$$) {
35         my ($self, $prev, $up, $next) = @_;
36         my $theme = $self->theme_dir;
37         print "<p class=parent>";
38         print "<span class=back style='width: ${navw}px; height: ${navh}px'>";
39         print "<a href='$prev'><img src='$theme/prev.png' width=${navw} height=${navh} alt='Back'></a>" if $prev ne "";
40         print "</span>\n";
41         printf "<span class=fwd style='width: ${navw}px; height: ${navh}px'>";
42         printf "<a href='$next'><img src='$theme/next.png' width=${navw} height=${navh} alt='Forward'></a>" if $next ne "";
43         print "</span>\n";
44         printf "<a href='$up'><img src='$theme/back.png' width=${navw} height=${navh} alt='Up'></a>" if $up ne "";
45 }
46
47 sub show_thumb($) {
48         my ($self, $meta, $photo_id, $click_url) = @_;
49         my $theme = $self->theme_dir;
50         my $m = $meta->{photo}->{$photo_id};
51         my $annot = UCW::CGI::html_escape($m->{title});
52         my $tf = $self->get('ThumbFormats')->[0];
53         my ($thumb_w, $thumb_h) = $self->{gal}->thumb_fmt_to_size($tf);
54         my $tm = $meta->{thumb}->{$tf}->{$photo_id} or die "No thumbnails for format $tf found!\n";
55         my $tw = $tm->{w};
56         my $th = $tm->{h};
57         my $thumb = $self->get('ThumbUrlPrefix') . "$tf/$photo_id.jpg";
58         my $side_w = $thumb_w + 2*$interior_margin;
59         my $side_h = $thumb_h + 2*$interior_margin;
60         my $box_w = $left_w + $side_w + $right_w;
61         my $box_h = $top_h + $side_h + $bot_h;
62         print "<div class=thf><div class=thumb>\n";
63         print "<img src='$theme/top.png' width=$box_w height=$top_h alt='' class=tt>\n";
64         print "<img src='$theme/left.png' width=$left_w height=$side_h alt='' class=tl>\n";
65         my $ol = $left_w + $interior_margin + int(($thumb_w - $tw)/2);
66         my $ot = $top_h + $interior_margin + int(($thumb_h - $th)/2);
67         my $tit = ($annot ne "") ? " title=\"$annot\"" : "";
68         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";
69         print "<img src='$theme/right.png' width=$right_w height=$side_h alt='' class=tr>\n";
70         print "<img src='$theme/bot.png' width=$box_w height=$bot_h alt='' class=tb>\n";
71         print "</div></div>\n\n";
72 }
73
74 sub run($$) {
75         my ($class, $gal) = @_;
76         my $self = $class->SUPER::attach($gal);
77         $self->dispatch();
78         return $self;
79 }
80
81 1;