Skip to content

Commit adf930b

Browse files
authored
Merge pull request #101 from ebsco/search-load-fix
Search load fix
2 parents c8c1473 + 766f913 commit adf930b

9 files changed

Lines changed: 2015 additions & 11 deletions

File tree

Koha/Plugin/EDS.pm

Lines changed: 51 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package Koha::Plugin::EDS;
33
use Modern::Perl;
44
use base qw(Koha::Plugins::Base);
55
use C4::Context;
6+
use Encode qw(encode);
67
use C4::Members;
78
use C4::Auth;
89
use Cwd qw( abs_path );
@@ -12,6 +13,10 @@ use Try::Tiny;
1213
use IO::Socket::SSL qw();
1314
use WWW::Mechanize qw();
1415
use MIME::Base64 qw( encode_base64 decode_base64 );
16+
use Template;
17+
use Template::Constants qw( :debug );
18+
use Template::Filters;
19+
Template::Filters->use_html_entities;
1520
my $mech = WWW::Mechanize->new(ssl_opts => {
1621
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
1722
verify_hostname => 0,
@@ -25,10 +30,10 @@ $PluginDir = $PluginDir.'/Koha/Plugin/EDS';
2530

2631
################# DO NOT TOUCH - CONTROLLED BY build.py
2732
our $MAJOR_VERSION = "20.05";
28-
our $SUB_VERSION = "002";
33+
our $SUB_VERSION = "003";
2934
our $VERSION = $MAJOR_VERSION . "" . $SUB_VERSION;
3035
our $SHA_ADD = "https://widgets.ebscohost.com/prod/api/koha/sha/1711.json";
31-
our $DATE_UPDATE = '2021-03-24';
36+
our $DATE_UPDATE = '2021-05-11';
3237
######################################################
3338

3439
## Here is our metadata, some keys are required, some are optional
@@ -133,6 +138,9 @@ sub configure {
133138
}
134139
);
135140

141+
#Run script to update files from templates
142+
$self->update_EDSScript_js($cgi);
143+
136144
if($cgi->param('edsinfo') eq 'Update Required'){
137145

138146
$self->store_data(
@@ -149,6 +157,40 @@ sub configure {
149157
$self->go_home();
150158
}
151159

160+
sub update_EDSScript_js {
161+
my ($self, $cgi) = @_;
162+
my $vars = {
163+
edsusername => quotemeta(($cgi->param('edsusername')?$cgi->param('edsusername'):"-")),
164+
edspassword => quotemeta(($cgi->param('edspassword')?$cgi->param('edspassword'):"-")),
165+
edsprofileid => ($cgi->param('edsprofileid')?$cgi->param('edsprofileid'):"-"),
166+
edscustomerid => ($cgi->param('edscustomerid')?$cgi->param('edscustomerid'):"-"),
167+
cataloguedbid => ($cgi->param('cataloguedbid')?$cgi->param('cataloguedbid'):"-"),
168+
catalogueanprefix => ($cgi->param('catalogueanprefix')?$cgi->param('catalogueanprefix'):"-"),
169+
defaultsearch => ($cgi->param('defaultsearch')?$cgi->param('defaultsearch'):"-"),
170+
logerrors => ($cgi->param('logerrors')?$cgi->param('logerrors'):"-"),
171+
iprange => ($cgi->param('iprange')?$cgi->param('iprange'):"-"),
172+
cookieexpiry => ($cgi->param('cookieexpiry')?$cgi->param('cookieexpiry'):"-"),
173+
defaultparams => ($cgi->param('defaultparams')?$cgi->param('defaultparams'):"-"),
174+
autocomplete_mode => ($cgi->param('autocomplete_mode')?$cgi->param('autocomplete_mode'):"-"),
175+
autocomplete => ($cgi->param('autocomplete')?$cgi->param('autocomplete'):"-"),
176+
authtoken => $cgi->param('authtoken'),
177+
lastedsinfoupdate => $cgi->param('lastedsinfoupdate'),
178+
edsinfo => quotemeta($self->retrieve_data('edsinfo'))
179+
};
180+
#my $pluginsdir = C4::Context->config('pluginsdir');
181+
#my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
182+
#my @plugindirs;
183+
#foreach my $plugindir ( @pluginsdir ){
184+
# $plugindir .= "/Koha/Plugin/EDS/js";
185+
# push @plugindirs, $plugindir
186+
#}
187+
my $template = Template->new({
188+
INCLUDE_PATH => $PluginDir,
189+
OUTPUT_PATH => $PluginDir
190+
});
191+
$template->process('js/EDSScript.tt',$vars, 'js/EDSScript.js');
192+
$template->process('opac/templates/eds-methods.tt',$vars, 'opac/eds-methods.pl');
193+
}
152194

153195
sub install() {
154196
my ( $self, $args ) = @_;
@@ -188,9 +230,16 @@ sub uninstall() {
188230
#my $enableEDSUpdate = C4::Context->dbh->do("UPDATE `systempreferences` SET `value`='0' WHERE `variable`='EDSEnabled'");
189231
}
190232

233+
#Update the JS file to include the correct variables without needing to call SQL
234+
sub update_search {
235+
my ( $self, $default_search) = @_;
236+
237+
}
238+
191239
sub opac_js {
192240
my ( $self ) = @_;
193241
my $default_search = $self->retrieve_data('defaultsearch');
242+
194243
return q|
195244
<script>
196245
var defaultSearch="| . $default_search . q|";
Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<!-- DO NOT TOUCH THIS FILE - controlled by build.py -->
33
<kohaplugin>
4-
<latestversion>20.05.002</latestversion>
4+
<latestversion>20.05.003</latestversion>
55
<download>https://github.com/ebsco/edsapi-koha-plugin</download>
6-
<lastupdated>2021/03/24</lastupdated>
6+
<lastupdated>2021/05/11</lastupdated>
77
<releasenotes>
8-
<release version="20.05.002" date="2021/03/24">
9-
<note id="1" author="mabrahamson@ebsco.com">Addresses multiple PRs into 20.05 compatible build. See PR #90 for Full Details.</note>
8+
<release version="20.05.003" date="2021/05/11">
9+
<note id="1" author="mabrahamson@ebsco.com">Addresses issues with dropdown being delayed in opening.</note>
1010
</release>
1111
</releasenotes>
1212
</kohaplugin>

Koha/Plugin/EDS/js/EDSScript.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var edsSelectedKnownItem = "";
88
var browseNextPage = "";
99
var catalogueId = "";
1010
var nocorrect = "";
11-
11+
var defaultsearch = "";
1212
//-configurable in plugin config
1313
var edsSwitchText = '';
1414
var kohaSwitchText = '';

0 commit comments

Comments
 (0)