Passed
Push — master ( 34a386...ef56ac )
by Matt
01:34
created

bbcodes_config::auto_video()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 3
c 0
b 0
f 0
nc 2
nop 1
dl 0
loc 8
rs 10
ccs 5
cts 5
cp 1
crap 2
1
<?php
2
/**
3
 *
4
 * Advanced BBCode Box
5
 *
6
 * @copyright (c) 2018 Matt Friedman
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace vse\abbc3\core;
12
13
use s9e\TextFormatter\Configurator;
0 ignored issues
show
Bug introduced by
The type s9e\TextFormatter\Configurator was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
14
15
/**
16
 * ABBC3 custom BBCodes configurator
17
 */
18
class bbcodes_config
19
{
20
	/**
21
	 * Configure s9e Auto Video plugin
22
	 *
23
	 * @param Configurator $configurator
24
	 * @access public
25
	 */
26 1
	public function auto_video(Configurator $configurator)
27
	{
28 1
		if (!$configurator->registeredVars['abbc3.auto_video_enabled'])
29 1
		{
30 1
			return;
31
		}
32
33 1
		$configurator->plugins->load('Autovideo');
34
	}
35
36 1
	/**
37 1
	 * Configure s9e Pipes table plugin
38
	 *
39 1
	 * @param Configurator $configurator
40 1
	 * @access public
41 1
	 */
42 1
	public function pipes(Configurator $configurator)
43
	{
44
		if (!isset($configurator->BBCodes['pipes']) || !$configurator->registeredVars['abbc3.pipes_enabled'])
45
		{
46
			return;
47
		}
48
49
		$configurator->plugins->load('PipeTables');
50 1
51
		/** @var \s9e\TextFormatter\Configurator\Items\TemplateDocument $dom Add class "pipe-table" to allow us to style the table with our CSS */
52 1
		$dom = $configurator->tags['TABLE']->template->asDOM();
53 1
		foreach ($dom->getElementsByTagName('table') as $table)
54 1
		{
55
			$table->setAttribute('class', 'pipe-table');
56
		}
57
		$dom->saveChanges();
58 1
	}
59 1
60 1
	/**
61
	 * Configure BBVideo to use the MEDIA tag with the Media Embed plugin
62 1
	 *
63 1
	 * @param Configurator $configurator
64 1
	 * @access public
65 1
	 */
66 1
	public function bbvideo(Configurator $configurator)
67 1
	{
68
		if (!isset($configurator->BBCodes['bbvideo']))
69 1
		{
70 1
			return;
71 1
		}
72
73 1
		// If MediaEmbed is not already active (for example due to another ext) lets enable it
74 1
		if (!isset($configurator->MediaEmbed) && !isset($configurator->BBCodes['MEDIA']))
75
		{
76 1
			foreach ($configurator->MediaEmbed->defaultSites as $tagName => $tag)
77 1
			{
78
				if (!isset($configurator->BBCodes[$tagName]))
79
				{
80
					$configurator->MediaEmbed->add($tagName);
81
				}
82
			}
83
		}
84
85 1
		unset($configurator->BBCodes['bbvideo'], $configurator->tags['bbvideo']);
86
		$configurator->BBCodes->add(
87 1
			'bbvideo',
88 1
			[
89 1
				'contentAttributes' => ['url'],
90
				'tagName'           => 'MEDIA',
91
			]
92 1
		);
93 1
	}
94 1
95
	/**
96
	 * Configure Hidden BBCode
97
	 *
98
	 * @param Configurator $configurator
99
	 * @access public
100
	 */
101
	public function hidden(Configurator $configurator)
102
	{
103
		if (!isset($configurator->BBCodes['hidden']))
104
		{
105
			return;
106
		}
107
108
		unset($configurator->BBCodes['hidden'], $configurator->tags['hidden']);
109 1
		$configurator->BBCodes->addCustom(
110 1
			'[hidden]{TEXT}[/hidden]',
111
			'<xsl:choose>
112
				<xsl:when test="$S_USER_LOGGED_IN and not($S_IS_BOT)">
113
					<div class="hidebox hidebox_visible">
114
						<div class="hidebox_title hidebox_visible">{L_ABBC3_HIDDEN_OFF}</div>
115
						<div class="hidebox_visible">{TEXT}</div>
116
					</div>
117
				</xsl:when>
118
				<xsl:otherwise>
119
					<div class="hidebox hidebox_hidden">
120
						<div class="hidebox_title hidebox_hidden">{L_ABBC3_HIDDEN_ON}</div>
121
						<div class="hidebox_hidden">{L_ABBC3_HIDDEN_EXPLAIN}</div>
122
					</div>
123
				</xsl:otherwise>
124
			</xsl:choose>'
125
		);
126
	}
127
}
128