Added the option to override the id when replacing links with bbcodes
authorMarcel Werk <burntime@woltlab.com>
Mon, 20 Jul 2020 21:49:17 +0000 (23:49 +0200)
committerMarcel Werk <burntime@woltlab.com>
Mon, 20 Jul 2020 21:49:17 +0000 (23:49 +0200)
wcfsetup/install/files/lib/system/html/node/HtmlNodePlainLink.class.php

index a04419c5fb036c4a3005806eb8b3ee25298da559..caaa0cd40b71c79745d055f84bed36524ad7d406 100644 (file)
@@ -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()) {