diff --git a/core/classes/Templates/AssetTree.php b/core/classes/Templates/AssetTree.php index a89b1c28ed..1609d6a95c 100644 --- a/core/classes/Templates/AssetTree.php +++ b/core/classes/Templates/AssetTree.php @@ -84,6 +84,7 @@ class AssetTree { * @var string Fomantic-UI bundle v2.8 (CSS + JS) */ public const FOMANTIC_UI = 'FOMANTIC_UI'; + public const ICON_PICKER = 'ICON_PICKER'; /** * @var mixed Tree of all available assets, with their applicable CSS/JS files. @@ -254,5 +255,13 @@ class AssetTree { self::JQUERY, ] ], + self::ICON_PICKER => [ + 'js' => [ + 'vendor/@migliori/universal-icon-picker/assets/js/universal-icon-picker.min.js', + ], + 'css' => [ + 'vendor/fomantic-ui/dist/components/icon.min.css', + ] + ], ]; } diff --git a/core/includes/updates/203.php b/core/includes/updates/203.php index ca909a2e35..eb4607e1ad 100644 --- a/core/includes/updates/203.php +++ b/core/includes/updates/203.php @@ -17,10 +17,46 @@ public function run(): void { } Util::setSetting('minecraft_query_interval', $query_interval); } + + // Update icon definitions to just be class names instead of full HTML + $announcements = DB::getInstance()->get('announcements', ['icon', '<>', ''])->results(); + foreach ($announcements as $announcement) { + DB::getInstance()->update('announcements', $announcement->id, [ + 'icon' => $this->extractIconClasses($announcement->icon) + ]); + } + (new Announcements($cache))->resetCache(); + + $custom_pages = DB::getInstance()->get('custom_pages', ['icon', '<>', ''])->results(); + foreach ($custom_pages as $custom_page) { + DB::getInstance()->update('custom_pages', $custom_page->id, [ + 'icon' => $this->extractIconClasses($custom_page->icon) + ]); + } + + $forums = DB::getInstance()->get('forums', ['icon', '<>', ''])->results(); + foreach ($forums as $forum) { + DB::getInstance()->update('forums', $forum->id, [ + 'icon' => $this->extractIconClasses($forum->icon) + ]); + } + + $cache->setCache('navbar_icons'); + $icons = $cache->retrieveAll(); + foreach ($icons as $key => $icon) { + $cache->store($key, $this->extractIconClasses($icon)); + } // Add all groups to member list selectable groups Util::setSetting('member_list_viewable_groups', json_encode(array_map(static fn (Group $group) => $group->id, Group::all())), 'Members'); $this->setVersion('2.1.0'); } + + /** + * Transform "" to "fas fa-home" + */ + private function extractIconClasses(string $icon_html): string { + return preg_replace('/<\/i>/', '$1', $icon_html); + } }; diff --git a/custom/panel_templates/Default/core/announcements_form.tpl b/custom/panel_templates/Default/core/announcements_form.tpl index 1a0c9d8ad4..309f5e17b3 100644 --- a/custom/panel_templates/Default/core/announcements_form.tpl +++ b/custom/panel_templates/Default/core/announcements_form.tpl @@ -89,11 +89,24 @@
- - + +
+
+ + + +
+ +
@@ -246,9 +259,20 @@ }).children().click(function (e) { e.stopPropagation(); }); + + new UniversalIconPicker('#nav-icon-picker', { + allowEmpty: false, + iconLibraries: [ + 'fomantic-ui.min.json', + 'font-awesome.min.json', + ], + onSelect: (icon) => { + document.getElementById('icon').value = icon.iconClass; + } + }); }); - \ No newline at end of file + diff --git a/custom/panel_templates/Default/core/navigation.tpl b/custom/panel_templates/Default/core/navigation.tpl index 81792b6d9a..4b8a343c4c 100644 --- a/custom/panel_templates/Default/core/navigation.tpl +++ b/custom/panel_templates/Default/core/navigation.tpl @@ -42,58 +42,68 @@
-
{$INFO}
+
{$INFO}

{$NAVBAR_ORDER_INSTRUCTIONS}

{$NAVBAR_ICON_INSTRUCTIONS}


{foreach from=$NAV_ITEMS key=key item=item} - {$item.title|escape} -
-
-
- - -
-
- - + {$item.title|escape} +
+
+
+ + +
+
+ +
+
+ + + +
+ +
+
-
- {if isset($item.items) && count($item.items)} -
- {$item.title|escape} » {$DROPDOWN_ITEMS} -
- {foreach from=$item.items key=dropdown_key item=dropdown_item} - {$dropdown_item.title|escape} -
-
-
- - -
-
- - -
-
-
- {/foreach} - {/if} + {if isset($item.items) && count($item.items)} +
+ {$item.title|escape} » {$DROPDOWN_ITEMS} +
+ {foreach from=$item.items key=dropdown_key item=dropdown_item} + {$dropdown_item.title|escape} +
+
+
+ + +
+
+ + +
+
+
+ {/foreach} + {/if} {/foreach}
@@ -130,6 +140,24 @@ {include file='scripts.tpl'} + + - \ No newline at end of file + diff --git a/custom/panel_templates/Default/forum/forums_edit.tpl b/custom/panel_templates/Default/forum/forums_edit.tpl index d16e5eda4f..d01af9e681 100644 --- a/custom/panel_templates/Default/forum/forums_edit.tpl +++ b/custom/panel_templates/Default/forum/forums_edit.tpl @@ -78,9 +78,24 @@
- - + +
+
+ + + +
+ +
@@ -387,9 +402,20 @@ $("#InputHooks").select2({ placeholder: "{$NO_ITEM_SELECTED}" }); $("#InputDefaultLabels").select2({ placeholder: "{$NO_ITEM_SELECTED}" }); + + new UniversalIconPicker('#nav-icon-picker', { + allowEmpty: false, + iconLibraries: [ + 'fomantic-ui.min.json', + 'font-awesome.min.json', + ], + onSelect: (icon) => { + document.getElementById('InputIcon').value = icon.iconClass; + } + }); }); - \ No newline at end of file + diff --git a/custom/panel_templates/Default/forum/forums_new_step_1.tpl b/custom/panel_templates/Default/forum/forums_new_step_1.tpl index 13ffbbbcbf..82c445e32b 100644 --- a/custom/panel_templates/Default/forum/forums_new_step_1.tpl +++ b/custom/panel_templates/Default/forum/forums_new_step_1.tpl @@ -71,10 +71,24 @@ class="form-control" rows="3">{$FORUM_DESCRIPTION_VALUE}
- - + +
+
+ + + +
+ +
@@ -128,8 +142,21 @@ function showCancelModal() { $('#cancelModal').modal().show(); } + + $(document).ready(function () { + new UniversalIconPicker('#nav-icon-picker', { + allowEmpty: false, + iconLibraries: [ + 'fomantic-ui.min.json', + 'font-awesome.min.json', + ], + onSelect: (icon) => { + document.getElementById('forum_icon').value = icon.iconClass; + } + }); + }); - \ No newline at end of file + diff --git a/custom/panel_templates/Default/includes/alerts.tpl b/custom/panel_templates/Default/includes/alerts.tpl index 0489aec01c..cf6f4c155d 100644 --- a/custom/panel_templates/Default/includes/alerts.tpl +++ b/custom/panel_templates/Default/includes/alerts.tpl @@ -3,7 +3,7 @@ -
{$SUCCESS_TITLE}
+
{$SUCCESS_TITLE}
{$SUCCESS}
{/if} @@ -12,11 +12,11 @@ -
{$ERRORS_TITLE}
+
{$ERRORS_TITLE}
    {foreach from=$ERRORS item=error}
  • {$error}
  • {/foreach}
-{/if} \ No newline at end of file +{/if} diff --git a/custom/templates/DefaultRevamp/css/custom.css b/custom/templates/DefaultRevamp/css/custom.css index 2c996acedb..366ab30e0c 100755 --- a/custom/templates/DefaultRevamp/css/custom.css +++ b/custom/templates/DefaultRevamp/css/custom.css @@ -983,6 +983,23 @@ select { } } +/* + Fix icons displaying small as forum icons + */ +.one.wide.column.mobile.hidden > i:first-child { + font-size: 2.3em; +} + +/* + Fix FontAwesome icons displaying strangely announcement icons + Styles copied from Fomantic UI's .message>.icon class + */ +.ui.icon.message.announcement > i:first-child:not(.icon) { + font-size: 3em; + margin-right: .6em; + opacity: .8; +} + #darkmode { display: inline-block; } diff --git a/custom/templates/DefaultRevamp/forum/forum_index.tpl b/custom/templates/DefaultRevamp/forum/forum_index.tpl index c148ad8faf..efed08482c 100755 --- a/custom/templates/DefaultRevamp/forum/forum_index.tpl +++ b/custom/templates/DefaultRevamp/forum/forum_index.tpl @@ -55,33 +55,34 @@ {foreach from=$forum.subforums item=subforum} {if $subforum->redirect_forum neq 1}
- @@ -24,76 +27,83 @@