From f8fbe3793680af1dae2db2829cfc84068831c52f Mon Sep 17 00:00:00 2001 From: rxu Date: Wed, 28 Jun 2017 00:58:03 +0700 Subject: [ticket/14972] replace all occurrences of sizeof() with the count() PHPBB3-14972 --- phpBB/includes/functions_content.php | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 06223027d8..40d44cfe7b 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -336,7 +336,7 @@ function get_context($text, $words, $length = 400) $text = str_replace($entities, $characters, $text); $word_indizes = array(); - if (sizeof($words)) + if (count($words)) { $match = ''; // find the starting indizes of all words @@ -361,12 +361,12 @@ function get_context($text, $words, $length = 400) } unset($match); - if (sizeof($word_indizes)) + if (count($word_indizes)) { $word_indizes = array_unique($word_indizes); sort($word_indizes); - $wordnum = sizeof($word_indizes); + $wordnum = count($word_indizes); // number of characters on the right and left side of each word $sequence_length = (int) ($length / (2 * $wordnum)) - 2; $final_text = ''; @@ -434,7 +434,7 @@ function get_context($text, $words, $length = 400) } } - if (!sizeof($words) || !sizeof($word_indizes)) + if (!count($words) || !count($word_indizes)) { return str_replace($characters, $entities, ((utf8_strlen($text) >= $length + 3) ? utf8_substr($text, 0, $length) . '...' : $text)); } @@ -1021,7 +1021,7 @@ function censor_text($text) } } - if (sizeof($censors)) + if (count($censors)) { return preg_replace($censors['match'], $censors['replace'], $text); } @@ -1079,7 +1079,7 @@ function smiley_text($text, $force_option = false) */ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_ary, $preview = false) { - if (!sizeof($attachments)) + if (!count($attachments)) { return; } @@ -1114,7 +1114,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a } // Grab attachments (security precaution) - if (sizeof($attach_ids)) + if (count($attach_ids)) { global $db; @@ -1151,7 +1151,7 @@ function parse_attachments($forum_id, &$message, &$attachments, &$update_count_a foreach ($attachments as $attachment) { - if (!sizeof($attachment)) + if (!count($attachment)) { continue; } @@ -1443,7 +1443,7 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al $chars = array_map('utf8_htmlspecialchars', $_chars); // Now check the length ;) - if (sizeof($chars) > $max_length) + if (count($chars) > $max_length) { // Cut off the last elements from the array $string = implode('', array_slice($chars, 0, $max_length - utf8_strlen($append))); @@ -1651,7 +1651,7 @@ function phpbb_generate_string_list($items, $user) return ''; } - $count = sizeof($items); + $count = count($items); $last_item = array_pop($items); $lang_key = 'STRING_LIST_MULTI'; -- cgit v1.2.1 From 184d24bb166b754b571bd7ef49b7cfacf1c8381d Mon Sep 17 00:00:00 2001 From: MikelAlejoBR Date: Tue, 31 Jul 2018 16:06:49 +0200 Subject: [ticket/15622] Extract duplicated code PHPBB3-15622 --- phpBB/includes/functions_content.php | 52 ++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 40d44cfe7b..aee90aab99 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1758,3 +1758,55 @@ class bitfield $this->data = $this->data | $bitfield->get_blob(); } } + +/** + * Formats the quote according to the given BBCode status setting + * + * @param bool $bbcode_status The status of the BBCode setting + * @param array $quote_attributes The attributes of the quoted post + * @param phpbb\textformatter\utils $text_formatter_utils Text formatter utilities + * @param parse_message $message_parser Message parser class + * @param string $message_link Link of the original quoted post + * @since 3.2.4-RC1 + */ +function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser, $message_link = '') +{ + if ($bbcode_status) + { + $quote_text = $text_formatter_utils->generate_quote( + censor_text($message_parser->message), + $quote_attributes + ); + + if($message_link) + { + $message_parser->message = $message_link . $quote_text . "\n\n"; + } + else + { + $message_parser->message = $quote_text . "\n\n"; + } + } + else + { + $offset = 0; + $quote_string = "> "; + $message = censor_text(trim($message_parser->message)); + // see if we are nesting. It's easily tricked but should work for one level of nesting + if (strpos($message, ">") !== false) + { + $offset = 10; + } + $message = utf8_wordwrap($message, 75 + $offset, "\n"); + + $message = $quote_string . $message; + $message = str_replace("\n", "\n" . $quote_string, $message); + + $message_parser->message = $quote_attributes['author'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; + + if($message_link) + { + $message_parser->message = $message_link . $message_parser->message; + } + } +} -- cgit v1.2.1 From 521aec5923874f8757592a07e09357b323460b00 Mon Sep 17 00:00:00 2001 From: MikelAlejoBR Date: Wed, 1 Aug 2018 17:37:21 +0200 Subject: [ticket/15622] Correct code style PHPBB3-15622 --- phpBB/includes/functions_content.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index aee90aab99..1bc217b694 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1778,7 +1778,7 @@ function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $quote_attributes ); - if($message_link) + if ($message_link) { $message_parser->message = $message_link . $quote_text . "\n\n"; } @@ -1804,7 +1804,7 @@ function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser->message = $quote_attributes['author'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; - if($message_link) + if ($message_link) { $message_parser->message = $message_link . $message_parser->message; } -- cgit v1.2.1 From ada8bc9da2790eeb600d61222b23ffdb5f025bf6 Mon Sep 17 00:00:00 2001 From: MikelAlejoBR Date: Wed, 1 Aug 2018 18:01:37 +0200 Subject: [ticket/15622] Refactor message link concatenation PHPBB3-15622 --- phpBB/includes/functions_content.php | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 1bc217b694..1e80da98d3 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1778,14 +1778,7 @@ function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $quote_attributes ); - if ($message_link) - { - $message_parser->message = $message_link . $quote_text . "\n\n"; - } - else - { - $message_parser->message = $quote_text . "\n\n"; - } + $message_parser->message = $quote_text . "\n\n"; } else { @@ -1803,10 +1796,10 @@ function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message = str_replace("\n", "\n" . $quote_string, $message); $message_parser->message = $quote_attributes['author'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; + } - if ($message_link) - { - $message_parser->message = $message_link . $message_parser->message; - } + if ($message_link) + { + $message_parser->message = $message_link . $message_parser->message; } } -- cgit v1.2.1 From e17f00fb6b482c71f3ed42786b6f413373a61b9b Mon Sep 17 00:00:00 2001 From: MikelAlejoBR Date: Sun, 16 Sep 2018 18:59:35 +0200 Subject: [ticket/15622] Remove "since" tag as it belongs to events PHPBB3-15622 --- phpBB/includes/functions_content.php | 1 - 1 file changed, 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 1e80da98d3..ed35f5213f 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1767,7 +1767,6 @@ class bitfield * @param phpbb\textformatter\utils $text_formatter_utils Text formatter utilities * @param parse_message $message_parser Message parser class * @param string $message_link Link of the original quoted post - * @since 3.2.4-RC1 */ function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser, $message_link = '') { -- cgit v1.2.1 From 4396bfba65b0c69023b47b564f789700f892e05a Mon Sep 17 00:00:00 2001 From: MikelAlejoBR Date: Sun, 16 Sep 2018 19:00:51 +0200 Subject: [ticket/15622] Rename function to avoid potential future conflicts PHPBB3-15622 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index ed35f5213f..e124bd46e6 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1768,7 +1768,7 @@ class bitfield * @param parse_message $message_parser Message parser class * @param string $message_link Link of the original quoted post */ -function format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser, $message_link = '') +function phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser, $message_link = '') { if ($bbcode_status) { -- cgit v1.2.1 From b148bb5d707d739e92b66205866a764a9aa133b5 Mon Sep 17 00:00:00 2001 From: Ruben Calvo Date: Sun, 21 Oct 2018 05:56:29 +0000 Subject: [ticket/15849] Stop using php4 constructors PHPBB3-15849 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index e124bd46e6..43dce036a3 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1672,7 +1672,7 @@ class bitfield { var $data; - function bitfield($bitfield = '') + function __construct($bitfield = '') { $this->data = base64_decode($bitfield); } -- cgit v1.2.1 From da9da88d11f1d62105268def24ae70c0e64bb840 Mon Sep 17 00:00:00 2001 From: rxu Date: Sun, 18 Nov 2018 01:33:56 +0700 Subject: [ticket/15875] Fix PHP fatal error on BBCode parsing PHPBB3-15875 --- phpBB/includes/functions_content.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 43dce036a3..8284aab6a4 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -627,7 +627,7 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text } else { - $bbcode->bbcode($bitfield); + $bbcode->bbcode_set_bitfield($bitfield); } $bbcode->bbcode_second_pass($text, $uid); -- cgit v1.2.1 From 087bf6fd35913152129eed97005953ac3979002a Mon Sep 17 00:00:00 2001 From: Marc Alexander Date: Sun, 2 Dec 2018 12:55:02 +0100 Subject: [ticket/15893] Pass needed language class directly to format quote PHPBB3-15893 --- phpBB/includes/functions_content.php | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 8284aab6a4..a15a03f966 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1762,13 +1762,14 @@ class bitfield /** * Formats the quote according to the given BBCode status setting * - * @param bool $bbcode_status The status of the BBCode setting - * @param array $quote_attributes The attributes of the quoted post - * @param phpbb\textformatter\utils $text_formatter_utils Text formatter utilities - * @param parse_message $message_parser Message parser class - * @param string $message_link Link of the original quoted post + * @param phpbb\language\language $language Language class + * @param parse_message $message_parser Message parser class + * @param phpbb\textformatter\utils_interface $text_formatter_utils Text formatter utilities + * @param bool $bbcode_status The status of the BBCode setting + * @param array $quote_attributes The attributes of the quoted post + * @param string $message_link Link of the original quoted post */ -function phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser, $message_link = '') +function phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link = '') { if ($bbcode_status) { @@ -1794,7 +1795,7 @@ function phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_u $message = $quote_string . $message; $message = str_replace("\n", "\n" . $quote_string, $message); - $message_parser->message = $quote_attributes['author'] . " " . $user->lang['WROTE'] . ":\n" . $message . "\n"; + $message_parser->message = $quote_attributes['author'] . " " . $language->lang('WROTE') . ":\n" . $message . "\n"; } if ($message_link) -- cgit v1.2.1 From 479201a3a1b821d2b3212000955fad1343f4efd0 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sat, 9 Mar 2019 10:30:19 +0100 Subject: [ticket/15886] Add @html doc for group/user strings PHPBB3-15886 --- phpBB/includes/functions_content.php | 1 + 1 file changed, 1 insertion(+) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index 8284aab6a4..e83a9ec195 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1501,6 +1501,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', { global $phpbb_root_path, $phpEx; + /** @html User name strings for usage in the template */ $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); $_profile_cache['tpl_noprofile'] = '{USERNAME}'; $_profile_cache['tpl_noprofile_colour'] = '{USERNAME}'; -- cgit v1.2.1 From 45e1aff14a149a652924e77cd404e39b2e5aacb5 Mon Sep 17 00:00:00 2001 From: mrgoldy Date: Sun, 10 Mar 2019 17:44:03 +0100 Subject: [ticket/15886] Appropriate HTML docs PHPBB3-15886 --- phpBB/includes/functions_content.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'phpBB/includes/functions_content.php') diff --git a/phpBB/includes/functions_content.php b/phpBB/includes/functions_content.php index e83a9ec195..1840416efc 100644 --- a/phpBB/includes/functions_content.php +++ b/phpBB/includes/functions_content.php @@ -1482,6 +1482,8 @@ function truncate_string($string, $max_length = 60, $max_store_length = 255, $al * Get username details for placing into templates. * This function caches all modes on first call, except for no_profile and anonymous user - determined by $user_id. * +* @html Username spans and links +* * @param string $mode Can be profile (for getting an url to the profile), username (for obtaining the username), colour (for obtaining the user colour), full (for obtaining a html string representing a coloured link to the users profile) or no_profile (the same as full but forcing no profile link) * @param int $user_id The users id * @param string $username The users name @@ -1501,7 +1503,7 @@ function get_username_string($mode, $user_id, $username, $username_colour = '', { global $phpbb_root_path, $phpEx; - /** @html User name strings for usage in the template */ + /** @html Username spans and links for usage in the template */ $_profile_cache['base_url'] = append_sid("{$phpbb_root_path}memberlist.$phpEx", 'mode=viewprofile&u={USER_ID}'); $_profile_cache['tpl_noprofile'] = '{USERNAME}'; $_profile_cache['tpl_noprofile_colour'] = '{USERNAME}'; -- cgit v1.2.1