From: Marcel Werk Date: Mon, 20 Jul 2020 21:49:17 +0000 (+0200) Subject: Added the option to override the id when replacing links with bbcodes X-Git-Tag: 5.3.0_Alpha_1~125 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=c624b35612b530797b95ee6644d79493e783d495;p=GitHub%2FWoltLab%2FWCF.git Added the option to override the id when replacing links with bbcodes --- diff --git a/wcfsetup/install/files/lib/system/html/node/HtmlNodePlainLink.class.php b/wcfsetup/install/files/lib/system/html/node/HtmlNodePlainLink.class.php index a04419c5fb..caaa0cd40b 100644 --- a/wcfsetup/install/files/lib/system/html/node/HtmlNodePlainLink.class.php +++ b/wcfsetup/install/files/lib/system/html/node/HtmlNodePlainLink.class.php @@ -138,9 +138,10 @@ class HtmlNodePlainLink { * Replaces the entire link, including any formatting, with the provided bbcode. This is * available for standalone links only. * - * @param BBCode $bbcode + * @param BBCode $bbcode + * @param int|null $overrideObjectID */ - public function replaceWithBBCode(BBCode $bbcode) { + public function replaceWithBBCode(BBCode $bbcode, $overrideObjectID = null) { $this->markAsTainted(); if ($this->objectID === 0) { @@ -149,7 +150,7 @@ class HtmlNodePlainLink { $metacodeElement = $this->link->ownerDocument->createElement('woltlab-metacode'); $metacodeElement->setAttribute('data-name', $bbcode->bbcodeTag); - $metacodeElement->setAttribute('data-attributes', base64_encode(JSON::encode([$this->objectID]))); + $metacodeElement->setAttribute('data-attributes', base64_encode(JSON::encode([($overrideObjectID !== null ? $overrideObjectID : $this->objectID)]))); if ($bbcode->isBlockElement) { if (!$this->isStandalone()) {