From 08f3844272f0d0fa5e68692a61deabc656b7fa02 Mon Sep 17 00:00:00 2001 From: Alexander Ebert Date: Wed, 17 Aug 2022 20:39:18 +0200 Subject: [PATCH] Add support for Font Awesome v6 icons in the admin panel menu --- XSD/acpMenu.xsd | 6 +- com.woltlab.wcf/acpMenu.xml | 88 +++++++++---------- .../install/files/acp/templates/pageMenu.tpl | 6 +- .../data/acp/menu/item/ACPMenuItem.class.php | 19 ++++ ...ACPMenuPackageInstallationPlugin.class.php | 17 ++++ 5 files changed, 89 insertions(+), 47 deletions(-) diff --git a/XSD/acpMenu.xsd b/XSD/acpMenu.xsd index a165e43d7c..efcc4cea79 100644 --- a/XSD/acpMenu.xsd +++ b/XSD/acpMenu.xsd @@ -32,6 +32,10 @@ + + + + @@ -44,7 +48,7 @@ - + diff --git a/com.woltlab.wcf/acpMenu.xml b/com.woltlab.wcf/acpMenu.xml index 93107d2a4e..2ca70c8dfd 100644 --- a/com.woltlab.wcf/acpMenu.xml +++ b/com.woltlab.wcf/acpMenu.xml @@ -4,7 +4,7 @@ 1 - fa-wrench + wrench @@ -37,7 +37,7 @@ wcf\acp\form\PackageStartInstallForm wcf.acp.menu.link.package.list admin.configuration.package.canInstallPackage - fa-plus + plus wcf\acp\page\PackageUpdateServerListPage @@ -48,7 +48,7 @@ wcf\acp\form\PackageUpdateServerAddForm wcf.acp.menu.link.package.server.list admin.configuration.package.canEditServer - fa-plus + plus @@ -81,7 +81,7 @@ wcf\acp\form\CaptchaQuestionAddForm wcf.acp.menu.link.captcha.question.list admin.captcha.canManageCaptchaQuestion - fa-plus + plus @@ -99,7 +99,7 @@ wcf\acp\form\DevtoolsProjectAddForm wcf.acp.menu.link.devtools.project.list admin.configuration.package.canInstallPackage - fa-plus + plus wcf\acp\page\DevtoolsMissingLanguageItemListPage @@ -116,7 +116,7 @@ 2 - fa-users + users @@ -132,13 +132,13 @@ wcf\acp\form\UserSearchForm wcf.acp.menu.link.user.list admin.user.canSearchUser - fa-search + magnifying-glass wcf\acp\form\UserAddForm wcf.acp.menu.link.user.list admin.user.canAddUser - fa-plus + plus wcf\acp\form\UserBulkProcessingForm @@ -171,7 +171,7 @@ wcf\acp\form\UserGroupAddForm wcf.acp.menu.link.group.list admin.user.canAddGroup - fa-plus + plus wcf\acp\form\UserMailForm @@ -188,7 +188,7 @@ wcf\acp\form\UserGroupAssignmentAddForm wcf.acp.menu.link.group.assignment admin.user.canManageGroupAssignment - fa-plus + plus @@ -206,7 +206,7 @@ wcf\acp\form\UserRankAddForm wcf.acp.menu.link.user.rank.list admin.user.rank.canManageRank - fa-plus + plus @@ -223,7 +223,7 @@ wcf\acp\form\UserOptionAddForm wcf.acp.menu.link.user.option.list admin.user.canManageUserOption - fa-plus + plus wcf\acp\page\UserOptionCategoryListPage @@ -234,7 +234,7 @@ wcf\acp\form\UserOptionCategoryAddForm wcf.acp.menu.link.user.option.category.list admin.user.canManageUserOption - fa-plus + plus wcf\acp\form\UserOptionSetDefaultsForm @@ -256,7 +256,7 @@ wcf\acp\form\NoticeAddForm wcf.acp.menu.link.notice.list admin.notice.canManageNotice - fa-plus + plus @@ -275,7 +275,7 @@ wcf.acp.menu.link.paidSubscription.list module_paid_subscription admin.paidSubscription.canManageSubscription - fa-plus + plus wcf\acp\page\PaidSubscriptionUserListPage @@ -306,7 +306,7 @@ wcf.acp.menu.link.trophy.category.list module_trophy admin.trophy.canManageTrophy - fa-plus + plus wcf\acp\page\TrophyListPage @@ -319,7 +319,7 @@ wcf.acp.menu.link.trophy.list module_trophy admin.trophy.canManageTrophy - fa-plus + plus wcf\acp\page\UserTrophyListPage @@ -332,14 +332,14 @@ wcf.acp.menu.link.userTrophy.list module_trophy admin.trophy.canAwardTrophy - fa-plus + plus 3 - fa-file-text + file-lines @@ -355,7 +355,7 @@ wcf\acp\form\PageAddForm wcf.acp.menu.link.cms.page.list admin.content.cms.canManagePage - fa-plus + plus wcf\acp\page\MenuListPage @@ -366,7 +366,7 @@ wcf\acp\form\MenuAddForm wcf.acp.menu.link.cms.menu.list admin.content.cms.canManageMenu - fa-plus + plus wcf\acp\page\BoxListPage @@ -377,7 +377,7 @@ wcf\acp\form\BoxAddForm wcf.acp.menu.link.cms.box.list admin.content.cms.canManageBox - fa-plus + plus @@ -399,7 +399,7 @@ wcf\acp\form\MediaCategoryAddForm wcf.acp.menu.link.media.category.list admin.content.cms.canManageMedia - fa-plus + plus @@ -417,7 +417,7 @@ wcf\acp\form\ArticleAddForm wcf.acp.menu.link.article.list admin.content.article.canManageArticle,admin.content.article.canContributeArticle - fa-plus + plus wcf\acp\page\ArticleCategoryListPage @@ -428,7 +428,7 @@ wcf\acp\form\ArticleCategoryAddForm wcf.acp.menu.link.article.category.list admin.content.article.canManageCategory - fa-plus + plus @@ -445,7 +445,7 @@ wcf\acp\form\LabelAddForm wcf.acp.menu.link.label.list admin.content.label.canManageLabel - fa-plus + plus wcf\acp\page\LabelGroupListPage @@ -456,7 +456,7 @@ wcf\acp\form\LabelGroupAddForm wcf.acp.menu.link.label.group.list admin.content.label.canManageLabel - fa-plus + plus @@ -473,7 +473,7 @@ wcf\acp\form\BBCodeAddForm wcf.acp.menu.link.bbcode.list admin.content.bbcode.canManageBBCode - fa-plus + plus wcf\acp\page\BBCodeMediaProviderListPage @@ -484,7 +484,7 @@ wcf\acp\form\BBCodeMediaProviderAddForm wcf.acp.menu.link.bbcode.mediaProvider.list admin.content.bbcode.canManageBBCode - fa-plus + plus @@ -502,7 +502,7 @@ wcf\acp\form\TagAddForm wcf.acp.menu.link.tag.list admin.content.tag.canManageTag - fa-plus + plus @@ -520,13 +520,13 @@ 4 - fa-comments + comments 5 - fa-desktop + desktop @@ -542,13 +542,13 @@ wcf\acp\form\StyleImportForm wcf.acp.menu.link.style.list admin.style.canManageStyle - fa-upload + upload wcf\acp\form\StyleAddForm wcf.acp.menu.link.style.list admin.style.canManageStyle - fa-plus + plus wcf\acp\form\StyleGlobalValuesForm @@ -570,7 +570,7 @@ wcf\acp\form\TemplateAddForm wcf.acp.menu.link.template.list admin.template.canManageTemplate - fa-plus + plus wcf\acp\page\TemplateGroupListPage @@ -581,7 +581,7 @@ wcf\acp\form\TemplateGroupAddForm wcf.acp.menu.link.template.group.list admin.template.canManageTemplate - fa-plus + plus @@ -598,7 +598,7 @@ wcf\acp\form\LanguageImportForm wcf.acp.menu.link.language.list admin.language.canManageLanguage - fa-upload + upload wcf\acp\page\LanguageItemListPage @@ -609,7 +609,7 @@ wcf\acp\form\LanguageItemAddForm wcf.acp.menu.link.language.item.list admin.language.canManageLanguage - fa-plus + plus wcf\acp\form\LanguageMultilingualismForm @@ -632,7 +632,7 @@ wcf\acp\form\SmileyAddForm wcf.acp.menu.link.smiley.list admin.content.smiley.canManageSmiley - fa-plus + plus wcf\acp\page\SmileyCategoryListPage @@ -643,7 +643,7 @@ wcf\acp\form\SmileyCategoryAddForm wcf.acp.menu.link.smiley.category.list admin.content.smiley.canManageSmiley - fa-plus + plus @@ -661,7 +661,7 @@ wcf\acp\form\AdAddForm wcf.acp.menu.link.ad.list admin.ad.canManageAd - fa-plus + plus @@ -679,14 +679,14 @@ wcf\acp\form\ReactionTypeAddForm wcf.acp.menu.link.reactionType.list admin.content.reaction.canManageReactionType - fa-plus + plus 6 - fa-cog + gear @@ -710,7 +710,7 @@ wcf.acp.menu.link.cronjob.list admin.management.canManageCronjob 3 - fa-plus + plus wcf\acp\page\CacheListPage diff --git a/wcfsetup/install/files/acp/templates/pageMenu.tpl b/wcfsetup/install/files/acp/templates/pageMenu.tpl index c525f463ee..7bbdea9a44 100644 --- a/wcfsetup/install/files/acp/templates/pageMenu.tpl +++ b/wcfsetup/install/files/acp/templates/pageMenu.tpl @@ -6,7 +6,7 @@ {foreach from=$__wcf->getACPMenu()->getMenuItems('') item=_sectionMenuItem}
  • - + {@$_sectionMenuItem->getIcon()->toHtml(32)} {@$_sectionMenuItem}
  • @@ -38,7 +38,9 @@ {@$_menuItem} {foreach from=$_subMenuItems item=_subMenuItem} - + + {@$_subMenuItem->getIcon()->toHtml(16)} + {/foreach} {/if} diff --git a/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php b/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php index afad6d6ae6..7f1a4f508e 100644 --- a/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php +++ b/wcfsetup/install/files/lib/data/acp/menu/item/ACPMenuItem.class.php @@ -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; + } } 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 e32d55aae3..ffd627270c 100644 --- a/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php +++ b/wcfsetup/install/files/lib/system/package/plugin/ACPMenuPackageInstallationPlugin.class.php @@ -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 -- 2.20.1