-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathHtmlOutputNodeWoltlabMetacode.class.php
More file actions
54 lines (45 loc) · 1.56 KB
/
HtmlOutputNodeWoltlabMetacode.class.php
File metadata and controls
54 lines (45 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace wcf\system\html\output\node;
use wcf\system\bbcode\HtmlBBCodeParser;
use wcf\system\html\node\AbstractHtmlNodeProcessor;
/**
* Processes bbcodes represented by `<woltlab-metacode>`.
*
* @author Alexander Ebert
* @copyright 2001-2019 WoltLab GmbH
* @license GNU Lesser General Public License <http://opensource.org/licenses/lgpl-license.php>
* @since 3.0
*/
class HtmlOutputNodeWoltlabMetacode extends AbstractHtmlOutputNode
{
/**
* @inheritDoc
*/
protected $tagName = 'woltlab-metacode';
/**
* @inheritDoc
*/
public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor)
{
/** @var \DOMElement $element */
foreach ($elements as $element) {
$name = $element->getAttribute('data-name');
$attributes = $element->getAttribute('data-attributes');
[$nodeIdentifier, $tagName] = $htmlNodeProcessor->getWcfNodeIdentifier();
$element = $htmlNodeProcessor->renameTag($element, $tagName);
$htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [
'name' => $name,
'attributes' => $htmlNodeProcessor->parseAttributes($attributes),
'element' => $element,
]);
}
}
/**
* @inheritDoc
*/
public function replaceTag(array $data)
{
HtmlBBCodeParser::getInstance()->setOutputType($this->outputType);
return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes'], $data['element']);
}
}