From 285ad0f6faac275c56576616ed6a880a7f88e94b Mon Sep 17 00:00:00 2001 From: Cesar G Date: Fri, 7 Feb 2014 14:56:14 -0800 Subject: [PATCH] [ticket/11959] Simplify how the users are trimmed. PHPBB3-11959 --- phpBB/language/en/common.php | 44 ++++++++++++-------------- phpBB/phpbb/notification/type/post.php | 22 ++++--------- 2 files changed, 27 insertions(+), 39 deletions(-) diff --git a/phpBB/language/en/common.php b/phpBB/language/en/common.php index e84033f1b7..757e421759 100644 --- a/phpBB/language/en/common.php +++ b/phpBB/language/en/common.php @@ -424,41 +424,28 @@ $lang = array_merge($lang, array( 'NOT_WATCHING_FORUM' => 'You are no longer subscribed to updates on this forum.', 'NOT_WATCHING_TOPIC' => 'You are no longer subscribed to this topic.', 'NOTIFICATIONS' => 'Notifications', - // This is used for a list of up to 4 users. 5 users or more uses _TRIMMED. + // This applies for NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. + // %1$s will return a list of users that's concatenated using "," and "and" - see STRING_LIST + // Once the user count reaches 5 users or more, the list is trimmed using NOTIFICATION_X_OTHERS + // Examples: + // A replied... + // A and B replied... + // A, B and C replied... + // A, B, C and 2 others replied... 'NOTIFICATION_BOOKMARK' => array( - 1 => '%1$s replied to the topic “%3$s” you have bookmarked.', - // X, Y, and Z replied to the topic “Test” you have bookmarked. - 2 => '%1$s and %2$s replied to the topic “%3$s” you have bookmarked.', - ), - // X, Y, Z and 2 others replied to the topic “Test” you have bookmarked. - 'NOTIFICATION_BOOKMARK_TRIMMED' => array( - 2 => '%1$s and %4$d others replied to the topic “%3$s” you have bookmarked.', + 1 => '%1$s replied to the topic “%2$s” you have bookmarked.', ), 'NOTIFICATION_GROUP_REQUEST' => '%1$s is requesting to join the group %2$s.', 'NOTIFICATION_GROUP_REQUEST_APPROVED' => 'Your request to join the group %1$s has been approved.', 'NOTIFICATION_PM' => '%1$s sent you a Private Message "%2$s".', - // This is used for a list of up to 4 users. 5 users or more uses _TRIMMED. 'NOTIFICATION_POST' => array( - 1 => '%1$s replied to the topic “%3$s”.', - // X, Y, and Z replied to the topic “Test”. - 2 => '%1$s and %2$s replied to the topic “%3$s”.', - ), - // X, Y, Z and 2 others replied to the topic “Test”. - 'NOTIFICATION_POST_TRIMMED' => array( - 2 => '%1$s and %4$d others replied to the topic “%3$s”', + 1 => '%1$s replied to the topic “%2$s”.', ), 'NOTIFICATION_POST_APPROVED' => 'Your post was approved "%2$s".', 'NOTIFICATION_POST_DISAPPROVED' => 'Your post "%1$s" was disapproved for reason: "%2$s".', 'NOTIFICATION_POST_IN_QUEUE' => 'A new post titled "%2$s" was posted by %1$s and needs approval.', - // This is used for a list of up to 4 users. 5 users or more uses _TRIMMED. 'NOTIFICATION_QUOTE' => array( - 1 => '%1$s quoted you in the post “%3$s”.', - // X, Y, and Z quoted you in the post “Re: Test”. - 2 => '%1$s and %2$s quoted you in the post “%3$s”.', - ), - // X, Y, Z and 2 others quoted you in the post “Re: Test”. - 'NOTIFICATION_QUOTE_TRIMMED' => array( - 2 => '%1$s and %4$d quoted you in the post “%3$s”', + 1 => '%1$s quoted you in the post “%2$s”.', ), 'NOTIFICATION_REPORT_PM' => '%1$s reported a Private Message "%2$s" for reason: "%3$s".', 'NOTIFICATION_REPORT_POST' => '%1$s reported a post "%2$s" for reason: "%3$s".', @@ -469,6 +456,10 @@ $lang = array_merge($lang, array( 'NOTIFICATION_TOPIC_IN_QUEUE' => 'A new topic titled "%2$s" was posted by %1$s and needs approval.', 'NOTIFICATION_TYPE_NOT_EXIST' => 'The notification type "%s" is missing from the file system.', 'NOTIFICATION_ADMIN_ACTIVATE_USER' => 'The user “%1$s” is newly registered and requires activation.', + // Used in conjuction with NOTIFICATION_BOOKMARK, NOTIFICATION_POST, and NOTIFICATION_QUOTE. + 'NOTIFICATION_X_OTHERS' => array( + 2 => '%d others', + ), 'NOTIFY_ADMIN' => 'Please notify the board administrator or webmaster.', 'NOTIFY_ADMIN_EMAIL' => 'Please notify the board administrator or webmaster: %1$s', 'NO_ACCESS_ATTACHMENT' => 'You are not allowed to access this file.', @@ -692,6 +683,11 @@ $lang = array_merge($lang, array( 'START_WATCHING_TOPIC' => 'Subscribe topic', 'STOP_WATCHING_FORUM' => 'Unsubscribe forum', 'STOP_WATCHING_TOPIC' => 'Unsubscribe topic', + 'STRING_LIST' => array( + 1 => '%1$s', + 2 => '%1$s and %2$s', + // At 3 or more, %1$s returns comma separated items. So output would be: X, Y and Z + ), 'SUBFORUM' => 'Subforum', 'SUBFORUMS' => 'Subforums', 'SUBJECT' => 'Subject', diff --git a/phpBB/phpbb/notification/type/post.php b/phpBB/phpbb/notification/type/post.php index 944023cba4..62c8bd52cb 100644 --- a/phpBB/phpbb/notification/type/post.php +++ b/phpBB/phpbb/notification/type/post.php @@ -205,30 +205,22 @@ class post extends \phpbb\notification\type\base $usernames[] = $this->user_loader->get_username($responder['poster_id'], 'no_profile'); } } - $last_user = ''; - $lang_key = $this->language_key; if ($trimmed_responders_cnt) { - $lang_key .= '_TRIMMED'; - $lang_user_cnt = $trimmed_responders_cnt; + $usernames[] = $this->user->lang('NOTIFICATION_X_OTHERS', $trimmed_responders_cnt); } - else - { - $lang_user_cnt = $responders_cnt; - if ($responders_cnt > 1) - { - $last_user = array_pop($usernames); - } + if (!function_exists('phpbb_gen_string_list')) + { + include($this->phpbb_root_path . 'includes/functions_display.' . $this->php_ex); } return $this->user->lang( - $lang_key, - implode($this->user->lang['COMMA_SEPARATOR'], $usernames), - $last_user, + $this->language_key, + phpbb_gen_string_list($usernames, $this->user), censor_text($this->get_data('topic_title')), - $lang_user_cnt + $responders_cnt ); }