Completed
Push — develop ( 755a17...843010 )
by Daniel
07:33
created

bbcodes::getSubscribedEvents()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 9
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 9
ccs 0
cts 9
cp 0
rs 9.6666
c 0
b 0
f 0
cc 1
eloc 5
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 *
4
 * @package sitemaker
5
 * @copyright (c) 2013 Daniel A. (blitze)
6
 * @license http://opensource.org/licenses/gpl-2.0.php GNU General Public License v2
7
 *
8
 */
9
10
namespace blitze\content\event;
11
12
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
13
14
class bbcodes implements EventSubscriberInterface
15
{
16
	/**
17
	 * @return array
18
	 */
19
	public static function getSubscribedEvents()
20
	{
21
		return array(
22
			'core.text_formatter_s9e_configure_after' => array(
23
				array('create_page_bbcode'),
24
				array('create_tag_bbcode'),
25
			),
26
		);
27
	}
28
29
	/**
30
	 * @param \phpbb\event\data $event
31
	 * @return void
32
	 */
33
	public function create_page_bbcode($event)
34
	{
35
		// Get the BBCode configurator
36
		$configurator = $event['configurator'];
37
38
		// Let's unset any existing BBCode that might already exist
39
		unset($configurator->BBCodes['pagebreak']);
40
		unset($configurator->tags['pagebreak']);
41
42
		// Let's create the new BBCode
43
		$configurator->BBCodes->addCustom(
44
		    '[pagebreak title={SIMPLETEXT;optional;postFilter=ucwords}]',
45
		    '<p><!-- pagebreak --></p>' .
46
		    '<xsl:if test="@title"><h4>{SIMPLETEXT}</h4><br /></xsl:if>'
47
		);
48
	}
49
50
	/**
51
	 * @param \phpbb\event\data $event
52
	 * @return void
53
	 */
54
	public function create_tag_bbcode($event)
55
	{
56
		// Get the BBCode configurator
57
		$configurator = $event['configurator'];
58
59
		// Let's unset any existing BBCode that might already exist
60
		unset($configurator->BBCodes['tag']);
61
		unset($configurator->tags['tag']);
62
63
		// Let's create the new BBCode
64
		$configurator->BBCodes->addCustom(
65
		    '[tag={IDENTIFIER}]{TEXT}[/tag]',
66
		    "<!-- begin field -->\n" .
67
			"<div data-field=\"{IDENTIFIER}\">{TEXT}</div><br />\n" .
68
			"<!-- end field -->\n"
69
		);
70
	}
71
}
72