Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Search load fix #101

Merged
merged 2 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 51 additions & 2 deletions Koha/Plugin/EDS.pm
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package Koha::Plugin::EDS;
use Modern::Perl;
use base qw(Koha::Plugins::Base);
use C4::Context;
use Encode qw(encode);
use C4::Members;
use C4::Auth;
use Cwd qw( abs_path );
Expand All @@ -12,6 +13,10 @@ use Try::Tiny;
use IO::Socket::SSL qw();
use WWW::Mechanize qw();
use MIME::Base64 qw( encode_base64 decode_base64 );
use Template;
use Template::Constants qw( :debug );
use Template::Filters;
Template::Filters->use_html_entities;
my $mech = WWW::Mechanize->new(ssl_opts => {
SSL_verify_mode => IO::Socket::SSL::SSL_VERIFY_NONE,
verify_hostname => 0,
Expand All @@ -25,10 +30,10 @@ $PluginDir = $PluginDir.'/Koha/Plugin/EDS';

################# DO NOT TOUCH - CONTROLLED BY build.py
our $MAJOR_VERSION = "20.05";
our $SUB_VERSION = "002";
our $SUB_VERSION = "003";
our $VERSION = $MAJOR_VERSION . "" . $SUB_VERSION;
our $SHA_ADD = "https://widgets.ebscohost.com/prod/api/koha/sha/1711.json";
our $DATE_UPDATE = '2021-03-24';
our $DATE_UPDATE = '2021-05-11';
######################################################

## Here is our metadata, some keys are required, some are optional
Expand Down Expand Up @@ -133,6 +138,9 @@ sub configure {
}
);

#Run script to update files from templates
$self->update_EDSScript_js($cgi);

if($cgi->param('edsinfo') eq 'Update Required'){

$self->store_data(
Expand All @@ -149,6 +157,40 @@ sub configure {
$self->go_home();
}

sub update_EDSScript_js {
my ($self, $cgi) = @_;
my $vars = {
edsusername => quotemeta(($cgi->param('edsusername')?$cgi->param('edsusername'):"-")),
edspassword => quotemeta(($cgi->param('edspassword')?$cgi->param('edspassword'):"-")),
edsprofileid => ($cgi->param('edsprofileid')?$cgi->param('edsprofileid'):"-"),
edscustomerid => ($cgi->param('edscustomerid')?$cgi->param('edscustomerid'):"-"),
cataloguedbid => ($cgi->param('cataloguedbid')?$cgi->param('cataloguedbid'):"-"),
catalogueanprefix => ($cgi->param('catalogueanprefix')?$cgi->param('catalogueanprefix'):"-"),
defaultsearch => ($cgi->param('defaultsearch')?$cgi->param('defaultsearch'):"-"),
logerrors => ($cgi->param('logerrors')?$cgi->param('logerrors'):"-"),
iprange => ($cgi->param('iprange')?$cgi->param('iprange'):"-"),
cookieexpiry => ($cgi->param('cookieexpiry')?$cgi->param('cookieexpiry'):"-"),
defaultparams => ($cgi->param('defaultparams')?$cgi->param('defaultparams'):"-"),
autocomplete_mode => ($cgi->param('autocomplete_mode')?$cgi->param('autocomplete_mode'):"-"),
autocomplete => ($cgi->param('autocomplete')?$cgi->param('autocomplete'):"-"),
authtoken => $cgi->param('authtoken'),
lastedsinfoupdate => $cgi->param('lastedsinfoupdate'),
edsinfo => quotemeta($self->retrieve_data('edsinfo'))
};
#my $pluginsdir = C4::Context->config('pluginsdir');
#my @pluginsdir = ref($pluginsdir) eq 'ARRAY' ? @$pluginsdir : $pluginsdir;
#my @plugindirs;
#foreach my $plugindir ( @pluginsdir ){
# $plugindir .= "/Koha/Plugin/EDS/js";
# push @plugindirs, $plugindir
#}
my $template = Template->new({
INCLUDE_PATH => $PluginDir,
OUTPUT_PATH => $PluginDir
});
$template->process('js/EDSScript.tt',$vars, 'js/EDSScript.js');
$template->process('opac/templates/eds-methods.tt',$vars, 'opac/eds-methods.pl');
}

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

#Update the JS file to include the correct variables without needing to call SQL
sub update_search {
my ( $self, $default_search) = @_;

}

sub opac_js {
my ( $self ) = @_;
my $default_search = $self->retrieve_data('defaultsearch');

return q|
<script>
var defaultSearch="| . $default_search . q|";
Expand Down
8 changes: 4 additions & 4 deletions Koha/Plugin/EDS/admin/release_notes.xml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- DO NOT TOUCH THIS FILE - controlled by build.py -->
<kohaplugin>
<latestversion>20.05.002</latestversion>
<latestversion>20.05.003</latestversion>
<download>https://github.com/ebsco/edsapi-koha-plugin</download>
<lastupdated>2021/03/24</lastupdated>
<lastupdated>2021/05/11</lastupdated>
<releasenotes>
<release version="20.05.002" date="2021/03/24">
<note id="1" author="mabrahamson@ebsco.com">Addresses multiple PRs into 20.05 compatible build. See PR #90 for Full Details.</note>
<release version="20.05.003" date="2021/05/11">
<note id="1" author="mabrahamson@ebsco.com">Addresses issues with dropdown being delayed in opening.</note>
</release>
</releasenotes>
</kohaplugin>
2 changes: 1 addition & 1 deletion Koha/Plugin/EDS/js/EDSScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ var edsSelectedKnownItem = "";
var browseNextPage = "";
var catalogueId = "";
var nocorrect = "";

var defaultsearch = "";
//-configurable in plugin config
var edsSwitchText = '';
var kohaSwitchText = '';
Expand Down
Loading