From 651df1af358dee15cd8406d8d954dfd8d4921b6e Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Mon, 31 Dec 2012 21:17:32 +0100 Subject: [PATCH] UCW::Gallery::Web: Better interface between web FE and hooks Each hook is now passed a reference to the front-end object, which provides a trivial interface to hooks. --- gal/UCW/Gallery/Web.pm | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/gal/UCW/Gallery/Web.pm b/gal/UCW/Gallery/Web.pm index af87ba5..693e349 100644 --- a/gal/UCW/Gallery/Web.pm +++ b/gal/UCW/Gallery/Web.pm @@ -32,12 +32,24 @@ sub extras($$) { my ($self, $key) = @_; my $val = $self->get($key); if (ref $val eq 'CODE') { - return &$val($self->{gal}); + return &$val($self); } else { return $val; } } +# For use by extras hooks +sub gallery($) { + my ($self) = @_; + return $self->{gal}; +} + +# For use by extras hooks: return true if we are showing an image page, false for index page +sub showing_image($) { + my ($self) = @_; + return $show_img ne ""; +} + sub html_top($) { my ($self) = @_; my $title = UCW::CGI::html_escape($self->get('Title')); -- 2.39.2