Bugzilla – Attachment 22774 Details for
Bug 10986
Limit the list of languages in advanced search through system preferences
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bugs 10986 - Limit the list of languages in advanced search
Bugs-10986---Limit-the-list-of-languages-in-advanc.patch (text/plain), 9.29 KB, created by
Jonathan Druart
on 2013-11-07 13:32:18 UTC
(
hide
)
Description:
Bugs 10986 - Limit the list of languages in advanced search
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2013-11-07 13:32:18 UTC
Size:
9.29 KB
patch
obsolete
>From e0aaa84886637927240e7c2460d92c3e2b511310 Mon Sep 17 00:00:00 2001 >From: blou <philippe.blouin@inlibro.com> >Date: Wed, 2 Oct 2013 15:05:38 -0400 >Subject: [PATCH] Bugs 10986 - Limit the list of languages in advanced search > >In Advanced Search, the list of available language is long and will only get longer. For a library offering books in 2-3 languages, that is offering too much info to the user (most of the small libraries we deal with only offer documents in two languages). > >Code changes: >Languages.pm: Extract getAllLanguages to make a more customizable getLanguages (have getAllLanguage call it, so rest of codebase is oblivious to the change). Build array returned based on system pref if corresponding argument is set. >search.pl and opac-search.pl: call getLanguages instead of getAllLanguages. > >TESTING >0) All language codes are iso 639-2 (three characters) >1) in OPAC, Advanced search, open Language box, acknowledge 30+ items. >2) in Intranet, go to system preferences AdvancedSearchLanguages, enter "ita|eng" >3) back in OPAC, refresh screen, acknowledge only Italian and English are listed. >4) in Intranet, click Search then click "More options" to make the Language box appear. Acknowledge limited options. >5) Regression Test: Back to the preference, empty the field then save. Go back to the OPAC and Intranet search, refresh the page, then the Language drop-box will now contain 30+ items. > >Signed-off-by: Mathieu Saby <mathieu.saby@univ-rennes2.fr> > >Signed-off-by: Jonathan Druart <jonathan.druart@biblibre.com> >--- > C4/Languages.pm | 30 ++++++++++++++++---- > catalogue/search.pl | 4 +-- > installer/data/mysql/sysprefs.sql | 3 +- > installer/data/mysql/updatedatabase.pl | 7 +++++ > .../en/modules/admin/preferences/searching.pref | 6 ++++ > opac/opac-search.pl | 4 +-- > 6 files changed, 44 insertions(+), 10 deletions(-) > >diff --git a/C4/Languages.pm b/C4/Languages.pm >index 2a74b92..75b9690 100644 >--- a/C4/Languages.pm >+++ b/C4/Languages.pm >@@ -43,9 +43,10 @@ BEGIN { > @EXPORT = qw( > &getFrameworkLanguages > &getTranslatedLanguages >+ &getLanguages > &getAllLanguages > ); >- @EXPORT_OK = qw(getFrameworkLanguages getTranslatedLanguages getAllLanguages get_bidi regex_lang_subtags language_get_description accept_language); >+ @EXPORT_OK = qw(getFrameworkLanguages getTranslatedLanguages getAllLanguages getLanguages get_bidi regex_lang_subtags language_get_description accept_language); > $DEBUG = 0; > } > >@@ -178,14 +179,31 @@ Returns a reference to an array of hashes: > =cut > > sub getAllLanguages { >+ return getLanguages(shift); >+} >+ >+=head2 getLanguages >+ >+Returns a reference to an array of hashes. >+Extracted from getAllLanguages to limit effect on the code base. >+This new function (name) will allow for more arguments to customize the values returned. >+ >+- If no parameter is passed to the function, it returns english languages names >+- If a $lang parameter conforming to RFC4646 syntax is passed, the function returns languages names translated in $lang >+ If a language name is not translated in $lang in database, the function returns english language name >+- If $isFiltered is set to true, only the detail of the languages selected in system preferences AdvanceSearchLanguages is returned. >+ >+=cut >+ >+sub getLanguages { > my $lang = shift; >-# if no parameter is passed to the function, it returns english languages names >-# if a $lang parameter conforming to RFC4646 syntax is passed, the function returns languages names translated in $lang >-# if a language name is not translated in $lang in database, the function returns english language name >+ my $isFiltered = shift; >+ > my @languages_loop; > my $dbh=C4::Context->dbh; > my $default_language = 'en'; > my $current_language = $default_language; >+ my $language_list=C4::Context->preference("AdvancedSearchLanguages") if $isFiltered; > if ($lang) { > $current_language = regex_lang_subtags($lang)->{'language'}; > } >@@ -226,7 +244,9 @@ sub getAllLanguages { > $language_subtag_registry->{language_description} = $language_descriptions->{description}; > } > } >- push @languages_loop, $language_subtag_registry; >+ if ( !$language_list || index ( $language_list, $language_subtag_registry->{ iso639_2_code } ) >= 0) { >+ push @languages_loop, $language_subtag_registry; >+ } > } > return \@languages_loop; > } >diff --git a/catalogue/search.pl b/catalogue/search.pl >index 892ff15..9d6198a 100755 >--- a/catalogue/search.pl >+++ b/catalogue/search.pl >@@ -144,7 +144,7 @@ use C4::Context; > use C4::Output; > use C4::Auth qw(:DEFAULT get_session); > use C4::Search; >-use C4::Languages qw(getAllLanguages); >+use C4::Languages qw(getLanguages); > use C4::Koha; > use C4::Members qw(GetMember); > use C4::VirtualShelves; >@@ -339,7 +339,7 @@ if ( $template_type eq 'advsearch' ) { > search_boxes_loop => \@search_boxes_array); > > # load the language limits (for search) >- my $languages_limit_loop = getAllLanguages($lang); >+ my $languages_limit_loop = getLanguages($lang, 1); > $template->param(search_languages_loop => $languages_limit_loop,); > > # Expanded search options in advanced search: >diff --git a/installer/data/mysql/sysprefs.sql b/installer/data/mysql/sysprefs.sql >index 72eead2..1cc34d3 100644 >--- a/installer/data/mysql/sysprefs.sql >+++ b/installer/data/mysql/sysprefs.sql >@@ -422,5 +422,6 @@ INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` > ('XSLTResultsDisplay','default','','Enable XSL stylesheet control over results page display on intranet','Free'), > ('yuipath','local','local|http://yui.yahooapis.com/2.5.1/build','Insert the path to YUI libraries, choose local if you use koha offline','Choice'), > ('z3950AuthorAuthFields','701,702,700',NULL,'Define the MARC biblio fields for Personal Name Authorities to fill biblio.author','free'), >-('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo') >+('z3950NormalizeAuthor','0','','If ON, Personal Name Authorities will replace authors in biblio.author','YesNo'), >+('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option. Example: eng|fre|ita','Textarea') > ; >diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl >index 6162bc5..ab75020 100755 >--- a/installer/data/mysql/updatedatabase.pl >+++ b/installer/data/mysql/updatedatabase.pl >@@ -7154,6 +7154,7 @@ if ( CheckVersion($DBversion) ) { > SetVersion($DBversion); > } > >+<<<<<<< HEAD > $DBversion = "3.13.00.023"; > if ( CheckVersion($DBversion) ) { > $dbh->do("ALTER TABLE borrowers CHANGE password password VARCHAR(60);"); >@@ -7165,6 +7166,12 @@ $DBversion = "3.13.00.024"; > if ( CheckVersion($DBversion) ) { > $dbh->do(q{ALTER TABLE z3950servers ADD COLUMN recordtype VARCHAR(45) NOT NULL DEFAULT 'biblio' AFTER description;}); > print "Upgrade to $DBversion done (Bug 10096 - Add a Z39.50 interface for authority searching)\n"; >+} >+ >+$DBversion = "3.13.00.XXX"; >+if ( CheckVersion($DBversion) ) { >+ $dbh->do("INSERT INTO systempreferences (variable,value,options,explanation,type) VALUES('AdvancedSearchLanguages','','','ISO 639-2 codes of languages you wish to see appear as an Advanced search option. Example: eng|fra|ita','Textarea')"); >+ print "Upgrade to $DBversion done (Bug 10986: system preferences to limit languages in Advanced search )\n"; > SetVersion ($DBversion); > } > >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 29da64e..e75dac7 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 >@@ -79,6 +79,12 @@ Searching: > - "fields (separate values with |). Tabs appear in the order listed.<br/>" > - "<em>Currently supported values</em>: Item types (<strong>itemtypes</strong>), Collection Codes (<strong>ccode</strong>) and Shelving Location (<strong>loc</strong>)." > - >+ - Limit the languages listed in the advanced search drop-down to the >+ - pref: AdvancedSearchLanguages >+ class: long >+ - "ISO 639-2 language codes (separate values with | or ,)." >+ - "For example, to limit listing to French and Italian, enter <em>ita|fre</em>." >+ - > - By default, > - pref: expandedSearchOption > type: boolean >diff --git a/opac/opac-search.pl b/opac/opac-search.pl >index 2854da6..249ef39 100755 >--- a/opac/opac-search.pl >+++ b/opac/opac-search.pl >@@ -43,7 +43,7 @@ for ( $searchengine ) { > > use C4::Output; > use C4::Auth qw(:DEFAULT get_session ParseSearchHistoryCookie); >-use C4::Languages qw(getAllLanguages); >+use C4::Languages qw(getLanguages); > use C4::Search; > use C4::Biblio; # GetBiblioData > use C4::Koha; >@@ -198,7 +198,7 @@ $template->param( > ); > > # load the language limits (for search) >-my $languages_limit_loop = getAllLanguages($lang); >+my $languages_limit_loop = getLanguages($lang, 1); > $template->param(search_languages_loop => $languages_limit_loop,); > > # load the Type stuff >-- >1.7.10.4
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 10986
:
21736
|
21764
|
21856
| 22774 |
22775
|
22776
|
22777