mirror of
https://github.com/phpbb/phpbb.git
synced 2025-04-07 01:13:53 +02:00
Merge branch '3.2.x'
This commit is contained in:
commit
b1fe0f9dbe
phpBB
tests
text_formatter/s9e
text_processing
@ -499,7 +499,10 @@ class bbcode
|
||||
// Turn template blocks into PHP assignment statements for the values of $bbcode_tpl..
|
||||
$this->bbcode_template = array();
|
||||
|
||||
$matches = preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (?:.*?) -->#', $tpl, $match);
|
||||
// Capture the BBCode template matches
|
||||
// Allow phpBB template or the Twig syntax
|
||||
$matches = (preg_match_all('#<!-- BEGIN (.*?) -->(.*?)<!-- END (?:.*?) -->#', $tpl, $match)) ?:
|
||||
preg_match_all('#{% for (.*?) in .*? %}(.*?){% endfor %}#s', $tpl, $match);
|
||||
|
||||
for ($i = 0; $i < $matches; $i++)
|
||||
{
|
||||
|
@ -557,6 +557,7 @@ function strip_bbcode(&$text, $uid = '')
|
||||
function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text = true)
|
||||
{
|
||||
static $bbcode;
|
||||
global $auth, $config, $user;
|
||||
global $phpbb_dispatcher, $phpbb_container;
|
||||
|
||||
if ($text === '')
|
||||
@ -584,6 +585,13 @@ function generate_text_for_display($text, $uid, $bitfield, $flags, $censor_text
|
||||
|
||||
// Temporarily switch off viewcensors if applicable
|
||||
$old_censor = $renderer->get_viewcensors();
|
||||
|
||||
// Check here if the user is having viewing censors disabled (and also allowed to do so).
|
||||
if (!$user->optionget('viewcensors') && $config['allow_nocensors'] && $auth->acl_get('u_chgcensors'))
|
||||
{
|
||||
$censor_text = false;
|
||||
}
|
||||
|
||||
if ($old_censor !== $censor_text)
|
||||
{
|
||||
$renderer->set_viewcensors($censor_text);
|
||||
|
4
phpBB/phpbb/cache/driver/redis.php
vendored
4
phpBB/phpbb/cache/driver/redis.php
vendored
@ -137,6 +137,10 @@ class redis extends \phpbb\cache\driver\memory
|
||||
*/
|
||||
function _write($var, $data, $ttl = 2592000)
|
||||
{
|
||||
if ($ttl == 0)
|
||||
{
|
||||
return $this->redis->set($var, $data);
|
||||
}
|
||||
return $this->redis->setex($var, $ttl, $data);
|
||||
}
|
||||
|
||||
|
@ -521,7 +521,9 @@ class factory implements \phpbb\textformatter\cache_interface
|
||||
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)
|
||||
|
@ -32,9 +32,15 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
return __DIR__ . '/../../tmp/';
|
||||
}
|
||||
|
||||
public function get_factory()
|
||||
public function get_factory($styles_path = null)
|
||||
{
|
||||
global $config, $phpbb_root_path, $request, $user;
|
||||
|
||||
if (!isset($styles_path))
|
||||
{
|
||||
$styles_path = $phpbb_root_path . 'styles/';
|
||||
}
|
||||
|
||||
$this->cache = new phpbb_mock_cache;
|
||||
$dal = new \phpbb\textformatter\data_access(
|
||||
$this->new_dbal(),
|
||||
@ -42,7 +48,7 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
'phpbb_smilies',
|
||||
'phpbb_styles',
|
||||
'phpbb_words',
|
||||
$phpbb_root_path . 'styles/'
|
||||
$styles_path
|
||||
);
|
||||
$factory = new \phpbb\textformatter\s9e\factory(
|
||||
$dal,
|
||||
@ -68,10 +74,8 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
return $factory;
|
||||
}
|
||||
|
||||
public function test_get_configurator()
|
||||
public function run_configurator_assertions($configurator)
|
||||
{
|
||||
$configurator = $this->get_factory()->get_configurator();
|
||||
|
||||
$this->assertInstanceOf('s9e\\TextFormatter\\Configurator', $configurator);
|
||||
|
||||
$this->assertTrue(isset($configurator->plugins['Autoemail']));
|
||||
@ -97,6 +101,17 @@ class phpbb_textformatter_s9e_factory_test extends phpbb_database_test_case
|
||||
$this->assertTrue(isset($configurator->Emoticons[':D']));
|
||||
}
|
||||
|
||||
public function test_get_configurator()
|
||||
{
|
||||
$configurator = $this->get_factory()->get_configurator();
|
||||
$this->run_configurator_assertions($configurator);
|
||||
|
||||
// Test with twigified bbcode.html
|
||||
$configurator = $this->get_factory(__DIR__ . '/fixtures/styles/')->get_configurator();
|
||||
$this->run_configurator_assertions($configurator);
|
||||
|
||||
}
|
||||
|
||||
public function test_regenerate()
|
||||
{
|
||||
extract($this->get_factory()->regenerate());
|
||||
|
@ -0,0 +1,75 @@
|
||||
{% for ulist_open in loops.ulist_open %}<ul style="list-style-type: {{ LIST_TYPE }}">{% endfor %}
|
||||
{% for ulist_open_default in loops.ulist_open_default %}<ul>{% endfor %}
|
||||
{% for ulist_close in loops.ulist_close %}</ul>{% endfor %}
|
||||
|
||||
{% for olist_open in loops.olist_open %}<ol style="list-style-type: {{ LIST_TYPE }}">{% endfor %}
|
||||
{% for olist_close in loops.olist_close %}</ol>{% endfor %}
|
||||
|
||||
{% for listitem in loops.listitem %}<li>{% endfor %}
|
||||
{% for listitem_close in loops.listitem_close %}</li>{% endfor %}
|
||||
|
||||
{% for quote_username_open in loops.quote_username_open %}<blockquote><div><cite>{{ USERNAME }} {{ lang('WROTE') }}{{ lang('COLON') }}</cite>{% endfor %}
|
||||
{% for quote_open in loops.quote_open %}<blockquote class="uncited"><div>{% endfor %}
|
||||
{% for quote_close in loops.quote_close %}</div></blockquote>{% endfor %}
|
||||
{% for quote_extended in loops.quote_extended %}
|
||||
<blockquote>
|
||||
<xsl:if test="not(@author)">
|
||||
<xsl:attribute name="class">uncited</xsl:attribute>
|
||||
</xsl:if>
|
||||
<div>
|
||||
<xsl:if test="@author">
|
||||
<cite>
|
||||
<xsl:choose>
|
||||
<xsl:when test="@url">
|
||||
<a href="{@url}" class="postlink"><xsl:value-of select="@author"/></a>
|
||||
</xsl:when>
|
||||
<xsl:when test="@profile_url">
|
||||
<a href="{@profile_url}"><xsl:value-of select="@author"/></a>
|
||||
</xsl:when>
|
||||
<xsl:otherwise>
|
||||
<xsl:value-of select="@author"/>
|
||||
</xsl:otherwise>
|
||||
</xsl:choose>
|
||||
<xsl:text> </xsl:text>
|
||||
<xsl:value-of select="$L_WROTE"/>
|
||||
<xsl:value-of select="$L_COLON"/>
|
||||
<xsl:if test="@post_url">
|
||||
<xsl:text> </xsl:text>
|
||||
<a href="{@post_url}" data-post-id="{@post_id}" onclick="if(document.getElementById(hash.substr(1)))href=hash">↑</a>
|
||||
</xsl:if>
|
||||
<xsl:if test="@date">
|
||||
<div class="responsive-hide"><xsl:value-of select="@date"/></div>
|
||||
</xsl:if>
|
||||
</cite>
|
||||
</xsl:if>
|
||||
<xsl:apply-templates/>
|
||||
</div>
|
||||
</blockquote>
|
||||
{% endfor %}
|
||||
|
||||
{% for code_open in loops.code_open %}<div class="codebox"><p>{{ lang('CODE') }}{{ lang('COLON') }} <a href="#" onclick="selectCode(this); return false;">{{ lang('SELECT_ALL_CODE') }}</a></p><pre><code>{% endfor %}
|
||||
{% for code_close in loops.code_close %}</code></pre></div>{% endfor %}
|
||||
|
||||
{% for inline_attachment_open in loops.inline_attachment_open %}<div class="inline-attachment">{% endfor %}
|
||||
{% for inline_attachment_close in loops.inline_attachment_close %}</div>{% endfor %}
|
||||
|
||||
{% for b_open in loops.b_open %}<strong class="text-strong">{% endfor %}
|
||||
{% for b_close in loops.b_close %}</strong>{% endfor %}
|
||||
|
||||
{% for u_open in loops.u_open %}<span style="text-decoration: underline">{% endfor %}
|
||||
{% for u_close in loops.u_close %}</span>{% endfor %}
|
||||
|
||||
{% for i_open in loops.i_open %}<em class="text-italics">{% endfor %}
|
||||
{% for i_close in loops.i_close %}</em>{% endfor %}
|
||||
|
||||
{% for color in loops.color %}<span style="color: {{ COLOR }}">{{ TEXT }}</span>{% endfor %}
|
||||
|
||||
{% for size in loops.size %}<span style="font-size: {{ SIZE }}%; line-height: 116%;">{{ TEXT }}</span>{% endfor %}
|
||||
|
||||
{% for img in loops.img %}<img src="{{ URL }}" class="postimage" alt="{{ lang('IMAGE') }}" />{% endfor %}
|
||||
|
||||
{% for url in loops.url %}<a href="{{ URL }}" class="postlink">{{ DESCRIPTION }}</a>{% endfor %}
|
||||
|
||||
{% for email in loops.email %}<a href="mailto:{{ EMAIL }}">{{ DESCRIPTION }}</a>{% endfor %}
|
||||
|
||||
{% for flash in loops.flash %}<object classid="clsid:D27CDB6E-AE6D-11CF-96B8-444553540000" codebase="http://active.macromedia.com/flash2/cabs/swflash.cab#version=5,0,0,0" width="{{ WIDTH }}" height="{{ HEIGHT }}"><param name="movie" value="{{ URL }}" /><param name="play" value="false" /><param name="loop" value="false" /><param name="quality" value="high" /><param name="allowScriptAccess" value="never" /><param name="allowNetworking" value="internal" /><embed src="{{ URL }}" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/shockwave/download/index.cgi?P1_Prod_Version=ShockwaveFlash" width="{{ WIDTH }}" height="{{ HEIGHT }}" play="false" loop="false" quality="high" allowscriptaccess="never" allownetworking="internal"></embed></object>{% endfor %}
|
@ -29,7 +29,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
|
||||
*/
|
||||
public function test_legacy($original, $expected, $uid = '', $bitfield = '', $flags = 0, $censor_text = true)
|
||||
{
|
||||
global $cache, $user;
|
||||
global $auth, $cache, $config, $user;
|
||||
|
||||
global $phpbb_root_path, $phpEx;
|
||||
|
||||
@ -63,7 +63,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
|
||||
|
||||
public function test_censor_is_restored()
|
||||
{
|
||||
global $phpbb_container;
|
||||
global $auth, $user, $config, $phpbb_container;
|
||||
|
||||
$phpbb_container = new phpbb_mock_container_builder;
|
||||
|
||||
@ -72,7 +72,8 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
|
||||
$lang_loader = new \phpbb\language\language_file_loader($phpbb_root_path, $phpEx);
|
||||
$lang = new \phpbb\language\language($lang_loader);
|
||||
$user = new \phpbb\user($lang, '\phpbb\datetime');
|
||||
$user->optionset('viewcensors', false);
|
||||
// Do not ignore word censoring by user (switch censoring on in UCP)
|
||||
$user->optionset('viewcensors', true);
|
||||
|
||||
$config = new \phpbb\config\config(array('allow_nocensors' => true));
|
||||
|
||||
@ -102,6 +103,14 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
|
||||
$this->assertSame('apple', $renderer->render($original));
|
||||
$this->assertSame('banana', generate_text_for_display($original, '', '', 0, true));
|
||||
$this->assertSame('apple', $renderer->render($original), 'The original setting was not restored');
|
||||
|
||||
// Test user option switch to ignore censoring
|
||||
$renderer->set_viewcensors(true);
|
||||
// 1st: censoring is still on in UCP
|
||||
$this->assertSame('banana', generate_text_for_display($original, '', '', 0, true));
|
||||
// 2nd: switch censoring off in UCP
|
||||
$user->optionset('viewcensors', false);
|
||||
$this->assertSame('apple', generate_text_for_display($original, '', '', 0, true));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -109,7 +118,7 @@ class phpbb_text_processing_generate_text_for_display_test extends phpbb_test_ca
|
||||
*/
|
||||
public function test_text_formatter($original, $expected, $censor_text = true, $setup = null)
|
||||
{
|
||||
global $phpbb_container;
|
||||
global $auth, $user, $config, $phpbb_container;
|
||||
|
||||
$phpbb_container = new phpbb_mock_container_builder;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user