Bugzilla – Attachment 170065 Details for
Bug 37570
Add possibility to send request on other url defined by a new syspref SearchAlsoIn
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37570: Add SearchAlsoIn syspref
Bug-37570-Add-SearchAlsoIn-syspref.patch (text/plain), 9.87 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-08-05 14:16:43 UTC
(
hide
)
Description:
Bug 37570: Add SearchAlsoIn syspref
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-08-05 14:16:43 UTC
Size:
9.87 KB
patch
obsolete
>From eca96f85790a8a211830bc9552268b3fceb4656b Mon Sep 17 00:00:00 2001 >From: Thibaud Guillot <thibaud.guillot@biblibre.com> >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', '<a href=\"https://worldcat.org/search?q={QUERY}\" target=\"_blank\">Other Libraries (WorldCat)</a>\n<br>\n<a href=\"https://scholar.google.com/scholar?q={QUERY}\" target=\"_blank\">Other Databases (Google Scholar)</a>', '', '', '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 <style> tag.','free'), > ('SCOUserJS','',NULL,'Define custom javascript for inclusion in the SCO module','free'), >+('SearchAlsoIn','<a href=\"https://worldcat.org/search?q={QUERY}\" target=\"_blank\">Other Libraries (WorldCat)</a>\n<br><a href=\"https://scholar.google.com/scholar?q={QUERY}\" target=\"_blank\">Other Databases (Google Scholar)</a>','Textarea'), > ('SearchEngine','Zebra','Elasticsearch|Zebra','Search Engine','Choice'), > ('SearchLimitLibrary', 'homebranch', 'homebranch|holdingbranch|both', "When limiting search results with a library or library group, use the item's home library, or holding library, or both.", 'Choice'), > ('SearchMyLibraryFirst','0',NULL,'If ON, OPAC searches return results limited by the user\'s library by default if they are logged in','YesNo'), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >index e697058880e..78f16078f04 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/searching.pref >@@ -362,7 +362,13 @@ Searching: > 1: Redirect > 0: "Don't redirect" > - to the result if a catalog search via the OPAC or staff interface returns only one record. >- >+ - >+ - 'Include a "Search also in" box on the results page, with the following HTML (leave blank to disable):' >+ - '<br />Note: The placeholders {QUERY} will be replaced by the request sent previously.' >+ - pref: SearchAlsoIn >+ type: textarea >+ syntax: text/html >+ class: code > Did you mean/spell checking: > - > - "Swedish service for spellchecking.<br/>" >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >index 91db336895a..bf20b3c9ac8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/results.tt >@@ -788,6 +788,22 @@ > > <div class="col-sm-2 col-sm-pull-10"> > <aside> >+ [% IF ( SearchAlsoIn ) %] >+ <ul id="action" class="fa-ul"> >+ <li> >+ <div id="search-also-in_menu"> >+ <div class="dropdown"> >+ <a id="furthersearches" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> >+ <i class="fa fa-fw fa-search" aria-hidden="true"></i> Search also in >+ </a> >+ <div class="dropdown-menu" aria-labelledby="furthersearches"> >+ [% SearchAlsoIn | $raw %] >+ </div> >+ </div> >+ </div> >+ </li> >+ </ul> >+ [% END %] > [% INCLUDE 'facets.inc' %] > </aside> > </div> <!-- /.col-sm-2.col-sm-pull-10 --> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >index c92819eebf4..41798a763b7 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-results.tt >@@ -99,6 +99,23 @@ > [% END # / UNLESS searchdesc %] > > <div class="container-fluid"> >+ [% IF ( SearchAlsoIn ) %] >+ <ul id="action" class="fa-ul"> >+ <li> >+ <div id="search-also-in_menu"> >+ <div class="dropdown"> >+ <a id="furthersearches" class="btn btn-link btn-lg dropdown-toggle" data-toggle="dropdown" href="#" role="button" aria-haspopup="true" aria-expanded="false"> >+ <i class="fa fa-fw fa-search" aria-hidden="true"></i> Search also in >+ </a> >+ <div class="dropdown-menu" aria-labelledby="furthersearches"> >+ [% SearchAlsoIn | $raw %] >+ </div> >+ </div> >+ </div> >+ </li> >+ </ul> >+ [% END %] >+ > <div class="row"> > [% IF ( opacfacets && total ) %] > <div class="col-lg-2"> >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index a5d80ed5855..025e9010313 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -43,7 +43,7 @@ my ($builder, $searcher); > $builder = Koha::SearchEngine::QueryBuilder->new({index => 'biblios'}); > $searcher = Koha::SearchEngine::Search->new({index => 'biblios'}); > >-use C4::Output qw( output_html_with_http_headers pagination_bar output_with_http_headers ); >+use C4::Output qw( output_html_with_http_headers pagination_bar output_with_http_headers parametrized_url); > use C4::Auth qw( get_template_and_user get_session ); > use C4::Languages qw( getlanguage getLanguages ); > use C4::Search qw( searchResults ); >@@ -923,4 +923,17 @@ if ($offset == 0) { > } > > $template->param( borrowernumber => $borrowernumber); >+ >+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_with_http_headers $cgi, $cookie, $template->output, $content_type; >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 37570
: 170065