From 2b30e632b6e266ef64d075ac0897972a8bb43bf1 Mon Sep 17 00:00:00 2001 From: Oliver Schramm Date: Thu, 28 May 2015 15:45:47 +0200 Subject: [PATCH] [ticket/12143] Add is_set method to language service We need that. PHPBB3-12143 --- phpBB/phpbb/language/language.php | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/phpBB/phpbb/language/language.php b/phpBB/phpbb/language/language.php index 44131e3da3..3ffb466c19 100644 --- a/phpBB/phpbb/language/language.php +++ b/phpBB/phpbb/language/language.php @@ -193,6 +193,36 @@ class language } } + /** + * @param $key array|string The language key we want to know more about. Can be string or array. + * + * @return bool Returns whether the language key is set. + */ + public function is_set($key) + { + // Load common language files if they not loaded yet + if (!$this->common_language_files_loaded) + { + $this->load_common_language_files(); + } + + if (is_array($key)) + { + $lang = &$this->lang[array_shift($key)]; + + foreach ($key as $_key) + { + $lang = &$lang[$_key]; + } + } + else + { + $lang = &$this->lang[$key]; + } + + return isset($lang); + } + /** * Advanced language substitution *