From: Tim Düsterhus Date: Fri, 17 Jun 2022 08:08:12 +0000 (+0200) Subject: Flarum: Faithfully reproduce post replies X-Git-Tag: 5.5.0_RC_2~1 X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=f57e54b65e36af37980171f1219f66bc8c16c5e0;p=GitHub%2FWoltLab%2Fcom.woltlab.wcf.exporter.git Flarum: Faithfully reproduce post replies Flarum supports a mention with an attached Post ID to indicate a reply. This pattern does not directly translate into WoltLab Suite, without creating very odd-looking posts. Import those as a simple link with an arrow as the link text. --- diff --git a/files/lib/system/exporter/Flarum1xExporter.class.php b/files/lib/system/exporter/Flarum1xExporter.class.php index 23861df..b703a43 100644 --- a/files/lib/system/exporter/Flarum1xExporter.class.php +++ b/files/lib/system/exporter/Flarum1xExporter.class.php @@ -8,6 +8,7 @@ use wcf\data\object\type\ObjectTypeCache; use wcf\data\user\group\UserGroup; use wcf\system\database\util\PreparedStatementConditionBuilder; use wcf\system\importer\ImportHandler; +use wcf\system\request\LinkHandler; use wcf\system\WCF; use wcf\util\ArrayUtil; use wcf\util\UserRegistrationUtil; @@ -730,6 +731,24 @@ final class Flarum1xExporter extends AbstractExporter $message = \preg_replace("/\r?\n/", ' \\0', $message); + $message = \preg_replace_callback('/@"([^"]+)"#p([0-9]+)/', static function (array $matches): string { + $username = $matches[1]; + $postID = $matches[2]; + + $postLink = LinkHandler::getInstance()->getLink('Thread', [ + 'application' => 'wbb', + 'postID' => $postID, + 'forceFrontend' => true, + ]) . '#post' . $postID; + + return \sprintf( + "[%s](%s) @'%s'", + "\u{21A9}", + $postLink, + \str_replace("'", "''", $username) + ); + }, $message); + $out = $parsedown->text($message); $out = \preg_replace(