Bugzilla – Attachment 103007 Details for
Bug 20116
Improve performance by caching the language list
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 20116: Prepare the ground
Bug-20116-Prepare-the-ground.patch (text/plain), 3.91 KB, created by
Marcel de Rooy
on 2020-04-15 14:00:47 UTC
(
hide
)
Description:
Bug 20116: Prepare the ground
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2020-04-15 14:00:47 UTC
Size:
3.91 KB
patch
obsolete
>From cd6160949e30eb4b6a73ebfdf57743475c56616e Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 31 Jan 2018 14:36:22 -0300 >Subject: [PATCH] Bug 20116: Prepare the ground >Content-Type: text/plain; charset=utf-8 > >Just refactoring to make the next patch more readable > >Signed-off-by: Liz Rea <wizzyrea@gmail.com> >Signed-off-by: Bouzid Fergani <bouzid.fergani@inlibro.com> > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > C4/Languages.pm | 74 ++++++++++++++++++++++++++++++++++----------------------- > 1 file changed, 44 insertions(+), 30 deletions(-) > >diff --git a/C4/Languages.pm b/C4/Languages.pm >index 31d17ba73b..0916dd4610 100644 >--- a/C4/Languages.pm >+++ b/C4/Languages.pm >@@ -111,44 +111,27 @@ Returns a reference to an array of hashes: > > sub getTranslatedLanguages { > my ($interface, $theme, $current_language, $which) = @_; >- my $htdocs; > my @languages; >- my @enabled_languages; >- >+ my @enabled_languages = >+ ( $interface && $interface eq 'intranet' ) >+ ? split ",", C4::Context->preference('language') >+ : split ",", C4::Context->preference('opaclanguages'); >+ > if ($interface && $interface eq 'opac' ) { >- @enabled_languages = split ",", C4::Context->preference('opaclanguages'); >- $htdocs = C4::Context->config('opachtdocs'); >- if ( $theme and -d "$htdocs/$theme" ) { >- (@languages) = _get_language_dirs($htdocs,$theme); >- } >- else { >- for my $theme ( _get_themes('opac') ) { >- push @languages, _get_language_dirs($htdocs,$theme); >- } >- } >+ my $htdocs = C4::Context->config('opachtdocs'); >+ @languages = _get_opac_language_dirs( $htdocs, $theme ); > } > elsif ($interface && $interface eq 'intranet' ) { >- @enabled_languages = split ",", C4::Context->preference('language'); >- $htdocs = C4::Context->config('intrahtdocs'); >- if ( $theme and -d "$htdocs/$theme" ) { >- @languages = _get_language_dirs($htdocs,$theme); >- } >- else { >- foreach my $theme ( _get_themes('intranet') ) { >- push @languages, _get_language_dirs($htdocs,$theme); >- } >- } >+ my $htdocs = C4::Context->config('intrahtdocs'); >+ @languages = _get_intranet_language_dirs( $htdocs, $theme ); > } > else { >- @enabled_languages = split ",", C4::Context->preference('opaclanguages'); > my $htdocs = C4::Context->config('intrahtdocs'); >- foreach my $theme ( _get_themes('intranet') ) { >- push @languages, _get_language_dirs($htdocs,$theme); >- } >+ push @languages, _get_intranet_language_dirs( $htdocs ); >+ > $htdocs = C4::Context->config('opachtdocs'); >- foreach my $theme ( _get_themes('opac') ) { >- push @languages, _get_language_dirs($htdocs,$theme); >- } >+ push @languages, _get_opac_language_dirs( $htdocs ); >+ > my %seen; > $seen{$_}++ for @languages; > @languages = keys %seen; >@@ -246,6 +229,37 @@ sub getLanguages { > return \@languages_loop; > } > >+sub _get_opac_language_dirs { >+ my ( $htdocs, $theme ) = @_; >+ >+ my @languages; >+ if ( $theme and -d "$htdocs/$theme" ) { >+ (@languages) = _get_language_dirs($htdocs,$theme); >+ } >+ else { >+ for my $theme ( _get_themes('opac') ) { >+ push @languages, _get_language_dirs($htdocs,$theme); >+ } >+ } >+ return @languages; >+} >+ >+ >+sub _get_intranet_language_dirs { >+ my ( $htdocs, $theme ) = @_; >+ >+ my @languages; >+ if ( $theme and -d "$htdocs/$theme" ) { >+ @languages = _get_language_dirs($htdocs,$theme); >+ } >+ else { >+ foreach my $theme ( _get_themes('intranet') ) { >+ push @languages, _get_language_dirs($htdocs,$theme); >+ } >+ } >+ return @languages; >+} >+ > =head2 _get_themes > > Internal function, returns an array of all available themes. >-- >2.11.0
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 20116
:
71097
|
71098
|
73521
|
73619
|
73620
|
75382
|
75383
|
75384
|
75385
|
88200
|
88201
|
88202
|
94995
|
94996
|
94997
|
99431
|
99432
|
99433
| 103007 |
103008
|
103009
|
105359