From 778ccc0abe5d8918c6ae3f29715df39f4eae354f Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Mon, 18 Sep 2023 20:09:57 +0200 Subject: [PATCH] Fix the support for Font Awesome icons in `acpMenu.xml` See https://www.woltlab.com/community/thread/301641-entwickler-werkzeuge-acpmenu-icons-machen-acp-kaputt/ --- ...ACPMenuPackageInstallationPlugin.class.php | 23 +++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php index f5bf8c7c5f..e36fa01783 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php @@ -173,8 +173,15 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl $data = parent::fetchElementData($element, $saveData); $icon = $element->getElementsByTagName('icon')->item(0); - if ($icon !== null) { - $data['icon'] = $icon->nodeValue; + if ($icon !== null && !\str_starts_with($icon->nodeValue, 'fa-')) { + \assert($icon instanceof \DOMElement); + $solid = $icon->getAttribute('solid') === 'true'; + + $data['icon'] = \sprintf( + '%s;%s', + $icon->nodeValue, + $solid ? 'true' : 'false' + ); } else { $data['icon'] = ''; } @@ -192,6 +199,18 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl $this->appendElementChildren($menuItem, ['icon' => null], $form); + $icon = $menuItem->getElementsByTagName('icon')->item(0); + if ($icon !== null) { + \assert($icon instanceof \DOMElement); + + [$name, $solid] = \explode(';', $icon->textContent, 2); + if ($solid === 'true') { + $icon->setAttribute('solid', 'true'); + } + + $icon->textContent = $name; + } + return $menuItem; } } -- 2.20.1