From 74d01f1942df636eef87612491c02378e6a19151 Mon Sep 17 00:00:00 2001 From: Tomas Cohen Arazi Date: Thu, 17 Oct 2019 15:40:44 -0300 Subject: [PATCH] Issue #1: Add a stub plugin structure for YAML configuration Signed-off-by: Tomas Cohen Arazi --- Koha/Plugin/Org/KC/ILL/Koha.pm | 87 ++++++++++++++++++++++++ Koha/Plugin/Org/KC/ILL/Koha/configure.tt | 40 +++++++++++ 2 files changed, 127 insertions(+) create mode 100644 Koha/Plugin/Org/KC/ILL/Koha.pm create mode 100644 Koha/Plugin/Org/KC/ILL/Koha/configure.tt diff --git a/Koha/Plugin/Org/KC/ILL/Koha.pm b/Koha/Plugin/Org/KC/ILL/Koha.pm new file mode 100644 index 0000000..f5b4222 --- /dev/null +++ b/Koha/Plugin/Org/KC/ILL/Koha.pm @@ -0,0 +1,87 @@ +package Koha::Plugin::Org::KC::ILL::Koha; + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# +# This program comes with ABSOLUTELY NO WARRANTY; + +use Modern::Perl; + +use base qw(Koha::Plugins::Base); + +use Mojo::JSON qw(decode_json); +use YAML; + +our $VERSION = "{VERSION}"; + +our $metadata = { + name => 'ILL plugin Koha <->Koha', + author => 'Koha Community', + date_authored => '2018-09-10', + date_updated => "2019-10-02", + minimum_version => '18.05', + maximum_version => undef, + version => $VERSION, + description => 'ILL plugin Koha <->Koha' +}; + +sub new { + my ( $class, $args ) = @_; + + $args->{'metadata'} = $metadata; + $args->{'metadata'}->{'class'} = $class; + + my $self = $class->SUPER::new($args); + + return $self; +} + +sub configure { + my ( $self, $args ) = @_; + my $cgi = $self->{'cgi'}; + + my $template = $self->get_template({ file => 'configure.tt' }); + + unless ( scalar $cgi->param('save') ) { + + ## Grab the values we already have for our settings, if any exist + $template->param( + configuration => $self->retrieve_data('configuration'), + ); + + $self->output_html( $template->output() ); + } + else { + $self->store_data( + { + configuration => scalar $cgi->param('configuration'), + } + ); + $template->param( + configuration => $self->retrieve_data('configuration'), + ); + $self->output_html( $template->output() ); + } +} + +sub configuration { + my ($self) = @_; + + my $configuration; + eval { $configuration = YAML::Load( $self->retrieve_data('configuration') . "\n\n" ); }; + die($@) if $@; + + return $configuration; +} + +1; diff --git a/Koha/Plugin/Org/KC/ILL/Koha/configure.tt b/Koha/Plugin/Org/KC/ILL/Koha/configure.tt new file mode 100644 index 0000000..4a4cb75 --- /dev/null +++ b/Koha/Plugin/Org/KC/ILL/Koha/configure.tt @@ -0,0 +1,40 @@ +[% INCLUDE 'doc-head-open.inc' %] + Koha › ILL plugin Koha <-> Koha › Configuration +[% INCLUDE 'doc-head-close.inc' %] + + +[% INCLUDE 'header.inc' %] +[% INCLUDE 'cat-search.inc' %] + + + +
+
+

ILL plugin Koha <-> Koha

+
+
+ + + + +
+ Configuration + +
+
+ +
+
+
+ +
+ +[% INCLUDE 'intranet-bottom.inc' %]