phpBB

Code Changes

File: phpbb/textformatter/s9e/factory.php

  Unmodified   Added   Modified   Removed
Line 78Line 78
		'b'     => '[B]{TEXT}[/B]',
'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]',
'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]',

		'b'     => '[B]{TEXT}[/B]',
'code' => '[CODE lang={IDENTIFIER;optional}]{TEXT}[/CODE]',
'color' => '[COLOR={COLOR}]{TEXT}[/COLOR]',

		'email' => '[EMAIL={EMAIL;useContent} subject={TEXT;optional;postFilter=rawurlencode} body={TEXT;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]',

		'email' => '[EMAIL={EMAIL;useContent} subject={TEXT1;optional;postFilter=rawurlencode} body={TEXT2;optional;postFilter=rawurlencode}]{TEXT}[/EMAIL]',

		'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]',
'i' => '[I]{TEXT}[/I]',
'img' => '[IMG src={IMAGEURL;useContent}]',

		'flash' => '[FLASH={NUMBER1},{NUMBER2} width={NUMBER1;postFilter=#flashwidth} height={NUMBER2;postFilter=#flashheight} url={URL;useContent} /]',
'i' => '[I]{TEXT}[/I]',
'img' => '[IMG src={IMAGEURL;useContent}]',

Line 130Line 130
	* @var \phpbb\event\dispatcher_interface
*/
protected $dispatcher;

	* @var \phpbb\event\dispatcher_interface
*/
protected $dispatcher;

 

/**
* @var \phpbb\log\log_interface
*/
protected $log;


/**
* Constructor


/**
* Constructor

Line 139Line 144
	* @param \phpbb\event\dispatcher_interface $dispatcher
* @param \phpbb\config\config $config
* @param \phpbb\textformatter\s9e\link_helper $link_helper

	* @param \phpbb\event\dispatcher_interface $dispatcher
* @param \phpbb\config\config $config
* @param \phpbb\textformatter\s9e\link_helper $link_helper

 
	* @param \phpbb\log\log_interface $log

	* @param string $cache_dir          Path to the cache dir
* @param string $cache_key_parser Cache key used for the parser
* @param string $cache_key_renderer Cache key used for the renderer
*/

	* @param string $cache_dir          Path to the cache dir
* @param string $cache_key_parser Cache key used for the parser
* @param string $cache_key_renderer Cache key used for the renderer
*/

	public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, $cache_dir, $cache_key_parser, $cache_key_renderer)

	public function __construct(\phpbb\textformatter\data_access $data_access, \phpbb\cache\driver\driver_interface $cache, \phpbb\event\dispatcher_interface $dispatcher, \phpbb\config\config $config, \phpbb\textformatter\s9e\link_helper $link_helper, \phpbb\log\log_interface $log, $cache_dir, $cache_key_parser, $cache_key_renderer)

	{
$this->link_helper = $link_helper;
$this->cache = $cache;

	{
$this->link_helper = $link_helper;
$this->cache = $cache;

Line 153Line 159
		$this->config = $config;
$this->data_access = $data_access;
$this->dispatcher = $dispatcher;

		$this->config = $config;
$this->data_access = $data_access;
$this->dispatcher = $dispatcher;

 
		$this->log = $log;

	}

/**

	}

/**

Line 266Line 273
			->addParameterByName('logger')
->addParameterByName('max_img_height')
->addParameterByName('max_img_width')

			->addParameterByName('logger')
->addParameterByName('max_img_height')
->addParameterByName('max_img_width')

			->markAsSafeAsURL();


			->markAsSafeAsURL()
->setJS('UrlFilter.filter');


// Add default BBCodes
foreach ($this->get_default_bbcodes($configurator) as $bbcode)
{


// Add default BBCodes
foreach ($this->get_default_bbcodes($configurator) as $bbcode)
{

			$configurator->BBCodes->addCustom($bbcode['usage'], $bbcode['template']);






			$this->add_bbcode($configurator, $bbcode['usage'], $bbcode['template']);
}
if (isset($configurator->tags['QUOTE']))
{
// Remove the nesting limit and let other services remove quotes at parsing time
$configurator->tags['QUOTE']->nestingLimit = PHP_INT_MAX;

		}

// Modify the template to disable images/flash depending on user's settings

		}

// Modify the template to disable images/flash depending on user's settings

Line 293Line 306
				},
$row['bbcode_tpl']
);

				},
$row['bbcode_tpl']
);


try
{
$configurator->BBCodes->addCustom($row['bbcode_match'], new UnsafeTemplate($tpl));
}
catch (\Exception $e)
{
/**
* @todo log an error?
*/
}

			$this->add_bbcode($configurator, $row['bbcode_match'], $tpl);











		}

// Load smilies

		}

// Load smilies

Line 323Line 326
			// Only parse emoticons at the beginning of the text or if they're preceded by any
// one of: a new line, a space, a dot, or a right square bracket
$configurator->Emoticons->notAfter = '[^\\n .\\]]';

			// Only parse emoticons at the beginning of the text or if they're preceded by any
// one of: a new line, a space, a dot, or a right square bracket
$configurator->Emoticons->notAfter = '[^\\n .\\]]';

 

// Ignore emoticons that are immediately followed by a "word" character
$configurator->Emoticons->notBefore = '\\w';

		}

// Load the censored words

		}

// Load the censored words

Line 347Line 353
		$configurator->registeredVars['max_img_width'] = 0;

// Load the Emoji plugin and modify its tag's template to obey viewsmilies

		$configurator->registeredVars['max_img_width'] = 0;

// Load the Emoji plugin and modify its tag's template to obey viewsmilies

		$configurator->Emoji->omitImageSize();
$configurator->Emoji->useSVG();

 
		$tag = $configurator->Emoji->getTag();
$tag->template = '<xsl:choose><xsl:when test="$S_VIEWSMILIES">' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . '</xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose>';


		$tag = $configurator->Emoji->getTag();
$tag->template = '<xsl:choose><xsl:when test="$S_VIEWSMILIES">' . str_replace('class="emoji"', 'class="emoji smilies"', $tag->template) . '</xsl:when><xsl:otherwise><xsl:value-of select="."/></xsl:otherwise></xsl:choose>';


Line 382Line 386
			unset($configurator->tags['censor:tag']);
}


			unset($configurator->tags['censor:tag']);
}


		$objects  = $configurator->finalize();












		$objects = $configurator->finalize();

/**
* Access the objects returned by finalize() before they are saved to cache
*
* @event core.text_formatter_s9e_configure_finalize
* @var array objects Array containing a "parser" object, a "renderer" object and optionally a "js" string
* @since 3.2.2-RC1
*/
$vars = array('objects');
extract($this->dispatcher->trigger_event('core.text_formatter_s9e_configure_finalize', compact($vars)));


		$parser   = $objects['parser'];
$renderer = $objects['renderer'];


		$parser   = $objects['parser'];
$renderer = $objects['renderer'];


Line 398Line 413
		$this->cache->put($this->cache_key_renderer, $renderer_data);

return array('parser' => $parser, 'renderer' => $renderer);

		$this->cache->put($this->cache_key_renderer, $renderer_data);

return array('parser' => $parser, 'renderer' => $renderer);

 
	}

/**
* Add a BBCode to given configurator
*
* @param Configurator $configurator
* @param string $usage
* @param string $template
* @return void
*/
protected function add_bbcode(Configurator $configurator, $usage, $template)
{
try
{
$configurator->BBCodes->addCustom($usage, new UnsafeTemplate($template));
}
catch (\Exception $e)
{
$this->log->add('critical', null, null, 'LOG_BBCODE_CONFIGURATION_ERROR', false, [$usage, $e->getMessage()]);
}

	}

/**

	}

/**

Line 518Line 553
	protected function extract_templates($template)
{
// Capture the template fragments

	protected function extract_templates($template)
{
// Capture the template fragments

		preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END .*? -->#s', $template, $matches, PREG_SET_ORDER);



		// Allow either phpBB template or the Twig syntax
preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END .*? -->#s', $template, $matches, PREG_SET_ORDER) ?:
preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $template, $matches, PREG_SET_ORDER);


$fragments = array();
foreach ($matches as $match)


$fragments = array();
foreach ($matches as $match)