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