Bugzilla – Attachment 71097 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.72 KB, created by
Jonathan Druart
on 2018-01-31 18:21:36 UTC
(
hide
)
Description:
Bug 20116: Prepare the ground
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2018-01-31 18:21:36 UTC
Size:
3.72 KB
patch
obsolete
>From 3417eff371af8ad420c1198b25e403b3b845385f 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 > >Just refactoring to make the next patch more readable >--- > C4/Languages.pm | 74 ++++++++++++++++++++++++++++++++++----------------------- > 1 file changed, 44 insertions(+), 30 deletions(-) > >diff --git a/C4/Languages.pm b/C4/Languages.pm >index 1958c91628..3693abdc96 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('opaclanguage'); >+ > 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_intranet_opac_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