From 4123cc6b10055a94efd7f5fff172ea4f2c0e67b3 Mon Sep 17 00:00:00 2001 From: etc Date: Sat, 30 May 2020 22:24:01 +0200 Subject: [PATCH] Restore, just in case --- textpattern/lib/txplib_admin.php | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/textpattern/lib/txplib_admin.php b/textpattern/lib/txplib_admin.php index 861c0db828..08524bf6fa 100644 --- a/textpattern/lib/txplib_admin.php +++ b/textpattern/lib/txplib_admin.php @@ -1689,6 +1689,42 @@ function load_lang_dates($lang) return false; } +/** + * Gets language strings for the given event. + * + * If no $lang is specified, the strings are loaded from the currently + * active language. + * + * @param string $event The event to get, e.g. "common", "admin", "public" + * @param string $lang The language code + * @return array|string Array of string on success, or an empty string when no strings were found + * @package L10n + * @see load_lang() + * @example + * print_r( + * load_lang_event('common') + * ); + */ + +function load_lang_event($event, $lang = LANG) +{ + $installed = (false !== safe_field("name", 'txp_lang', "lang = '".doSlash($lang)."' LIMIT 1")); + + $lang_code = ($installed) ? $lang : TEXTPATTERN_DEFAULT_LANG; + + $rs = safe_rows_start("name, data", 'txp_lang', "lang = '".doSlash($lang_code)."' AND event = '".doSlash($event)."'"); + + $out = array(); + + if ($rs && !empty($rs)) { + while ($a = nextRow($rs)) { + $out[$a['name']] = $a['data']; + } + } + + return ($out) ? $out : ''; +} + /** * Installs localisation strings from a Textpack. *