Add support for Font Awesome v6 icons in the admin panel menu
authorAlexander Ebert <ebert@woltlab.com>
Wed, 17 Aug 2022 18:39:18 +0000 (20:39 +0200)
committerAlexander Ebert <ebert@woltlab.com>
Wed, 17 Aug 2022 18:39:18 +0000 (20:39 +0200)
XSD/acpMenu.xsd
com.woltlab.wcf/acpMenu.xml
wcfsetup/install/files/acp/templates/pageMenu.tpl
wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php
wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php

index a165e43d7cdd5d0bff38050f7ff5a0fa683e53be..efcc4cea79d22d230893997121935116e5bbb580 100644 (file)
        <xs:complexType name="acpmenuitem_delete">
                <xs:attribute name="name" type="woltlab_varchar" use="required" />
        </xs:complexType>
+
+       <xs:complexType name="acpmenuitem_icon">
+               <xs:attribute name="solid" type="xs:boolean" />
+       </xs:complexType>
        
        <!-- imported/updated acp menu item element type -->
        <xs:complexType name="acpmenuitem_import">
@@ -44,7 +48,7 @@
                                        <xs:element name="showorder" type="xs:unsignedInt" minOccurs="0" />
                                        <xs:element name="permissions" type="xs:string" minOccurs="0" />
                                        <xs:element name="options" type="xs:string" minOccurs="0" />
-                                       <xs:element name="icon" type="woltlab_varchar_nullable" minOccurs="0" />
+                                       <xs:element name="icon" type="acpmenuitem_icon" minOccurs="0" />
                                </xs:all>
                        </xs:extension>
                </xs:complexContent>
index 93107d2a4e8b09579620201e19b9d9ef592ed9d1..2ca70c8dfdb451455f9c4bb29d1330d39d8e1b4e 100644 (file)
@@ -4,7 +4,7 @@
                <!-- configuration -->
                <acpmenuitem name="wcf.acp.menu.link.configuration">
                        <showorder>1</showorder>
-                       <icon>fa-wrench</icon>
+                       <icon>wrench</icon>
                </acpmenuitem>
                <!-- option -->
                <acpmenuitem name="wcf.acp.menu.link.option">
@@ -37,7 +37,7 @@
                        <controller>wcf\acp\form\PackageStartInstallForm</controller>
                        <parent>wcf.acp.menu.link.package.list</parent>
                        <permissions>admin.configuration.package.canInstallPackage</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.package.server.list">
                        <controller>wcf\acp\page\PackageUpdateServerListPage</controller>
@@ -48,7 +48,7 @@
                        <controller>wcf\acp\form\PackageUpdateServerAddForm</controller>
                        <parent>wcf.acp.menu.link.package.server.list</parent>
                        <permissions>admin.configuration.package.canEditServer</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /package -->
                <!-- other -->
@@ -81,7 +81,7 @@
                        <controller>wcf\acp\form\CaptchaQuestionAddForm</controller>
                        <parent>wcf.acp.menu.link.captcha.question.list</parent>
                        <permissions>admin.captcha.canManageCaptchaQuestion</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /other -->
                <!-- devtools -->
@@ -99,7 +99,7 @@
                        <controller>wcf\acp\form\DevtoolsProjectAddForm</controller>
                        <parent>wcf.acp.menu.link.devtools.project.list</parent>
                        <permissions>admin.configuration.package.canInstallPackage</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.devtools.missingLanguageItem.list">
                        <controller>wcf\acp\page\DevtoolsMissingLanguageItemListPage</controller>
                <!-- user -->
                <acpmenuitem name="wcf.acp.menu.link.user">
                        <showorder>2</showorder>
-                       <icon>fa-users</icon>
+                       <icon>users</icon>
                </acpmenuitem>
                <!-- management -->
                <acpmenuitem name="wcf.acp.menu.link.user.management">
                        <controller>wcf\acp\form\UserSearchForm</controller>
                        <parent>wcf.acp.menu.link.user.list</parent>
                        <permissions>admin.user.canSearchUser</permissions>
-                       <icon>fa-search</icon>
+                       <icon>magnifying-glass</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.user.add">
                        <controller>wcf\acp\form\UserAddForm</controller>
                        <parent>wcf.acp.menu.link.user.list</parent>
                        <permissions>admin.user.canAddUser</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.user.bulkProcessing">
                        <controller>wcf\acp\form\UserBulkProcessingForm</controller>
                        <controller>wcf\acp\form\UserGroupAddForm</controller>
                        <parent>wcf.acp.menu.link.group.list</parent>
                        <permissions>admin.user.canAddGroup</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.group.mail">
                        <controller>wcf\acp\form\UserMailForm</controller>
                        <controller>wcf\acp\form\UserGroupAssignmentAddForm</controller>
                        <parent>wcf.acp.menu.link.group.assignment</parent>
                        <permissions>admin.user.canManageGroupAssignment</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /group -->
                <!-- rank -->
                        <controller>wcf\acp\form\UserRankAddForm</controller>
                        <parent>wcf.acp.menu.link.user.rank.list</parent>
                        <permissions>admin.user.rank.canManageRank</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /rank -->
                <!-- option -->
                        <controller>wcf\acp\form\UserOptionAddForm</controller>
                        <parent>wcf.acp.menu.link.user.option.list</parent>
                        <permissions>admin.user.canManageUserOption</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.user.option.category.list">
                        <controller>wcf\acp\page\UserOptionCategoryListPage</controller>
                        <controller>wcf\acp\form\UserOptionCategoryAddForm</controller>
                        <parent>wcf.acp.menu.link.user.option.category.list</parent>
                        <permissions>admin.user.canManageUserOption</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.userOptionDefaults">
                        <controller>wcf\acp\form\UserOptionSetDefaultsForm</controller>
                        <controller>wcf\acp\form\NoticeAddForm</controller>
                        <parent>wcf.acp.menu.link.notice.list</parent>
                        <permissions>admin.notice.canManageNotice</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /notice -->
                <!-- paid subscription -->
                        <parent>wcf.acp.menu.link.paidSubscription.list</parent>
                        <options>module_paid_subscription</options>
                        <permissions>admin.paidSubscription.canManageSubscription</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.paidSubscription.user.list">
                        <controller>wcf\acp\page\PaidSubscriptionUserListPage</controller>
                        <parent>wcf.acp.menu.link.trophy.category.list</parent>
                        <options>module_trophy</options>
                        <permissions>admin.trophy.canManageTrophy</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.trophy.list">
                        <controller>wcf\acp\page\TrophyListPage</controller>
                        <parent>wcf.acp.menu.link.trophy.list</parent>
                        <options>module_trophy</options>
                        <permissions>admin.trophy.canManageTrophy</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.userTrophy.list">
                        <controller>wcf\acp\page\UserTrophyListPage</controller>
                        <parent>wcf.acp.menu.link.userTrophy.list</parent>
                        <options>module_trophy</options>
                        <permissions>admin.trophy.canAwardTrophy</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /trophy -->
                <!-- /user -->
                <!-- content -->
                <acpmenuitem name="wcf.acp.menu.link.content">
                        <showorder>3</showorder>
-                       <icon>fa-file-text</icon>
+                       <icon>file-lines</icon>
                </acpmenuitem>
                <!-- cms -->
                <acpmenuitem name="wcf.acp.menu.link.cms">
                        <controller>wcf\acp\form\PageAddForm</controller>
                        <parent>wcf.acp.menu.link.cms.page.list</parent>
                        <permissions>admin.content.cms.canManagePage</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.cms.menu.list">
                        <controller>wcf\acp\page\MenuListPage</controller>
                        <controller>wcf\acp\form\MenuAddForm</controller>
                        <parent>wcf.acp.menu.link.cms.menu.list</parent>
                        <permissions>admin.content.cms.canManageMenu</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.cms.box.list">
                        <controller>wcf\acp\page\BoxListPage</controller>
                        <controller>wcf\acp\form\BoxAddForm</controller>
                        <parent>wcf.acp.menu.link.cms.box.list</parent>
                        <permissions>admin.content.cms.canManageBox</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /cms -->
                <!-- media -->
                        <controller>wcf\acp\form\MediaCategoryAddForm</controller>
                        <parent>wcf.acp.menu.link.media.category.list</parent>
                        <permissions>admin.content.cms.canManageMedia</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /media -->
                <!-- article -->
                        <controller>wcf\acp\form\ArticleAddForm</controller>
                        <parent>wcf.acp.menu.link.article.list</parent>
                        <permissions>admin.content.article.canManageArticle,admin.content.article.canContributeArticle</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.article.category.list">
                        <controller>wcf\acp\page\ArticleCategoryListPage</controller>
                        <controller>wcf\acp\form\ArticleCategoryAddForm</controller>
                        <parent>wcf.acp.menu.link.article.category.list</parent>
                        <permissions>admin.content.article.canManageCategory</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /article -->
                <!-- label -->
                        <controller>wcf\acp\form\LabelAddForm</controller>
                        <parent>wcf.acp.menu.link.label.list</parent>
                        <permissions>admin.content.label.canManageLabel</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.label.group.list">
                        <controller>wcf\acp\page\LabelGroupListPage</controller>
                        <controller>wcf\acp\form\LabelGroupAddForm</controller>
                        <parent>wcf.acp.menu.link.label.group.list</parent>
                        <permissions>admin.content.label.canManageLabel</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /label -->
                <!-- bbcode -->
                        <controller>wcf\acp\form\BBCodeAddForm</controller>
                        <parent>wcf.acp.menu.link.bbcode.list</parent>
                        <permissions>admin.content.bbcode.canManageBBCode</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.bbcode.mediaProvider.list">
                        <controller>wcf\acp\page\BBCodeMediaProviderListPage</controller>
                        <controller>wcf\acp\form\BBCodeMediaProviderAddForm</controller>
                        <parent>wcf.acp.menu.link.bbcode.mediaProvider.list</parent>
                        <permissions>admin.content.bbcode.canManageBBCode</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /bbcode -->
                <!-- tag -->
                        <controller>wcf\acp\form\TagAddForm</controller>
                        <parent>wcf.acp.menu.link.tag.list</parent>
                        <permissions>admin.content.tag.canManageTag</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /tag -->
                <!-- attachment -->
                <!-- application -->
                <acpmenuitem name="wcf.acp.menu.link.application">
                        <showorder>4</showorder>
-                       <icon>fa-comments</icon>
+                       <icon>comments</icon>
                </acpmenuitem>
                <!-- /application -->
                <!-- customization -->
                <acpmenuitem name="wcf.acp.menu.link.customization">
                        <showorder>5</showorder>
-                       <icon>fa-desktop</icon>
+                       <icon>desktop</icon>
                </acpmenuitem>
                <!-- style -->
                <acpmenuitem name="wcf.acp.menu.link.style">
                        <controller>wcf\acp\form\StyleImportForm</controller>
                        <parent>wcf.acp.menu.link.style.list</parent>
                        <permissions>admin.style.canManageStyle</permissions>
-                       <icon>fa-upload</icon>
+                       <icon>upload</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.style.add">
                        <controller>wcf\acp\form\StyleAddForm</controller>
                        <parent>wcf.acp.menu.link.style.list</parent>
                        <permissions>admin.style.canManageStyle</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.style.globalValues">
                        <controller>wcf\acp\form\StyleGlobalValuesForm</controller>
                        <controller>wcf\acp\form\TemplateAddForm</controller>
                        <parent>wcf.acp.menu.link.template.list</parent>
                        <permissions>admin.template.canManageTemplate</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.template.group.list">
                        <controller>wcf\acp\page\TemplateGroupListPage</controller>
                        <controller>wcf\acp\form\TemplateGroupAddForm</controller>
                        <parent>wcf.acp.menu.link.template.group.list</parent>
                        <permissions>admin.template.canManageTemplate</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /template -->
                <!-- language -->
                        <controller>wcf\acp\form\LanguageImportForm</controller>
                        <parent>wcf.acp.menu.link.language.list</parent>
                        <permissions>admin.language.canManageLanguage</permissions>
-                       <icon>fa-upload</icon>
+                       <icon>upload</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.language.item.list">
                        <controller>wcf\acp\page\LanguageItemListPage</controller>
                        <controller>wcf\acp\form\LanguageItemAddForm</controller>
                        <parent>wcf.acp.menu.link.language.item.list</parent>
                        <permissions>admin.language.canManageLanguage</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.language.multilingualism">
                        <controller>wcf\acp\form\LanguageMultilingualismForm</controller>
                        <controller>wcf\acp\form\SmileyAddForm</controller>
                        <parent>wcf.acp.menu.link.smiley.list</parent>
                        <permissions>admin.content.smiley.canManageSmiley</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.smiley.category.list">
                        <controller>wcf\acp\page\SmileyCategoryListPage</controller>
                        <controller>wcf\acp\form\SmileyCategoryAddForm</controller>
                        <parent>wcf.acp.menu.link.smiley.category.list</parent>
                        <permissions>admin.content.smiley.canManageSmiley</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /smiley -->
                <!-- ad -->
                        <controller>wcf\acp\form\AdAddForm</controller>
                        <parent>wcf.acp.menu.link.ad.list</parent>
                        <permissions>admin.ad.canManageAd</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /ad -->
                <!-- reactions -->
                        <controller>wcf\acp\form\ReactionTypeAddForm</controller>
                        <parent>wcf.acp.menu.link.reactionType.list</parent>
                        <permissions>admin.content.reaction.canManageReactionType</permissions>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <!-- /reactions -->
                <!-- /customization -->
                <!-- management -->
                <acpmenuitem name="wcf.acp.menu.link.management">
                        <showorder>6</showorder>
-                       <icon>fa-cog</icon>
+                       <icon>gear</icon>
                </acpmenuitem>
                <!-- maintenance -->
                <acpmenuitem name="wcf.acp.menu.link.maintenance">
                        <parent>wcf.acp.menu.link.cronjob.list</parent>
                        <permissions>admin.management.canManageCronjob</permissions>
                        <showorder>3</showorder>
-                       <icon>fa-plus</icon>
+                       <icon>plus</icon>
                </acpmenuitem>
                <acpmenuitem name="wcf.acp.menu.link.maintenance.cache">
                        <controller>wcf\acp\page\CacheListPage</controller>
index c525f463ee9c2732183ba0528500a7260dd1c96e..7bbdea9a44df604b76b7c207fe791e9636d583e0 100644 (file)
@@ -6,7 +6,7 @@
                        {foreach from=$__wcf->getACPMenu()->getMenuItems('') item=_sectionMenuItem}
                                <li>
                                        <a href="#" class="acpPageMenuLink{if $_sectionMenuItem->menuItem|in_array:$_activeMenuItems} active{/if}" data-menu-item="{$_sectionMenuItem->menuItem}">
-                                               <span class="icon icon32 {$_sectionMenuItem->icon}"></span>
+                                               {@$_sectionMenuItem->getIcon()->toHtml(32)}
                                                <span class="acpPageMenuItemLabel">{@$_sectionMenuItem}</span>
                                        </a>
                                </li>
@@ -38,7 +38,9 @@
                                                                                        <a href="{$_menuItem->getLink()}" class="acpPageSubMenuLink{if $_menuItem->menuItem|in_array:$_activeMenuItems && $_activeMenuItems[0] === $_menuItem->menuItem} active{/if}">{@$_menuItem}</a>
                                                                                        
                                                                                        {foreach from=$_subMenuItems item=_subMenuItem}
-                                                                                               <a href="{$_subMenuItem->getLink()}" class="acpPageSubMenuIcon jsTooltip{if $_subMenuItem->menuItem|in_array:$_activeMenuItems} active{/if}" title="{@$_subMenuItem}"><span class="icon icon16 {$_subMenuItem->icon}"></span></a>
+                                                                                               <a href="{$_subMenuItem->getLink()}" class="acpPageSubMenuIcon jsTooltip{if $_subMenuItem->menuItem|in_array:$_activeMenuItems} active{/if}" title="{@$_subMenuItem}">
+                                                                                                       {@$_subMenuItem->getIcon()->toHtml(16)}
+                                                                                               </a>
                                                                                        {/foreach}
                                                                                </li>
                                                                        {/if}
index afad6d6ae642a9af81c399c425246c43fc093665..7f1a4f508ed4fd2c214031a414ed52cb93138f03 100644 (file)
@@ -6,6 +6,7 @@ use wcf\data\DatabaseObject;
 use wcf\system\menu\ITreeMenuItem;
 use wcf\system\Regex;
 use wcf\system\request\LinkHandler;
+use wcf\system\style\FontAwesomeIcon;
 use wcf\system\WCF;
 
 /**
@@ -122,4 +123,22 @@ class ACPMenuItem extends DatabaseObject implements ITreeMenuItem
     {
         return WCF::getLanguage()->get($this->menuItem);
     }
+
+    /**
+     * @since 6.0
+     */
+    public function getIcon(): ?FontAwesomeIcon
+    {
+        if ($this->icon) {
+            if (FontAwesomeIcon::isValidString($this->icon)) {
+                return FontAwesomeIcon::fromString($this->icon);
+            } else if (\str_starts_with($this->icon, 'fa-')) {
+                // Safeguard to prevent legacy icons from breaking
+                // the admin panel during the upgrade to 6.0.
+                return FontAwesomeIcon::fromString("question\0true");
+            }
+        }
+
+        return null;
+    }
 }
index e32d55aae3770182a52d945bd40911f636443d47..ffd627270c053f445cd126492337f7ddc37e920e 100644 (file)
@@ -42,6 +42,23 @@ class ACPMenuPackageInstallationPlugin extends AbstractMenuPackageInstallationPl
         return $returnValue;
     }
 
+    /**
+     * @inheritDoc
+     */
+    protected function getElement(\DOMXPath $xpath, array &$elements, \DOMElement $element)
+    {
+        if ($element->tagName === 'icon') {
+            $solid = $element->getAttribute('solid');
+            $elements[$element->tagName] = \sprintf(
+                "%s\0%s",
+                $element->nodeValue,
+                $solid === 'true' ? 'true' : 'false'
+            );
+        } else {
+            $elements[$element->tagName] = $element->nodeValue;
+        }
+    }
+
     /**
      * @inheritDoc
      * @since   3.0