Skip to content
Permalink
Browse files

Add text reparser service for board rules

  • Loading branch information...
VSEphpbb committed Jul 16, 2015
1 parent 7ecd1c7 commit 8d7647432f32c6150ebf7226975a0008038c4d7f
@@ -75,3 +75,12 @@ services:
- [set_controller_helper, [@controller.helper]]
tags:
- { name: notification.type }

phpbb.boardrules.text_reparser.rule_text:
class: phpbb\boardrules\textreparser\plugins\rule_text
arguments:
- @dbal.conn
calls:
- [set_table_name, [%phpbb.boardrules.tables.boardrules%]]
tags:
- { name: text_reparser.plugin }
@@ -31,8 +31,8 @@ class ext extends \phpbb\extension\base
* The current phpBB version should meet or exceed
* the minimum version required by this extension:
*
* Requires phpBB 3.2.0-dev due to new faq controller route for bbcodes
* and the revised notifications system.
* Requires phpBB 3.2.0-dev due to new faq controller route for bbcodes,
* the revised notifications system and the text reparser service.
*
* @return bool
* @access public
@@ -0,0 +1,80 @@
<?xml version="1.0" encoding="UTF-8" ?>
<dataset>
<table name="phpbb_boardrules">
<column>rule_id</column>
<column>rule_message</column>
<column>rule_message_bbcode_uid</column>
<column>rule_message_bbcode_options</column>
<column>rule_parents</column>
<row>
<value>1</value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
<value>0</value>
<value></value>
</row>
<row>
<value>2</value>
<value>[b]Not bold[/b] :) http://example.org</value>
<value>abcd1234</value>
<value>0</value>
<value></value>
</row>
<row>
<value>3</value>
<value>[b:abcd1234]Bold[/b:abcd1234] :) http://example.org</value>
<value>abcd1234</value>
<value>1</value>
<value></value>
</row>
<row>
<value>4</value>
<value><![CDATA[[b]Not bold[/b] <!-- s:) --><img src="{SMILIES_PATH}/icon_e_smile.gif" alt=":)" title="Smile" /><!-- s:) --> http://example.org]]></value>
<value>abcd1234</value>
<value>2</value>
<value></value>
</row>
<row>
<value>5</value>
<value><![CDATA[[b]Not bold[/b] :) <!-- m --><a class="postlink" href="http://example.org">http://example.org</a><!-- m -->]]></value>
<value>abcd1234</value>
<value>4</value>
<value></value>
</row>
<row>
<value>6</value>
<value><![CDATA[[flash=123,345:abcd1234]http&#58;//example&#46;org/flash&#46;swf[/flash:abcd1234]]]></value>
<value>abcd1234</value>
<value>1</value>
<value></value>
</row>
<row>
<value>7</value>
<value><![CDATA[[flash=123,345]http://example.org/flash.swf[/flash]]]></value>
<value>abcd1234</value>
<value>0</value>
<value></value>
</row>
<row>
<value>8</value>
<value><![CDATA[[img:abcd1234]http&#58;//example&#46;org/img&#46;png[/img:abcd1234]]]></value>
<value>abcd1234</value>
<value>1</value>
<value></value>
</row>
<row>
<value>9</value>
<value><![CDATA[[img]http://example.org/img.png[/img]]]></value>
<value>abcd1234</value>
<value>0</value>
<value></value>
</row>
<row>
<value>1000</value>
<value>This row should be [b]ignored[/b]</value>
<value>abcd1234</value>
<value>0</value>
<value></value>
</row>
</table>
</dataset>
@@ -0,0 +1,35 @@
<?php
/**
*
* Board Rules extension for the phpBB Forum Software package.
*
* @copyright (c) 2015 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\boardrules\tests\text_reparser;
include_once dirname(__FILE__) . '/../../../../../../tests/text_reparser/plugins/test_row_based_plugin.php';
class rule_text_test extends \phpbb_textreparser_test_row_based_plugin
{
static protected function setup_extensions()
{
return array('phpbb/boardrules');
}
public function getDataSet()
{
return $this->createXMLDataSet(__DIR__ . '/fixtures/boardrules.xml');
}
protected function get_reparser()
{
$reparser = new \phpbb\boardrules\textreparser\plugins\rule_text($this->db);
$reparser->set_table_name('phpbb_boardrules');
return $reparser;
}
}
@@ -0,0 +1,49 @@
<?php
/**
*
* Board Rules extension for the phpBB Forum Software package.
*
* @copyright (c) 2015 phpBB Limited <https://www.phpbb.com>
* @license GNU General Public License, version 2 (GPL-2.0)
*
*/
namespace phpbb\boardrules\textreparser\plugins;
class rule_text extends \phpbb\textreparser\row_based_plugin
{
/** @var string The database table the rules are stored in */
protected $boardrules_table;
/**
* Set the board rules database table name
*
* @param string $boardrules_table
* @return null
*/
public function set_table_name($boardrules_table)
{
$this->boardrules_table = $boardrules_table;
}
/**
* {@inheritdoc}
*/
public function get_columns()
{
return array(
'id' => 'rule_id',
'text' => 'rule_message',
'bbcode_uid' => 'rule_message_bbcode_uid',
'options' => 'rule_message_bbcode_options',
);
}
/**
* {@inheritdoc}
*/
public function get_table_name()
{
return $this->boardrules_table;
}
}

0 comments on commit 8d76474

Please sign in to comment.
You can’t perform that action at this time.