document iterator cfgsection
[bse.git] / site / cgi-bin / modules / BSE / TB / Image.pm
CommitLineData
f40af7e2
TC
1package BSE::TB::Image;
2use strict;
3# represents an image from the database
4use Squirrel::Row;
ecc7c0d0 5use BSE::ThumbCommon;
f40af7e2 6use vars qw/@ISA/;
ecc7c0d0 7@ISA = qw/Squirrel::Row BSE::ThumbCommon/;
f40af7e2 8use Carp qw(confess);
f40af7e2 9
ecc7c0d0 10our $VERSION = "1.002";
cb7fd78d 11
f40af7e2
TC
12sub columns {
13 return qw/id articleId image alt width height url displayOrder name
14 storage src ftype/;
15}
16
f40af7e2
TC
17sub formatted {
18 my ($self, %opts) = @_;
19
20 my $cfg = delete $opts{cfg}
21 or confess "Missing cfg parameter";
22
23 my $handler = $self->_handler_object($cfg);
24
25 return $handler->format
26 (
27 image => $self,
28 %opts,
29 );
30}
31
32sub inline {
33 my ($self, %opts) = @_;
34
35 my $cfg = delete $opts{cfg}
36 or confess "Missing cfg parameter";
37
38 my $handler = $self->_handler_object($cfg);
39
40 return $handler->inline
41 (
42 image => $self,
43 %opts,
44 );
45}
46
3f23129e
TC
47sub popimage {
48 my ($im, %opts) = @_;
49
50 my $cfg = delete $opts{cfg}
51 or confess "Missing cfg parameter";
52
53 my $handler = $im->_handler_object($cfg);
54
55 return $handler->popimage
56 (
57 image => $im,
58 %opts,
59 );
60}
61
f40af7e2 62sub image_url {
d585a3cf 63 my ($im) = @_;
f40af7e2
TC
64
65 $im->src || "/images/$im->{image}";
66}
67
d585a3cf
TC
68sub json_data {
69 my ($self) = @_;
70
71 my $data = $self->data_only;
72 $data->{url} = $self->image_url;
73
74 return $data;
75}
76
ecc7c0d0
TC
77sub dynamic_thumb_url {
78 my ($self, %opts) = @_;
79
80 my $geo = delete $opts{geo}
81 or Carp::confess("missing geo option");
82
83 return $self->thumb_base_url
84 . "?g=$geo&page=$self->{articleId}&image=$self->{id}";
85}
86
87sub thumb_base_url {
88 '/cgi-bin/thumb.pl';
89}
90
91sub full_filename {
92 my ($self) = @_;
93
94 return BSE::TB::Images->image_dir() . "/" . $self->image;
95}
96
97# compatibility with BSE::TB::File
98sub filename {
99 my ($self) = @_;
100
101 return $self->image;
102}
103
f40af7e2 1041;