Bugzilla – Attachment 38603 Details for
Bug 14063
Implement language overlay for authorised values
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14063 - Implement language overlay for authorised values
Bug-14063---Implement-language-overlay-for-authori.patch (text/plain), 4.10 KB, created by
Mirko Tietgen
on 2015-04-28 12:14:21 UTC
(
hide
)
Description:
Bug 14063 - Implement language overlay for authorised values
Filename:
MIME Type:
Creator:
Mirko Tietgen
Created:
2015-04-28 12:14:21 UTC
Size:
4.10 KB
patch
obsolete
>From a4f5c93a1b57268f985cc04ba1997730de83a8cd Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Marc=20V=C3=A9ron?= <veron@veron.ch> >Date: Sun, 26 Apr 2015 07:04:03 +0200 >Subject: [PATCH] Bug 14063 - Implement language overlay for authorised values >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >This patch implements a language overlay for authorised values. > >To prepare tests >- Have an installation with e.g. English, French and German languages >- Set syspref 'suggestion' to: [Allow] patrons to make purchase suggestions on the OPAC. >- Verify that you have a authorised values for OPAC_SUG (bestseller, damaged) > >- Open OPAC, log in, go to Purchase suggestions > Create a new suggesion >- The dropdown "Reason for suggestion:" shows the authorised values from OPAC_SUG, e.g. "The copy on the shelf is damaged" and "Upcoming title by popular author" >- Select German >- The dropdown "Begründung" shows the same (English) values. >- Same with French > >- Open Intranet (Staff client) >- Go to Home > Acquisitions > Suggestions management > New purchase suggestion >- Switch between languages, the dropdown "Reason for suggestion" changes the label, but the values are not ranslated. >- Same with the detail view of a suggestion > >To test: >- In Staff client, go to Home > Administration > Authorized values >- Add a new category OPAC_SUG-de-DE (add language code) >- Create new translated values 'bestseller' and 'damaged' for this category. >- Do the same for French (OPAC_SUG-fr-FR) or other installed languages >- Go to OPAC > Purchase suggestions > Create a new suggesion >- Switch between languages, the values in the dropdown 'Reason' should display in selected language >- Got to Staff client > Home > Acquisitions > Suggestions management > New purchase suggestion >- Switch between languages and verify that the values in the dropdown 'Reason' display in selected language >- Display a suggestion's detail view, switch languages. Text for 'Reason' should change as appropriate. > >Bonus test: >- Create language overlays e.g. for category 'DAMAGED' (DAMAGED-de-DE and DAMAGED-fr-FR), authorised values 0 -> 'No' and 1 -> 'Damaged' > >Signed-off-by: Mirko Tietgen <mirko@abunchofthings.net> >--- > C4/Koha.pm | 20 +++++++++++++++++++- > 1 file changed, 19 insertions(+), 1 deletion(-) > >diff --git a/C4/Koha.pm b/C4/Koha.pm >index 23fbfee..e8929d3 100644 >--- a/C4/Koha.pm >+++ b/C4/Koha.pm >@@ -1151,6 +1151,8 @@ sub GetAuthorisedValues { > return $result if $result; > > my @results; >+ my $lang_results_hash; >+ my $language = C4::Languages::getlanguage(); > my $dbh = C4::Context->dbh; > my $query = qq{ > SELECT * >@@ -1161,13 +1163,16 @@ sub GetAuthorisedValues { > } if $branch_limit; > my @where_strings; > my @where_args; >+ my @where_args_lang; > if($category) { > push @where_strings, "category = ?"; > push @where_args, $category; >+ push @where_args_lang, $category.'-'.$language; > } > if($branch_limit) { > push @where_strings, "( branchcode = ? OR branchcode IS NULL )"; > push @where_args, $branch_limit; >+ push @where_args_lang, $branch_limit; > } > if(@where_strings > 0) { > $query .= " WHERE " . join(" AND ", @where_strings); >@@ -1178,10 +1183,23 @@ sub GetAuthorisedValues { > : 'lib, lib_opac' > ); > >- my $sth = $dbh->prepare($query); >+ # Prepare language overlay >+ my $sth_lang = $dbh->prepare($query); >+ $sth_lang->execute( @where_args_lang ); >+ while (my $data_lang=$sth_lang->fetchrow_hashref) { >+ $lang_results_hash->{$data_lang->{authorised_value}}= $data_lang; >+ } >+ $sth_lang->finish; > >+ # Get original values and overlay them if appropriate >+ my $sth = $dbh->prepare($query); > $sth->execute( @where_args ); > while (my $data=$sth->fetchrow_hashref) { >+ #Do language overlay >+ if (defined $lang_results_hash->{$data->{authorised_value}} ){ >+ $data = $lang_results_hash->{$data->{authorised_value}}; >+ } >+ > if ( defined $selected and $selected eq $data->{authorised_value} ) { > $data->{selected} = 1; > } >-- >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 14063
:
38519
|
38595
| 38603