From b893dae105f72b7c34abe855e24f0dec35206208 Mon Sep 17 00:00:00 2001 From: Cesar G Date: Sat, 29 Mar 2014 09:29:47 -0700 Subject: [ticket/11959] Move phpbb_generate_string_list() to functions_content.php. PHPBB3-11959 --- phpBB/includes/functions_content.php | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 8122b87e4b..dd9201165b 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1414,6 +1414,38 @@ function phpbb_add_quickmod_option($option, $lang_string) )); } +/** +* Concatenate an array into a string list. +* +* @param array $items Array of items to concatenate +* @param object $user The phpBB $user object. +* +* @return string String list. Examples: "A"; "A and B"; "A, B, and C" +*/ +function phpbb_generate_string_list($items, $user) +{ + if (empty($items)) + { + return ''; + } + + $count = sizeof($items); + $last_item = array_pop($items); + $lang_key = 'STRING_LIST_MULTI'; + + if ($count == 1) + { + return $last_item; + } + else if ($count == 2) + { + $lang_key = 'STRING_LIST_SIMPLE'; + } + $list = implode($user->lang['COMMA_SEPARATOR'], $items); + + return $user->lang($lang_key, $list, $last_item); +} + /** * @package phpBB3 */ -- cgit v1.2.1