-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Issue #1: Add a stub plugin structure for YAML configuration
Signed-off-by: Tomas Cohen Arazi <[email protected]>
- Loading branch information
1 parent
5c051fd
commit 74d01f1
Showing
2 changed files
with
127 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
# | ||
# 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
[% INCLUDE 'doc-head-open.inc' %] | ||
<title>Koha › ILL plugin Koha <-> Koha › Configuration</title> | ||
[% INCLUDE 'doc-head-close.inc' %] | ||
</head> | ||
<body> | ||
[% INCLUDE 'header.inc' %] | ||
[% INCLUDE 'cat-search.inc' %] | ||
|
||
<div id="breadcrumbs"> | ||
<a href="/cgi-bin/koha/mainpage.pl">Home</a> › | ||
<a href="?class=[% CLASS %]&method=configure">ILL plugin Koha <-> Koha</a> › | ||
Configuration | ||
</div> | ||
|
||
<div id="doc3" class="yui-t2"> | ||
<div id="yui-main"> | ||
<h2>ILL plugin Koha <-> Koha</h2> | ||
<br/> | ||
<form method="post"> | ||
<input type="hidden" name="class" value="[% CLASS %]"/> | ||
<input type="hidden" name="method" value="configure"/> | ||
<input type="hidden" name="step" value="configure"/> | ||
<input type="hidden" name="save" value="1"/> | ||
<div class="input-group"> | ||
<span class="input-group-addon" id="configuration_label">Configuration</span> | ||
<textarea rows="30" | ||
columns="100" | ||
class="form-control" | ||
aria-describedby="configuration_label" | ||
name="configuration" id="configuration">[%- configuration -%]</textarea> | ||
</div> | ||
<br/> | ||
<button type="submit" value="Save" class="btn btn-default" type="button">Save</button> | ||
</form> | ||
</div> | ||
<div class="yui-b"> | ||
<div id="navmenu"> </div> | ||
</div> | ||
|
||
[% INCLUDE 'intranet-bottom.inc' %] |