<xs:attribute name="name" type="woltlab_varchar" use="required" />
</xs:complexType>
+ <xs:complexType name="usermenuitem_icon">
+ <xs:attribute name="solid" type="xs:boolean" />
+ </xs:complexType>
+
<!-- imported/updated page menu item element -->
<xs:complexType name="usermenuitem_import">
<xs:complexContent>
<xs:element name="permissions" type="xs:string" minOccurs="0" />
<xs:element name="controller" type="woltlab_varchar_nullable" minOccurs="0" />
<xs:element name="iconclassname" type="woltlab_varchar_nullable" minOccurs="0" />
- <xs:element name="classname" type="woltlab_varchar_nullable" minOccurs="0" />
+ <xs:element name="classname" type="usermenuitem_icon" minOccurs="0" />
<xs:element name="parent" type="woltlab_varchar_nullable" minOccurs="0" />
<xs:element name="showorder" type="xs:unsignedInt" minOccurs="0" />
</xs:all>
{foreach from=$__wcf->getUserMenu()->getUserMenuItems() item=menuItem}
<div class="userMenuItem userMenuItemNarrow userMenuItemSingleLine" data-category="{$menuItem[category]->menuItem}">
<div class="userMenuItemImage">
- <span class="icon icon32 {$menuItem[category]->getIconClassName()}"></span>
+ {@$menuItem[category]->getIcon()->toHtml(32)}
</div>
<div class="userMenuItemContent">
<a href="{$menuItem[link]}" class="userMenuItemLink">
<!-- profile -->
<usermenuitem name="wcf.user.menu.profile">
<showorder>1</showorder>
- <iconclassname>fa-user</iconclassname>
+ <iconclassname>user</iconclassname>
</usermenuitem>
<usermenuitem name="wcf.user.menu.profile.accountManagement">
<controller>wcf\form\AccountManagementForm</controller>
<!-- settings -->
<usermenuitem name="wcf.user.menu.settings">
<showorder>2</showorder>
- <iconclassname>fa-cog</iconclassname>
+ <iconclassname>cog</iconclassname>
</usermenuitem>
<usermenuitem name="wcf.user.menu.settings.notification">
<controller>wcf\form\NotificationSettingsForm</controller>
<!-- community -->
<usermenuitem name="wcf.user.menu.community">
<showorder>3</showorder>
- <iconclassname>fa-globe</iconclassname>
+ <iconclassname>globe</iconclassname>
</usermenuitem>
<usermenuitem name="wcf.user.menu.community.following">
<controller>wcf\page\FollowingPage</controller>
use wcf\data\ITitledObject;
use wcf\data\ProcessibleDatabaseObject;
+use wcf\system\exception\SystemException;
use wcf\system\menu\ITreeMenuItem;
use wcf\system\menu\user\DefaultUserMenuItemProvider;
use wcf\system\menu\user\IUserMenuItemProvider;
use wcf\system\Regex;
use wcf\system\request\LinkHandler;
+use wcf\system\style\exception\InvalidIconFormat;
+use wcf\system\style\exception\UnknownIcon;
+use wcf\system\style\FontAwesomeIcon;
use wcf\system\WCF;
/**
}
/**
- * Returns FontAwesome icon class name.
- *
- * @return string
+ * @since 6.0
*/
- public function getIconClassName()
+ public function getIcon(): ?FontAwesomeIcon
{
- return $this->iconClassName ?: 'fa-bars';
+ if ($this->iconClassName && !\str_starts_with($this->iconClassName, 'fa-')) {
+ return FontAwesomeIcon::fromString($this->iconClassName);
+ }
+
+ return FontAwesomeIcon::fromValues('bars', false);
}
}
$result['className'] = $data['elements']['classname'];
}
- // FontAwesome icon name
- if (
- !empty($data['elements']['iconclassname'])
- && \preg_match('~^fa\-[a-z\-]+$~', $data['elements']['iconclassname'])
- ) {
- $result['iconClassName'] = $data['elements']['iconclassname'];
+ if (isset($data['elements']['iconClassName'])) {
+ $result['iconClassName'] = $data['elements']['iconClassName'];
}
return $result;
}
+ /**
+ * @inheritDoc
+ */
+ protected function getElement(\DOMXPath $xpath, array &$elements, \DOMElement $element)
+ {
+ if ($element->tagName === 'iconclassname') {
+ $solid = $element->getAttribute('solid');
+ $elements['iconClassName'] = \sprintf(
+ "%s;%s",
+ $element->nodeValue,
+ $solid === 'true' ? 'true' : 'false'
+ );
+ } else {
+ $elements[$element->tagName] = $element->nodeValue;
+ }
+ }
+
/**
* @inheritDoc
* @since 5.2