aboutsummaryrefslogtreecommitdiffstats
path: root/phpBB/phpbb/textformatter/s9e/factory.php
diff options
context:
space:
mode:
authorJoshyPHP <s9e.dev@gmail.com>2015-02-19 06:05:39 +0100
committerJoshyPHP <s9e.dev@gmail.com>2015-04-02 19:16:01 +0200
commitf721b85a7835c18459b310e4db74cc0f654b05ec (patch)
treeed8f9334a79e5fe24ebe3ca96bf3fb30b18bd446 /phpBB/phpbb/textformatter/s9e/factory.php
parent6578e1c6ec7172016fbfa375dd2fce5cb20f3ce1 (diff)
downloadforums-f721b85a7835c18459b310e4db74cc0f654b05ec.tar
forums-f721b85a7835c18459b310e4db74cc0f654b05ec.tar.gz
forums-f721b85a7835c18459b310e4db74cc0f654b05ec.tar.bz2
forums-f721b85a7835c18459b310e4db74cc0f654b05ec.tar.xz
forums-f721b85a7835c18459b310e4db74cc0f654b05ec.zip
[ticket/11768] Replaced the Censor plugin
...with something that is run at rendering time. PHPBB3-11768
Diffstat (limited to 'phpBB/phpbb/textformatter/s9e/factory.php')
-rw-r--r--phpBB/phpbb/textformatter/s9e/factory.php38
1 files changed, 20 insertions, 18 deletions
diff --git a/phpBB/phpbb/textformatter/s9e/factory.php b/phpBB/phpbb/textformatter/s9e/factory.php
index 47da3e3eb7..557645b0d6 100644
--- a/phpBB/phpbb/textformatter/s9e/factory.php
+++ b/phpBB/phpbb/textformatter/s9e/factory.php
@@ -264,25 +264,15 @@ class factory implements \phpbb\textformatter\cache
}
// Load the censored words
- foreach ($this->dal->get_words() as $row)
+ $censor = $this->dal->get_words();
+ if (!empty($censor))
{
- $configurator->Censor->add($row['word'], $row['replacement']);
- }
-
- if (isset($configurator->Censor))
- {
- // Replace the template with a template that applies only when $S_VIEWCENSORS is set
- $tag = $configurator->Censor->getTag();
- $tag->template =
- '<xsl:choose>
- <xsl:when test="not($S_VIEWCENSORS)">
- <xsl:value-of select="."/>
- </xsl:when>
- <xsl:when test="@with">
- <xsl:value-of select="@with"/>
- </xsl:when>
- <xsl:otherwise>****</xsl:otherwise>
- </xsl:choose>';
+ // Use a namespaced tag to avoid collisions
+ $configurator->plugins->load('Censor', array('tagName' => 'censor:tag'));
+ foreach ($censor as $row)
+ {
+ $configurator->Censor->add($row['word'], $row['replacement']);
+ }
}
// Load the magic links plugins. We do that after BBCodes so that they use the same tags
@@ -307,6 +297,14 @@ class factory implements \phpbb\textformatter\cache
{
$configurator = $this->get_configurator();
+ // Get the censor helper and remove the Censor plugin if applicable
+ if (isset($configurator->Censor))
+ {
+ $censor = $configurator->Censor->getHelper();
+ unset($configurator->Censor);
+ unset($configurator->tags['censor:tag']);
+ }
+
// Create $parser and $renderer
extract($configurator->finalize());
@@ -320,6 +318,10 @@ class factory implements \phpbb\textformatter\cache
'class' => get_class($renderer),
'renderer' => serialize($renderer)
);
+ if (isset($censor))
+ {
+ $renderer_data['censor'] = $censor;
+ }
$this->cache->put($this->cache_key_renderer, $renderer_data);
return array('parser' => $parser, 'renderer' => $renderer);