From aa141dc647cba025efed779ec0c5a5d7070dccfd Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 27 Jun 2016 13:12:30 +0200 Subject: [PATCH] Added output type and basic implementations --- .../node/AbstractHtmlInputNode.class.php | 14 ++++++ .../input/node/HtmlInputNodeImg.class.php | 5 +- .../node/HtmlInputNodeProcessor.class.php | 5 ++ .../HtmlInputNodeWoltlabMention.class.php | 5 +- .../HtmlInputNodeWoltlabMetacode.class.php | 5 +- ...mlInputNodeWoltlabMetacodeMarker.class.php | 3 +- .../node/AbstractHtmlNodeProcessor.class.php | 22 ++++++++ .../html/output/HtmlOutputProcessor.class.php | 21 ++++++++ .../node/AbstractHtmlOutputNode.class.php | 27 ++++++++++ .../node/HtmlOutputNodeBlockquote.class.php | 36 +++++++++---- .../output/node/HtmlOutputNodePre.class.php | 30 +++++++---- .../node/HtmlOutputNodeProcessor.class.php | 31 ++++++++++++ .../node/HtmlOutputNodeWoltlabColor.class.php | 23 ++++----- .../HtmlOutputNodeWoltlabMention.class.php | 50 ++++++++++--------- .../HtmlOutputNodeWoltlabMetacode.class.php | 5 +- .../node/HtmlOutputNodeWoltlabSize.class.php | 23 ++++----- .../HtmlOutputNodeWoltlabSpoiler.class.php | 26 ++++++---- .../output/node/IHtmlOutputNode.class.php | 9 +++- .../install/files/lib/util/DOMUtil.class.php | 17 +++++++ wcfsetup/install/lang/de.xml | 4 +- wcfsetup/install/lang/en.xml | 4 +- 21 files changed, 270 insertions(+), 95 deletions(-) create mode 100644 wcfsetup/install/files/lib/system/html/input/node/AbstractHtmlInputNode.class.php create mode 100644 wcfsetup/install/files/lib/system/html/output/node/AbstractHtmlOutputNode.class.php diff --git a/wcfsetup/install/files/lib/system/html/input/node/AbstractHtmlInputNode.class.php b/wcfsetup/install/files/lib/system/html/input/node/AbstractHtmlInputNode.class.php new file mode 100644 index 0000000000..945877ef95 --- /dev/null +++ b/wcfsetup/install/files/lib/system/html/input/node/AbstractHtmlInputNode.class.php @@ -0,0 +1,14 @@ + + * @package WoltLabSuite\Core\System\Html\Input\Node + * @since 3.0 + */ +abstract class AbstractHtmlInputNode extends AbstractHtmlNode implements IHtmlInputNode {} diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php index 12e9b64c0f..f3c3de9783 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeImg.class.php @@ -1,12 +1,11 @@ ` to handle embedded attachments. + * Processes `` to handle embedded attachments. * * @author Alexander Ebert * @copyright 2001-2016 WoltLab GmbH @@ -14,7 +13,7 @@ use wcf\util\JSON; * @package WoltLabSuite\Core\System\Html\Input\Node * @since 3.0 */ -class HtmlInputNodeImg extends AbstractHtmlNode { +class HtmlInputNodeImg extends AbstractHtmlInputNode { /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php index 0d2c8e5e96..8e2b59ea1f 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeProcessor.class.php @@ -19,6 +19,11 @@ class HtmlInputNodeProcessor extends AbstractHtmlNodeProcessor { */ protected $embeddedContent = []; + /** + * @inheritDoc + */ + protected $nodeInterface = IHtmlInputNode::class; + /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMention.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMention.class.php index 253add68da..3f520f9a7f 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMention.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMention.class.php @@ -1,10 +1,9 @@ `. + * Processes ``. * * @author Alexander Ebert * @copyright 2001-2016 WoltLab GmbH @@ -12,7 +11,7 @@ use wcf\system\html\node\AbstractHtmlNodeProcessor; * @package WoltLabSuite\Core\System\Html\Input\Node * @since 3.0 */ -class HtmlInputNodeWoltlabMention extends AbstractHtmlNode { +class HtmlInputNodeWoltlabMention extends AbstractHtmlInputNode { /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php index 23acfc8681..8b8251d838 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacode.class.php @@ -1,12 +1,11 @@ ` and converts them if appropriate. + * Processes `` and converts them if appropriate. * * @author Alexander Ebert * @copyright 2001-2016 WoltLab GmbH @@ -14,7 +13,7 @@ use wcf\util\DOMUtil; * @package WoltLabSuite\Core\System\Html\Input\Node * @since 3.0 */ -class HtmlInputNodeWoltlabMetacode extends AbstractHtmlNode { +class HtmlInputNodeWoltlabMetacode extends AbstractHtmlInputNode { /** * static mapping of attribute-less metacodes that map to * an exact HTML tag without the need of further processing diff --git a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php index 8a90cb92f8..38ef362242 100644 --- a/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php +++ b/wcfsetup/install/files/lib/system/html/input/node/HtmlInputNodeWoltlabMetacodeMarker.class.php @@ -1,7 +1,6 @@ ownerDocument->createTextNode($text); + $element->parentNode->insertBefore($textNode, $element); + $element->parentNode->removeChild($element); + } + /** * Removes an element but preserves child nodes by moving them into * its original position. @@ -191,6 +209,10 @@ abstract class AbstractHtmlNodeProcessor implements IHtmlNodeProcessor { * @param IHtmlNode $htmlNode html node processor */ protected function invokeHtmlNode(IHtmlNode $htmlNode) { + if (!($htmlNode instanceof $this->nodeInterface)) { + throw new \InvalidArgumentException("Node '" . get_class($htmlNode) . "' does not implement the interface '" . $this->nodeInterface . "'."); + } + $tagName = $htmlNode->getTagName(); if (empty($tagName)) { throw new \UnexpectedValueException("Missing tag name for " . get_class($htmlNode)); diff --git a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php index 23b63fbe56..e0fb3f0365 100644 --- a/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/HtmlOutputProcessor.class.php @@ -19,16 +19,37 @@ class HtmlOutputProcessor extends AbstractHtmlProcessor { */ protected $htmlOutputNodeProcessor; + /** + * desired output type + * @var string + */ + protected $outputType = 'text/html'; + /** * @inheritDoc */ public function process($html, $objectType, $objectID) { $this->setContext($objectType, $objectID); + $this->getHtmlOutputNodeProcessor()->setOutputType($this->outputType); $this->getHtmlOutputNodeProcessor()->load($this, $html); $this->getHtmlOutputNodeProcessor()->process(); } + /** + * Sets the desired output type. + * + * @param string $outputType desired output type + * @throws \InvalidArgumentException + */ + public function setOutputType($outputType) { + if (!in_array($outputType, ['text/html', 'text/simplified-html', 'text/plain'])) { + throw new \InvalidArgumentException("Expected 'text/html', 'text/simplified-html' or 'text/plain', but received '" . $outputType . "'"); + } + + $this->outputType = $outputType; + } + /** * @inheritDoc */ diff --git a/wcfsetup/install/files/lib/system/html/output/node/AbstractHtmlOutputNode.class.php b/wcfsetup/install/files/lib/system/html/output/node/AbstractHtmlOutputNode.class.php new file mode 100644 index 0000000000..fd5898ba39 --- /dev/null +++ b/wcfsetup/install/files/lib/system/html/output/node/AbstractHtmlOutputNode.class.php @@ -0,0 +1,27 @@ + + * @package WoltLabSuite\Core\System\Html\Output\Node + * @since 3.0 + */ +abstract class AbstractHtmlOutputNode extends AbstractHtmlNode implements IHtmlOutputNode { + /** + * desired output type + * @var string + */ + protected $outputType = 'text/html'; + + /** + * @inheritDoc + */ + public function setOutputType($outputType) { + $this->outputType = $outputType; + } +} diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeBlockquote.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeBlockquote.class.php index d1fdea2009..5ffc96d3a7 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeBlockquote.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeBlockquote.class.php @@ -1,11 +1,11 @@ addNodeData($this, $nodeIdentifier, [ - 'author' => ($element->hasAttribute('data-author')) ? $element->getAttribute('data-author') : '', - 'url' => ($element->hasAttribute('data-url')) ? $element->getAttribute('data-url') : '' - ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + switch ($this->outputType) { + case 'text/html': + $nodeIdentifier = StringUtil::getRandomID(); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ + 'author' => $element->getAttribute('data-author'), + 'url' => $element->getAttribute('data-url') + ]); + + $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + break; + + case 'text/simplified-html': + case 'text/plain': + // check if this quote is within another + if (DOMUtil::hasParent($element, 'blockquote')) { + DOMUtil::removeNode($element); + } + else { + $htmlNodeProcessor->replaceElementWithText( + $element, + WCF::getLanguage()->getDynamicVariable('wcf.bbcode.quote.simplified', ['cite' => $element->getAttribute('data-author')])."\n" + ); + } + break; + } } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodePre.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodePre.class.php index 79184f5bb9..95d4c94d37 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodePre.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodePre.class.php @@ -13,7 +13,6 @@ use wcf\system\bbcode\highlighter\PythonHighlighter; use wcf\system\bbcode\highlighter\SqlHighlighter; use wcf\system\bbcode\highlighter\TexHighlighter; use wcf\system\bbcode\highlighter\XmlHighlighter; -use wcf\system\html\node\AbstractHtmlNode; use wcf\system\html\node\AbstractHtmlNodeProcessor; use wcf\system\Regex; use wcf\system\WCF; @@ -28,7 +27,7 @@ use wcf\util\StringUtil; * @package WoltLabSuite\Core\System\Html\Output\Node * @since 3.0 */ -class HtmlOutputNodePre extends AbstractHtmlNode { +class HtmlOutputNodePre extends AbstractHtmlOutputNode { /** * @inheritDoc */ @@ -46,15 +45,24 @@ class HtmlOutputNodePre extends AbstractHtmlNode { public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor) { /** @var \DOMElement $element */ foreach ($elements as $element) { - $nodeIdentifier = StringUtil::getRandomID(); - $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ - 'content' => $element->textContent, - 'file' => ($element->hasAttribute('data-file')) ? $element->getAttribute('data-file') : '', - 'highlighter' => ($element->hasAttribute('data-highlighter')) ? $element->getAttribute('data-highlighter') : '', - 'line' => ($element->hasAttribute('data-line')) ? $element->getAttribute('data-line') : 1 - ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + switch ($this->outputType) { + case 'text/html': + $nodeIdentifier = StringUtil::getRandomID(); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ + 'content' => $element->textContent, + 'file' => ($element->hasAttribute('data-file')) ? $element->getAttribute('data-file') : '', + 'highlighter' => ($element->hasAttribute('data-highlighter')) ? $element->getAttribute('data-highlighter') : '', + 'line' => ($element->hasAttribute('data-line')) ? $element->getAttribute('data-line') : 1 + ]); + + $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + break; + + case 'text/simplified-html': + case 'text/plain': + return WCF::getLanguage()->getDynamicVariable('wcf.bbcode.code.simplified', ['lines' => substr_count($element->nodeValue, "\n") + 1]); + break; + } } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php index 015203c176..cf0adb66cc 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeProcessor.class.php @@ -1,6 +1,7 @@ outputType = $outputType; + } + /** * @inheritDoc */ @@ -21,4 +42,14 @@ class HtmlOutputNodeProcessor extends AbstractHtmlNodeProcessor { // dynamic node handlers $this->invokeNodeHandlers('wcf\system\html\output\node\HtmlOutputNode', ['woltlab-metacode']); } + + /** + * @inheritDoc + */ + protected function invokeHtmlNode(IHtmlNode $htmlNode) { + /** @var IHtmlOutputNode $htmlNode */ + $htmlNode->setOutputType($this->outputType); + + parent::invokeHtmlNode($htmlNode); + } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabColor.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabColor.class.php index f6829e093d..5e45e01995 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabColor.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabColor.class.php @@ -1,6 +1,5 @@ [A-F0-9]{6})$~', $element->getAttribute('class'), $matches)) { - $nodeIdentifier = StringUtil::getRandomID(); - $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ - 'color' => $matches['color'] - ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + if ($this->outputType === 'text/html' || $this->outputType === 'text/simplified-html') { + /** @var \DOMElement $element */ + foreach ($elements as $element) { + // parse color + if (preg_match('~^woltlab-color-(?P[A-F0-9]{6})$~', $element->getAttribute('class'), $matches)) { + $nodeIdentifier = StringUtil::getRandomID(); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, ['color' => $matches['color']]); + + $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + } } } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php index e2821b253e..3ae4183a50 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMention.class.php @@ -2,7 +2,6 @@ namespace wcf\system\html\output\node; use wcf\data\user\UserProfile; use wcf\system\cache\runtime\UserProfileRuntimeCache; -use wcf\system\html\node\AbstractHtmlNode; use wcf\system\html\node\AbstractHtmlNodeProcessor; use wcf\system\WCF; use wcf\util\DOMUtil; @@ -17,7 +16,7 @@ use wcf\util\StringUtil; * @package WoltLabSuite\Core\System\Html\Output\Node * @since 3.0 */ -class HtmlOutputNodeWoltlabMention extends AbstractHtmlNode { +class HtmlOutputNodeWoltlabMention extends AbstractHtmlOutputNode { /** * @inheritDoc */ @@ -32,31 +31,36 @@ class HtmlOutputNodeWoltlabMention extends AbstractHtmlNode { * @inheritDoc */ public function process(array $elements, AbstractHtmlNodeProcessor $htmlNodeProcessor) { - $this->userProfiles = []; - - $userIds = []; - /** @var \DOMElement $element */ - foreach ($elements as $element) { - $userId = ($element->hasAttribute('data-user-id')) ? intval($element->getAttribute('data-user-id')) : 0; - $username = ($element->hasAttribute('data-username')) ? StringUtil::trim($element->getAttribute('data-username')) : ''; + if ($this->outputType === 'text/html' || $this->outputType === 'text/simplified-html') { + $this->userProfiles = []; - if ($userId === 0 || $username === '') { - DOMUtil::removeNode($element); - continue; + $userIds = []; + /** @var \DOMElement $element */ + foreach ($elements as $element) { + $userId = intval($element->getAttribute('data-user-id')); + $username = StringUtil::trim($element->getAttribute('data-username')); + + if ($userId === 0 || $username === '') { + DOMUtil::removeNode($element); + continue; + } + + $userIds[] = $userId; + $nodeIdentifier = StringUtil::getRandomID(); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, ['userId' => $userId, 'username' => $username]); + + $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); } - $userIds[] = $userId; - $nodeIdentifier = StringUtil::getRandomID(); - $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ - 'userId' => $userId, - 'username' => $username - ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + if (!empty($userIds)) { + $this->userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIds); + } } - - if (!empty($userIds)) { - $this->userProfiles = UserProfileRuntimeCache::getInstance()->getObjects($userIds); + else if ($this->outputType === 'text/plain') { + /** @var \DOMElement $element */ + foreach ($elements as $element) { + $htmlNodeProcessor->replaceElementWithText($element, '@' . $element->getAttribute('data-username')); + } } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php index 98a2df63e1..368c418e6b 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabMetacode.class.php @@ -1,7 +1,6 @@ setOutputType($this->outputType); + return HtmlBBCodeParser::getInstance()->getHtmlOutput($data['name'], $data['attributes']); } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSize.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSize.class.php index 094d96f7a5..ca817d49ce 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSize.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSize.class.php @@ -1,6 +1,5 @@ [0-9]{1,2})$~', $element->getAttribute('class'), $matches)) { - $nodeIdentifier = StringUtil::getRandomID(); - $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, [ - 'size' => $matches['size'] - ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + if ($this->outputType === 'text/html' || $this->outputType === 'text/simplified-html') { + /** @var \DOMElement $element */ + foreach ($elements as $element) { + // parse color + if (preg_match('~^woltlab-size-(?P[0-9]{1,2})$~', $element->getAttribute('class'), $matches)) { + $nodeIdentifier = StringUtil::getRandomID(); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, ['size' => $matches['size']]); + + $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + } } } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSpoiler.class.php b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSpoiler.class.php index 982172626c..2305900c0a 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSpoiler.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/HtmlOutputNodeWoltlabSpoiler.class.php @@ -1,8 +1,8 @@ addNodeData($this, $nodeIdentifier, [ - 'label' => ($element->hasAttribute('data-label')) ? $element->getAttribute('data-label') : '' - ]); - - $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + if ($this->outputType === 'text/html' || $this->outputType === 'text/simplified-html') { + /** @var \DOMElement $element */ + foreach ($elements as $element) { + $nodeIdentifier = StringUtil::getRandomID(); + $htmlNodeProcessor->addNodeData($this, $nodeIdentifier, ['label' => $element->getAttribute('data-label')]); + + $htmlNodeProcessor->renameTag($element, 'wcfNode-' . $nodeIdentifier); + } + } + else if ($this->outputType === 'text/plain') { + /** @var \DOMElement $element */ + foreach ($elements as $element) { + DOMUtil::removeNode($element); + } } } diff --git a/wcfsetup/install/files/lib/system/html/output/node/IHtmlOutputNode.class.php b/wcfsetup/install/files/lib/system/html/output/node/IHtmlOutputNode.class.php index 1dd8700bdd..c92a06eba4 100644 --- a/wcfsetup/install/files/lib/system/html/output/node/IHtmlOutputNode.class.php +++ b/wcfsetup/install/files/lib/system/html/output/node/IHtmlOutputNode.class.php @@ -11,4 +11,11 @@ use wcf\system\html\node\IHtmlNode; * @package WoltLabSuite\Core\System\Html\Output\Node * @since 3.0 */ -interface IHtmlOutputNode extends IHtmlNode {} +interface IHtmlOutputNode extends IHtmlNode { + /** + * Sets the desired output type. + * + * @param string $outputType desired output type + */ + public function setOutputType($outputType); +} diff --git a/wcfsetup/install/files/lib/util/DOMUtil.class.php b/wcfsetup/install/files/lib/util/DOMUtil.class.php index 149e34483f..c255353bad 100644 --- a/wcfsetup/install/files/lib/util/DOMUtil.class.php +++ b/wcfsetup/install/files/lib/util/DOMUtil.class.php @@ -176,6 +176,23 @@ final class DOMUtil { throw new \RuntimeException("Unable to determine relative node position."); } + /** + * Returns true if there is at least one parent with the provided tag name. + * + * @param \DOMElement $element start element + * @param string $tagName tag name to match + * @return boolean true if there is at least one parent with the provided tag name + */ + public static function hasParent(\DOMElement $element, $tagName) { + while ($element = $element->parentNode) { + if ($element->nodeName === $tagName) { + return true; + } + } + + return false; + } + /** * Inserts given DOM node after the reference node. * diff --git a/wcfsetup/install/lang/de.xml b/wcfsetup/install/lang/de.xml index 59b5a38a82..a031972b7e 100644 --- a/wcfsetup/install/lang/de.xml +++ b/wcfsetup/install/lang/de.xml @@ -1826,11 +1826,11 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExt - + @@ -1840,7 +1840,7 @@ Erlaubte Dateiendungen: {', '|implode:$attachmentHandler->getFormattedAllowedExt - + diff --git a/wcfsetup/install/lang/en.xml b/wcfsetup/install/lang/en.xml index fa4131eb94..c78b025e76 100644 --- a/wcfsetup/install/lang/en.xml +++ b/wcfsetup/install/lang/en.xml @@ -1835,9 +1835,9 @@ Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensi - + @@ -1847,7 +1847,7 @@ Allowed extensions: {', '|implode:$attachmentHandler->getFormattedAllowedExtensi - + -- 2.20.1