Fix the support for Font Awesome icons in `acpMenu.xml`
authorAlexander Ebert <ebert@woltlab.com>
Mon, 18 Sep 2023 18:09:57 +0000 (20:09 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Mon, 18 Sep 2023 18:09:57 +0000 (20:09 +0200)
See https://www.woltlab.com/community/thread/301641-entwickler-werkzeuge-acpmenu-icons-machen-acp-kaputt/

wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php

index f5bf8c7c5f6d8a9623bfe4c8ac1079827fca8d23..e36fa01783deae9c36bcd87a2a95d0aa022b0242 100644 (file)
@@ -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;
     }
 }