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