From ccf12bc9ab55cd091385baeb9dda317670f6786a Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Sun, 26 Apr 2009 11:45:24 -0500 Subject: [PATCH] bug 3161: don't display blank language chooser If more than one translation is installed but only one is active, a blank div is displayed at the bottom of all pages in the intranet (and in the OPAC if the opacchangelanguages system preference is ON), taking a bit of vertical real estate needlessly. Changed so that
for the language chooser is output only if there is more than one enabled language. Signed-off-by: Galen Charlton Signed-off-by: Henri-Damien LAURENT --- C4/Languages.pm | 9 +-------- C4/Output.pm | 11 +++++++++-- .../prog/en/includes/intranet-bottom.inc | 4 ++-- koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc | 4 ++-- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/C4/Languages.pm b/C4/Languages.pm index 7c3503c637..5795202a7e 100644 --- a/C4/Languages.pm +++ b/C4/Languages.pm @@ -108,7 +108,6 @@ sub getTranslatedLanguages { my $htdocs; my $all_languages = getAllLanguages(); my @languages; - my $lang; my @enabled_languages; if ($interface && $interface eq 'opac' ) { @@ -116,13 +115,11 @@ sub getTranslatedLanguages { $htdocs = C4::Context->config('opachtdocs'); if ( $theme and -d "$htdocs/$theme" ) { (@languages) = _get_language_dirs($htdocs,$theme); - return _build_languages_arrayref($all_languages,\@languages,$current_language,\@enabled_languages); } else { for my $theme ( _get_themes('opac') ) { push @languages, _get_language_dirs($htdocs,$theme); } - return _build_languages_arrayref($all_languages,\@languages,$current_language,\@enabled_languages); } } elsif ($interface && $interface eq 'intranet' ) { @@ -130,13 +127,11 @@ sub getTranslatedLanguages { $htdocs = C4::Context->config('intrahtdocs'); if ( $theme and -d "$htdocs/$theme" ) { @languages = _get_language_dirs($htdocs,$theme); - return _build_languages_arrayref($all_languages,\@languages,$current_language,\@enabled_languages); } else { foreach my $theme ( _get_themes('intranet') ) { push @languages, _get_language_dirs($htdocs,$theme); } - return _build_languages_arrayref($all_languages,\@languages,$current_language,\@enabled_languages); } } else { @@ -152,8 +147,8 @@ sub getTranslatedLanguages { my %seen; $seen{$_}++ for @languages; @languages = keys %seen; - return _build_languages_arrayref($all_languages,\@languages,$current_language,\@enabled_languages); } + return _build_languages_arrayref($all_languages,\@languages,$current_language,\@enabled_languages); } =head2 getAllLanguages @@ -273,7 +268,6 @@ sub _build_languages_arrayref { my @languages_loop; # the final reference to an array of hashrefs my @enabled_languages = @$enabled_languages; # how many languages are enabled, if one, take note, some contexts won't need to display it - my $one_language_enabled = 1 unless @enabled_languages > 1; my %seen_languages; # the language tags we've seen my %found_languages; my $language_groups; @@ -318,7 +312,6 @@ sub _build_languages_arrayref { plural => $track_language_groups->{$key} >1 ? 1 : 0, current => $current_language_regex->{language} eq $key ? 1 : 0, group_enabled => $enabled, - one_language_enabled => $one_language_enabled, }; } return \@languages_loop; diff --git a/C4/Output.pm b/C4/Output.pm index fd32541a02..c8404dc05b 100644 --- a/C4/Output.pm +++ b/C4/Output.pm @@ -115,9 +115,16 @@ sub gettemplate { $bidi = get_bidi($current_lang->{script}) if $current_lang->{script}; # Languages my $languages_loop = getTranslatedLanguages($interface,$theme,$lang); + my $num_languages_enabled = 0; + foreach my $lang (@$languages_loop) { + foreach my $sublang (@{ $lang->{'sublanguages_loop'} }) { + $num_languages_enabled++ if $sublang->{enabled}; + } + } $template->param( - languages_loop => $languages_loop, - bidi => $bidi + languages_loop => $languages_loop, + bidi => $bidi, + one_language_enabled => ($num_languages_enabled <= 1) ? 1 : 0, # deal with zero enabled langs as well ) unless @$languages_loop<2; return $template; diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc index a6a2b070d3..78334b202d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/intranet-bottom.inc @@ -1,6 +1,7 @@
+
-
  • @@ -30,11 +30,11 @@ - + diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc b/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc index e4551c083c..6568c8c527 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/opac-bottom.inc @@ -7,6 +7,7 @@ +
    Languages: @@ -28,7 +29,6 @@
    - @@ -37,10 +37,10 @@ - | + -- 2.39.5