diff options
| author | Oliver Schramm <oliver.schramm97@gmail.com> | 2017-09-28 20:02:15 +0200 | 
|---|---|---|
| committer | Oliver Schramm <oliver.schramm97@gmail.com> | 2017-09-28 20:02:50 +0200 | 
| commit | 3da67ce581d35f53b1b7e0ef7bce10f9261f8c6c (patch) | |
| tree | 4f874e21a176ff60d742ef8dbd45584939fc7d7b /phpBB/phpbb | |
| parent | 4a7ead0239179d4257c074b755cd4a5f765a513b (diff) | |
| download | forums-3da67ce581d35f53b1b7e0ef7bce10f9261f8c6c.tar forums-3da67ce581d35f53b1b7e0ef7bce10f9261f8c6c.tar.gz forums-3da67ce581d35f53b1b7e0ef7bce10f9261f8c6c.tar.bz2 forums-3da67ce581d35f53b1b7e0ef7bce10f9261f8c6c.tar.xz forums-3da67ce581d35f53b1b7e0ef7bce10f9261f8c6c.zip | |
[ticket/15245] Configure TextFormatter before rendering feeds
PHPBB3-15245
Diffstat (limited to 'phpBB/phpbb')
| -rw-r--r-- | phpBB/phpbb/feed/feed_quote_helper.php | 35 | ||||
| -rw-r--r-- | phpBB/phpbb/feed/helper.php | 25 | 
2 files changed, 48 insertions, 12 deletions
| diff --git a/phpBB/phpbb/feed/feed_quote_helper.php b/phpBB/phpbb/feed/feed_quote_helper.php new file mode 100644 index 0000000000..02a9b35dc0 --- /dev/null +++ b/phpBB/phpbb/feed/feed_quote_helper.php @@ -0,0 +1,35 @@ +<?php +/** + * + * This file is part of the phpBB Forum Software package. + * + * @copyright (c) phpBB Limited <https://www.phpbb.com> + * @license GNU General Public License, version 2 (GPL-2.0) + * + * For full copyright and license information, please see + * the docs/CREDITS.txt file. + * + */ + +namespace phpbb\feed; + +/** + * Modified quote_helper for feeds (basically just removing all attributes) + */ +class feed_quote_helper extends \phpbb\textformatter\s9e\quote_helper +{ +	/** +	 * {@inheritdoc} +	 */ +	public function inject_metadata($xml) +	{ +		// In feeds we don't want any attributes, so delete all of them +		return \s9e\TextFormatter\Utils::replaceAttributes( +			$xml, +			'QUOTE', +			function () { +				return []; +			} +		); +	} +} diff --git a/phpBB/phpbb/feed/helper.php b/phpBB/phpbb/feed/helper.php index 3bca8598a5..df7388331c 100644 --- a/phpBB/phpbb/feed/helper.php +++ b/phpBB/phpbb/feed/helper.php @@ -24,20 +24,25 @@ class helper  	/** @var \phpbb\path_helper */  	protected $path_helper; +	/** @var \phpbb\textformatter\s9e\renderer */ +	protected $renderer; +  	/** @var \phpbb\user */  	protected $user;  	/**  	 * Constructor  	 * -	 * @param	\phpbb\config\config	$config			Config object -	 * @param	\phpbb\path_helper		$path_helper 	Path helper object -	 * @param	\phpbb\user				$user			User object +	 * @param	\phpbb\config\config				$config			Config object +	 * @param	\phpbb\path_helper					$path_helper 	Path helper object +	 * @param	\phpbb\textformatter\s9e\renderer	$renderer		TextFormatter renderer object +	 * @param	\phpbb\user							$user			User object  	 */ -	public function __construct(\phpbb\config\config $config, \phpbb\path_helper $path_helper, \phpbb\user $user) +	public function __construct(\phpbb\config\config $config, \phpbb\path_helper $path_helper, \phpbb\textformatter\s9e\renderer $renderer, \phpbb\user $user)  	{  		$this->config = $config;  		$this->path_helper = $path_helper; +		$this->renderer = $renderer;  		$this->user = $user;  	} @@ -99,16 +104,12 @@ class helper  			return '';  		} -		// Prepare some bbcodes for better parsing -		$content = preg_replace("#\[quote(=".*?")?:$uid\]\s*(.*?)\s*\[/quote:$uid\]#si", "[quote$1:$uid]<br />$2<br />[/quote:$uid]", $content); - -		$content = generate_text_for_display($content, $uid, $bitfield, $options); +		// Setup our own quote_helper to remove all attributes from quotes +		$this->renderer->configure_quote_helper(new feed_quote_helper($this->user, $this->path_helper->get_phpbb_root_path(), $this->path_helper->get_php_ext())); -		// Add newlines -		$content = str_replace('<br />', '<br />' . "\n", $content); +		$this->renderer->set_smilies_path($this->get_board_url() . '/' . $this->config['smilies_path']); -		// Convert smiley Relative paths to Absolute path, Windows style -		$content = str_replace($this->path_helper->get_web_root_path() . $this->config['smilies_path'], $this->get_board_url() . '/' . $this->config['smilies_path'], $content); +		$content = generate_text_for_display($content, $uid, $bitfield, $options);  		// Remove "Select all" link and mouse events  		$content = str_replace('<a href="#" onclick="selectCode(this); return false;">' . $this->user->lang['SELECT_ALL_CODE'] . '</a>', '', $content); | 
