mirror of
https://github.com/phpbb/phpbb.git
synced 2025-06-08 04:18:52 +00:00
[ticket/15893] Pass needed language class directly to format quote
PHPBB3-15893
This commit is contained in:
parent
fc27dc02b4
commit
087bf6fd35
4 changed files with 28 additions and 15 deletions
|
@ -1762,13 +1762,14 @@ class bitfield
|
||||||
/**
|
/**
|
||||||
* Formats the quote according to the given BBCode status setting
|
* Formats the quote according to the given BBCode status setting
|
||||||
*
|
*
|
||||||
* @param bool $bbcode_status The status of the BBCode setting
|
* @param phpbb\language\language $language Language class
|
||||||
* @param array $quote_attributes The attributes of the quoted post
|
* @param parse_message $message_parser Message parser class
|
||||||
* @param phpbb\textformatter\utils $text_formatter_utils Text formatter utilities
|
* @param phpbb\textformatter\utils_interface $text_formatter_utils Text formatter utilities
|
||||||
* @param parse_message $message_parser Message parser class
|
* @param bool $bbcode_status The status of the BBCode setting
|
||||||
* @param string $message_link Link of the original quoted post
|
* @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)
|
if ($bbcode_status)
|
||||||
{
|
{
|
||||||
|
@ -1794,7 +1795,7 @@ function phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_u
|
||||||
$message = $quote_string . $message;
|
$message = $quote_string . $message;
|
||||||
$message = str_replace("\n", "\n" . $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)
|
if ($message_link)
|
||||||
|
|
|
@ -986,7 +986,11 @@ function compose_pm($id, $mode, $action, $user_folders = array())
|
||||||
$quote_attributes['post_id'] = $post['msg_id'];
|
$quote_attributes['post_id'] = $post['msg_id'];
|
||||||
}
|
}
|
||||||
|
|
||||||
phpbb_format_quote($bbcode_status, $quote_attributes, $phpbb_container->get('text_formatter.utils'), $message_parser, $message_link);
|
/** @var \phpbb\language\language $language */
|
||||||
|
$language = $phpbb_container->get('language');
|
||||||
|
/** @var \phpbb\textformatter\utils_interface $text_formatter_utils */
|
||||||
|
$text_formatter_utils = $phpbb_container->get('text_formatter.utils');
|
||||||
|
phpbb_format_quote($language, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
|
if (($action == 'reply' || $action == 'quote' || $action == 'quotepost') && !$preview && !$refresh)
|
||||||
|
|
|
@ -846,6 +846,7 @@ if ($load && ($mode == 'reply' || $mode == 'quote' || $mode == 'post') && $post_
|
||||||
load_drafts($topic_id, $forum_id);
|
load_drafts($topic_id, $forum_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @var \phpbb\textformatter\utils_interface $bbcode_utils */
|
||||||
$bbcode_utils = $phpbb_container->get('text_formatter.utils');
|
$bbcode_utils = $phpbb_container->get('text_formatter.utils');
|
||||||
|
|
||||||
if ($submit || $preview || $refresh)
|
if ($submit || $preview || $refresh)
|
||||||
|
@ -1648,7 +1649,9 @@ if ($generate_quote)
|
||||||
'user_id' => $post_data['poster_id'],
|
'user_id' => $post_data['poster_id'],
|
||||||
);
|
);
|
||||||
|
|
||||||
phpbb_format_quote($config['allow_bbcode'], $quote_attributes, $bbcode_utils, $message_parser);
|
/** @var \phpbb\language\language $language */
|
||||||
|
$language = $phpbb_container->get('language');
|
||||||
|
phpbb_format_quote($language, $message_parser, $bbcode_utils, $bbcode_status, $quote_attributes);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh)
|
if (($mode == 'reply' || $mode == 'quote') && !$submit && !$preview && !$refresh)
|
||||||
|
|
|
@ -15,13 +15,16 @@ require_once dirname(__FILE__) . '/../../phpBB/includes/message_parser.php';
|
||||||
|
|
||||||
class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
|
class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
|
||||||
{
|
{
|
||||||
|
/** @var \phpbb\language\language */
|
||||||
|
protected $lang;
|
||||||
|
|
||||||
public function setUp()
|
public function setUp()
|
||||||
{
|
{
|
||||||
global $cache, $user, $phpbb_root_path, $phpEx;
|
global $cache, $user, $phpbb_root_path, $phpEx;
|
||||||
|
|
||||||
$lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
$lang_file_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||||
$lang = new \phpbb\language\language($lang_file_loader);
|
$this->lang = new \phpbb\language\language($lang_file_loader);
|
||||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
$user = new \phpbb\user($this->lang, '\phpbb\datetime');
|
||||||
$cache = new phpbb_mock_cache();
|
$cache = new phpbb_mock_cache();
|
||||||
|
|
||||||
parent::setUp();
|
parent::setUp();
|
||||||
|
@ -30,8 +33,10 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
|
||||||
public function data_phpbb_format_quote()
|
public function data_phpbb_format_quote()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"],
|
[true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', '', "[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"],
|
||||||
[false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "admin wrote:\n> [quote="username"]quoted[/quote]\n"]
|
[false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', '', "admin wrote:\n> [quote="username"]quoted[/quote]\n"],
|
||||||
|
[true, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n", "[url=http://viewtopic.php?p=1#p1]Subject: Foo[/url]\n\n[quote=admin user_id=2][quote="username"]quoted[/quote][/quote]\n\n"],
|
||||||
|
[false, ['author' => 'admin', 'user_id' => 2], '[quote="username"]quoted[/quote]', "http://viewtopic.php?p=1#p1 - Subject: Foo\n\n", "http://viewtopic.php?p=1#p1 - Subject: Foo\n\nadmin wrote:\n> [quote="username"]quoted[/quote]\n"],
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,13 +44,13 @@ class phpbb_functions_content_phpbb_format_quote_test extends phpbb_test_case
|
||||||
/**
|
/**
|
||||||
* @dataProvider data_phpbb_format_quote
|
* @dataProvider data_phpbb_format_quote
|
||||||
*/
|
*/
|
||||||
public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $expected)
|
public function test_phpbb_format_quote($bbcode_status, $quote_attributes, $message, $message_link, $expected)
|
||||||
{
|
{
|
||||||
$text_formatter_utils = new \phpbb\textformatter\s9e\utils();
|
$text_formatter_utils = new \phpbb\textformatter\s9e\utils();
|
||||||
|
|
||||||
$message_parser = new parse_message($message);
|
$message_parser = new parse_message($message);
|
||||||
|
|
||||||
phpbb_format_quote($bbcode_status, $quote_attributes, $text_formatter_utils, $message_parser);
|
phpbb_format_quote($this->lang, $message_parser, $text_formatter_utils, $bbcode_status, $quote_attributes, $message_link);
|
||||||
|
|
||||||
$this->assertEquals($expected, $message_parser->message);
|
$this->assertEquals($expected, $message_parser->message);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue