1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
/** |
6
|
|
|
* Saito - The Threaded Web Forum |
7
|
|
|
* |
8
|
|
|
* @copyright Copyright (c) the Saito Project Developers |
9
|
|
|
* @link https://github.com/Schlaefer/Saito |
10
|
|
|
* @license http://opensource.org/licenses/MIT |
11
|
|
|
*/ |
12
|
|
|
|
13
|
|
|
namespace Plugin\BbcodeParser\src\Lib\jBBCode\Definitions; |
14
|
|
|
|
15
|
|
|
use Cake\View\Helper; |
16
|
|
|
use JBBCode\ElementNode; |
17
|
|
|
use Saito\Markup\MarkupSettings; |
18
|
|
|
|
19
|
|
|
abstract class CodeDefinition extends \JBBCode\CodeDefinition |
20
|
|
|
{ |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var Helper calling CakePHP helper |
24
|
|
|
*/ |
25
|
|
|
protected $_sHelper; |
26
|
|
|
|
27
|
|
|
protected $_sParseContent = true; |
28
|
|
|
|
29
|
|
|
protected $_sUseOptions = false; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* @var string bbcode-tag |
33
|
|
|
*/ |
34
|
|
|
protected $_sTagName; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var array Saito-options |
38
|
|
|
*/ |
39
|
|
|
protected $_sOptions; |
40
|
|
|
|
41
|
|
|
/** |
42
|
|
|
* {@inheritDoc} |
43
|
|
|
*/ |
44
|
|
|
public function __construct(Helper $Helper, MarkupSettings $options) |
45
|
|
|
{ |
46
|
|
|
$this->_sOptions = $options; |
|
|
|
|
47
|
|
|
$this->_sHelper = $Helper; |
48
|
|
|
parent::__construct(); |
|
|
|
|
49
|
|
|
$this->setTagName($this->_sTagName); |
|
|
|
|
50
|
|
|
$this->setParseContent($this->_sParseContent); |
|
|
|
|
51
|
|
|
$this->setUseOption($this->_sUseOptions); |
|
|
|
|
52
|
|
|
} |
53
|
|
|
|
54
|
|
|
/** |
55
|
|
|
* {@inheritDoc} |
56
|
|
|
*/ |
57
|
|
|
public function __get($name) |
58
|
|
|
{ |
59
|
|
|
if (is_object($this->_sHelper->$name)) { |
60
|
|
|
return $this->_sHelper->{$name}; |
61
|
|
|
} |
62
|
|
|
} |
63
|
|
|
|
64
|
|
|
/** |
65
|
|
|
* {@inheritDoc} |
66
|
|
|
*/ |
67
|
|
|
public function asHtml(ElementNode $el) |
68
|
|
|
{ |
69
|
|
|
if (!$this->hasValidInputs($el)) { |
70
|
|
|
return $el->getAsBBCode(); |
71
|
|
|
} |
72
|
|
|
$content = $this->getContent($el); |
73
|
|
|
$parsedString = $this->_parse($content, $el->getAttribute(), $el); |
74
|
|
|
if ($parsedString === false) { |
75
|
|
|
return $el->getAsBBCode(); |
76
|
|
|
} |
77
|
|
|
|
78
|
|
|
return $parsedString; |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* Parse |
83
|
|
|
* |
84
|
|
|
* @param string $content content |
85
|
|
|
* @param array $attributes attributes |
86
|
|
|
* @param ElementNode $node node |
87
|
|
|
* |
88
|
|
|
* @return mixed parsed string or bool false if parsing failed |
89
|
|
|
*/ |
90
|
|
|
abstract protected function _parse($content, $attributes, ElementNode $node); |
91
|
|
|
} |
92
|
|
|
|
Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.
Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..