From eca96f85790a8a211830bc9552268b3fceb4656b Mon Sep 17 00:00:00 2001 From: Thibaud Guillot Date: Mon, 5 Aug 2024 16:11:56 +0200 Subject: [PATCH] Bug 37570: Add SearchAlsoIn syspref MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit SearchAlsoIn adds the possibility of defining urls to launch the query on the other sites. Dropdown menu appears on both sides (Staff and OPAC results pages) Test plan: 1) Apply this patch 2) Run updatedatabase 3) Perform a search on both sides (Staff and OPAC) 4) Click on "Search Also In" to see urls option to launch another query with your search Sponsored by: Institut français d’archéologie orientale (IFAO) --- catalogue/search.pl | 14 +++++++++++++- .../bug_37570-add_SearchAlsoIn_syspref.pl | 19 +++++++++++++++++++ installer/data/mysql/mandatory/sysprefs.sql | 1 + .../modules/admin/preferences/searching.pref | 8 +++++++- .../prog/en/modules/catalogue/results.tt | 16 ++++++++++++++++ .../bootstrap/en/modules/opac-results.tt | 17 +++++++++++++++++ opac/opac-search.pl | 15 ++++++++++++++- 7 files changed, 87 insertions(+), 3 deletions(-) create mode 100755 installer/data/mysql/atomicupdate/bug_37570-add_SearchAlsoIn_syspref.pl diff --git a/catalogue/search.pl b/catalogue/search.pl index ebb78bcfb6e..1f28e652eef 100755 --- a/catalogue/search.pl +++ b/catalogue/search.pl @@ -140,7 +140,7 @@ use Modern::Perl; ## load Koha modules use C4::Context; -use C4::Output qw( output_html_with_http_headers pagination_bar ); +use C4::Output qw( output_html_with_http_headers pagination_bar parametrized_url ); use C4::Circulation qw( barcodedecode ); use C4::Auth qw( get_template_and_user ); use C4::Search qw( searchResults enabled_staff_search_views z3950_search_args new_record_from_zebra ); @@ -781,6 +781,18 @@ $template->param( add_to_some_public_shelves => $some_public_shelves, ); +if (my $search_also_in = C4::Context->preference('SearchAlsoIn')){ + $simple_query =~ s/\/+$//; # remove trailing slash + $simple_query =~ s/\s+$//; # remove trailing space + $search_also_in = parametrized_url( + $search_also_in, + { + QUERY => $simple_query, + } + ); + $template->param('SearchAlsoIn' => $search_also_in); +} + output_html_with_http_headers $cgi, $cookie, $template->output; diff --git a/installer/data/mysql/atomicupdate/bug_37570-add_SearchAlsoIn_syspref.pl b/installer/data/mysql/atomicupdate/bug_37570-add_SearchAlsoIn_syspref.pl new file mode 100755 index 00000000000..d8ca477cfbc --- /dev/null +++ b/installer/data/mysql/atomicupdate/bug_37570-add_SearchAlsoIn_syspref.pl @@ -0,0 +1,19 @@ +use Modern::Perl; +use Koha::Installer::Output qw( say_success ); + +return { + bug_number => "37570", + description => "Add SearchAlsoIn syspref", + up => sub { + my ($args) = @_; + my ( $dbh, $out ) = @$args{qw(dbh out)}; + + # Do you stuffs here + $dbh->do(q{ + INSERT IGNORE INTO systempreferences (`variable`, `value`, `options`, `explanation`, `type`) VALUES ('SearchAlsoIn', 'Other Libraries (WorldCat)\n
\nOther Databases (Google Scholar)', '', '', 'Textarea'); + }); + + # sysprefs + say_success($out, "Added new system preference 'SearchAlsoIn'"); + }, +}; diff --git a/installer/data/mysql/mandatory/sysprefs.sql b/installer/data/mysql/mandatory/sysprefs.sql index 1a7cd033e90..2bec4b4e860 100644 --- a/installer/data/mysql/mandatory/sysprefs.sql +++ b/installer/data/mysql/mandatory/sysprefs.sql @@ -688,6 +688,7 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` ('SCOLoadCheckoutsByDefault','1','','If enabled, load the list of a patrons checkouts when they log in to the Self Checkout','YesNo'), ('SCOUserCSS','',NULL,'Add CSS to be included in the SCO module in an embedded