From 6aed312ee357874e8b7af23bd90068b1518989b8 Mon Sep 17 00:00:00 2001 From: Bill Erickson Date: Fri, 1 Aug 2014 15:26:29 -0400 Subject: [PATCH] LP#1347774 move evergreen.get_locale_name to API Signed-off-by: Bill Erickson --- .../src/perlmods/lib/OpenILS/Application/Search.pm | 32 ++++++++++++++++++++++ Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm | 13 ++++----- 2 files changed, 37 insertions(+), 8 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm index 9ebb6da3d4..1e1db25daa 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Search.pm @@ -7,6 +7,7 @@ use OpenSRF::Utils::Logger qw(:logger); use OpenILS::Utils::Fieldmapper; use OpenILS::Utils::ModsParser; +use OpenILS::Utils::CStoreEditor qw/:funcs/; use OpenSRF::Utils::SettingsClient; use OpenSRF::Utils::Cache; @@ -119,5 +120,36 @@ sub spellcheck { } +__PACKAGE__->register_method( + method => "get_locale_name", + api_name => "open-ils.search.locale_name", + signature => { + desc => q/ + Given a locale code (e.g. en_us) returns the name and + description of the locale./, + param => [ + { + name => 'locale', + desc => 'Locale code', + type => 'string' + }, + ], + return => { + desc => q/ + Hash of "name" and "description". + Undef if the locale is not found/, + type => 'hash' + } + } +); + +sub get_locale_name { + my ($self, $client, $locale) = @_; + my $data = new_editor->json_query( + {from => ['evergreen.get_locale_name', $locale]})->[0]; + # evergreen.get_locale_name returns a hash regardless + return ($data and $data->{name}) ? $data : undef; +} + 1; diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm index 1514ad176e..d8feb9027c 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGWeb.pm @@ -10,6 +10,7 @@ use Apache2::Log; use OpenSRF::EX qw(:try); use OpenSRF::AppSession; use OpenILS::Utils::CStoreEditor (':funcs', personality => 'open-ils.prcud'); +use OpenILS::Application::AppUtils; use List::MoreUtils qw/uniq/; use constant OILS_HTTP_COOKIE_SKIN => 'eg_skin'; @@ -292,15 +293,11 @@ sub load_locale_handlers { my $tag = $locale_tags[$idx]; next if grep { $_ eq $tag } keys %registered_locales; - my $res = $editor->json_query({ - "from" => [ - "evergreen.get_locale_name", - $tag - ] - }); + my $locale = OpenILS::Application::AppUtils->simplereq( + 'open-ils.search', + 'open-ils.search.locale_name', $tag) or next; - my $locale_name = $res->[0]->{"name"} if exists $res->[0]->{"name"}; - next unless $locale_name; + my $locale_name = $locale->{name}; my $parent_tag = ''; my $sub_idx = $idx; -- 2.11.0