-
Notifications
You must be signed in to change notification settings - Fork 148
Expand file tree
/
Copy pathHtmlOutputNodeWoltlabSpoiler.class.php
More file actions
63 lines (57 loc) · 1.88 KB
/
HtmlOutputNodeWoltlabSpoiler.class.php
File metadata and controls
63 lines (57 loc) · 1.88 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
55
56
57
58
59
60
61
62
63
<?php
namespace wcf\system\html\output\node;
use wcf\system\html\node\AbstractHtmlNodeProcessor;
use wcf\system\WCF;
use wcf\util\StringUtil;
/**
* Processes spoilers.
*
* @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 HtmlOutputNodeWoltlabSpoiler extends AbstractHtmlOutputNode
{
/**
* @inheritDoc
*/
protected $tagName = 'woltlab-spoiler';
/**
* @inheritDoc
*/
public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor)
{
/** @var \DOMElement $element */
foreach ($elements as $element) {
if ($this->outputType === 'text/html') {
[$nodeIdentifier, $tagName] = $htmlNodeProcessor->getWcfNodeIdentifier();
$htmlNodeProcessor->addNodeData(
$this,
$nodeIdentifier,
['label' => $element->getAttribute('data-label')]
);
$htmlNodeProcessor->renameTag($element, $tagName);
} elseif ($this->outputType === 'text/simplified-html' || $this->outputType === 'text/plain') {
$htmlNodeProcessor->replaceElementWithText(
$element,
WCF::getLanguage()->getDynamicVariable(
'wcf.bbcode.spoiler.simplified',
['label' => $element->getAttribute('data-label')]
),
true
);
}
}
}
/**
* @inheritDoc
*/
public function replaceTag(array $data)
{
return WCF::getTPL()->render('wcf', 'shared_spoilerMetaCode', [
'buttonLabel' => $data['label'],
'spoilerID' => \substr(StringUtil::getRandomID(), 0, 8),
]);
}
}