diff --git a/Plugins.pm.orig b/Plugins.pm index 11d44dc..71461de 100644 --- a/Plugins.pm.orig +++ b/Plugins.pm @@ -82,6 +82,35 @@ sub call { return @responses; } +=head2 call_apply + +Calls a plugin method for all enabled plugins, reworking on the same input and returning it. +ideally the caller of a plugin must not know how to merge the results +so maybe also implement a "merge" method in the plugin + + @responses = Koha::Plugins->call_apply($method, $work_var, @args) + +=cut + +sub call_apply { + my ($class, $method, $work_var, @args) = @_; + + if (C4::Context->config('enable_plugins')) { + my @plugins = $class->new({ enable_plugins => 1 })->GetPlugins({ method => $method }); + @plugins = grep { $_->can($method) } @plugins; + foreach my $plugin (@plugins) { + my $work_var = eval { $plugin->$method($work_var, @args) }; + if ($@) { + warn sprintf("Plugin error (%s): %s", $plugin->get_metadata->{name}, $@); + next; + } + } + + } + return $work_var; +} + + =head2 GetPlugins diff --git a/opac-detail.pl.orig b/opac-detail.pl index e74cf4b..b46eb90 100755 --- a/opac-detail.pl.orig +++ b/opac-detail.pl @@ -217,6 +217,16 @@ if ( $xslfile ) { $variables = { %$variables, %$plugin_variables }; } + $record = Koha::Plugins->call_apply( + 'munge_record', + $record, + { + patron => $patron, + interface => 'opac', + caller => 'opac-detail', + } + ); + $template->param( XSLTBloc => XSLTParse4Display( $biblionumber, $record, "OPACXSLTDetailsDisplay", 1, undef,