From 8fc3c840d91153b450fa32fbe720a66405389575 Mon Sep 17 00:00:00 2001 From: BentiGorlich Date: Fri, 14 Jun 2024 12:38:44 +0200 Subject: [PATCH] Add theme settings for showing avatars - add theme settings to show users' avatars and magazines' icons --- .../User/ThemeSettingsController.php | 4 +++ .../layout/_options_appearance.html.twig | 5 ++++ templates/modlog/_blocks.html.twig | 30 +++++++++---------- templates/modlog/front.html.twig | 7 +++++ templates/modlog/magazine.html.twig | 9 +++++- 5 files changed, 38 insertions(+), 17 deletions(-) diff --git a/src/Controller/User/ThemeSettingsController.php b/src/Controller/User/ThemeSettingsController.php index de6b6da50..7bb93808d 100644 --- a/src/Controller/User/ThemeSettingsController.php +++ b/src/Controller/User/ThemeSettingsController.php @@ -41,6 +41,8 @@ class ThemeSettingsController extends AbstractController public const KBIN_SUBSCRIPTIONS_SIDEBARS_SAME_SIDE = 'kbin_subscriptions_sidebars_same_side'; public const KBIN_SUBSCRIPTIONS_LARGE_PANEL = 'kbin_subscriptions_large_panel'; public const KBIN_SUBSCRIPTIONS_SHOW_MAGAZINE_ICON = 'kbin_subscriptions_show_magazine_icon'; + public const MBIN_MODERATION_LOG_SHOW_USER_AVATARS = 'mbin_moderation_log_show_user_avatars'; + public const MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS = 'mbin_moderation_log_show_magazine_icons'; public const CLASSIC = 'classic'; public const CHAT = 'chat'; @@ -96,6 +98,8 @@ class ThemeSettingsController extends AbstractController self::KBIN_SUBSCRIPTIONS_SIDEBARS_SAME_SIDE, self::KBIN_SUBSCRIPTIONS_LARGE_PANEL, self::KBIN_SUBSCRIPTIONS_SHOW_MAGAZINE_ICON, + self::MBIN_MODERATION_LOG_SHOW_USER_AVATARS, + self::MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS, ]; public const VALUES = [ diff --git a/templates/layout/_options_appearance.html.twig b/templates/layout/_options_appearance.html.twig index bd3e92095..481d32dc9 100644 --- a/templates/layout/_options_appearance.html.twig +++ b/templates/layout/_options_appearance.html.twig @@ -51,4 +51,9 @@ {{ component('settings_row_enum', {label: 'comment_reply_position'|trans, help: 'comment_reply_position_help'|trans, settingsKey: 'KBIN_COMMENTS_REPLY_POSITION', values: [ {name: 'position_top'|trans , value: 'TOP'}, {name: 'position_bottom'|trans , value: 'BOTTOM' } ], defaultValue: 'TOP' } ) }} {{ component('settings_row_switch', {label: 'show_avatars_on_comments'|trans, help: 'show_avatars_on_comments_help'|trans, settingsKey: 'KBIN_COMMENTS_SHOW_USER_AVATAR', defaultValue: true}) }} + {{ 'mod_log'|trans }} +
+ {{ component('settings_row_switch', {label: 'show_users_avatars'|trans, settingsKey: 'MBIN_MODERATION_LOG_SHOW_USER_AVATARS', defaultValue: false}) }} + {{ component('settings_row_switch', {label: 'show_magazines_icons'|trans, settingsKey: 'MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS', defaultValue: false}) }} +
diff --git a/templates/modlog/_blocks.html.twig b/templates/modlog/_blocks.html.twig index 68b0f1388..781abb443 100644 --- a/templates/modlog/_blocks.html.twig +++ b/templates/modlog/_blocks.html.twig @@ -1,46 +1,46 @@ {% block log_entry_deleted %} - {{ component('user_inline', {user: log.user}) }} {{ 'removed_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.entry.shortTitle(300) }} {% endblock %} {% block log_entry_restored %} - {{ component('user_inline', {user: log.user}) }} {{ 'restored_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_thread_by'|trans|lower }} {{ component('user_inline', {user: log.entry.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.entry.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.entry.shortTitle(300) }} {% endblock %} {% block log_entry_comment_deleted %} - {{ component('user_inline', {user: log.user}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.comment.shortTitle(300) }} {% endblock %} {% block log_entry_comment_restored %} - {{ component('user_inline', {user: log.user}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.comment.shortTitle(300) }} {% endblock %} {% block log_post_deleted %} - {{ component('user_inline', {user: log.user}) }} {{ 'removed_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.post.shortTitle(300) }} {% endblock %} {% block log_post_restored %} - {{ component('user_inline', {user: log.user}) }} {{ 'restored_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_post_by'|trans|lower }} {{ component('user_inline', {user: log.post.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.post.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.post.shortTitle(300) }} {% endblock %} {% block log_post_comment_deleted %} - {{ component('user_inline', {user: log.user}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'removed_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.comment.shortTitle(300) }} {% endblock %} {% block log_post_comment_restored %} - {{ component('user_inline', {user: log.user}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: true }) }}{% endif %} - + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {{ 'restored_comment_by'|trans|lower }} {{ component('user_inline', {user: log.comment.user}) }}{% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.comment.magazine, showAvatar: showIcons }) }}{% endif %} - {{ log.comment.shortTitle(300) }} {% endblock %} {% block log_ban %} - {{ component('user_inline', {user: log.user}) }} {% if log.meta is same as 'ban' %}{{ 'he_banned'|trans|lower }}{% else %}{{ 'he_unbanned'|trans|lower }}{% endif %} {{ component('user_inline', {user: log.ban.user}) }} - {% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.ban.magazine, showAvatar: true }) }}{% endif %}{% if log.ban.reason %} - {{ log.ban.reason }}{% endif %} + {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {% if log.meta is same as 'ban' %}{{ 'he_banned'|trans|lower }}{% else %}{{ 'he_unbanned'|trans|lower }}{% endif %} {{ component('user_inline', {user: log.ban.user}) }} + {% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.ban.magazine, showAvatar: showIcons }) }}{% endif %}{% if log.ban.reason %} - {{ log.ban.reason }}{% endif %} {% endblock %} {% block log_moderator_add %} @@ -49,9 +49,8 @@ {% else %} {{ 'someone'|trans }} {% endif %} - {{ 'magazine_log_mod_added'|trans }} - {% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.magazine, showAvatar: true }) }}{% endif %} - : {{ component('user_inline', {user: log.user}) }} + {{ 'magazine_log_mod_added'|trans -}} + {% if showMagazine %} {{ 'in'|trans|lower }} {{ component('magazine_inline', {magazine: log.magazine, showAvatar: showIcons }) -}}{%- endif -%}: {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {% endblock %} {% block log_moderator_remove %} @@ -60,7 +59,6 @@ {% else %} {{ 'someone'|trans }} {% endif %} - {{ 'magazine_log_mod_removed'|trans }} - {% if showMagazine %} {{ 'from'|trans|lower }} {{ component('magazine_inline', {magazine: log.magazine, showAvatar: true }) }}{% endif %} - : {{ component('user_inline', {user: log.user}) }} + {{ 'magazine_log_mod_removed'|trans -}} + {% if showMagazine %} {{ 'from'|trans|lower }} {{ component('magazine_inline', {magazine: log.magazine, showAvatar: showIcons }) -}}{%- endif -%}: {{ component('user_inline', {user: log.user, showAvatar: showAvatars}) }} {% endblock %} diff --git a/templates/modlog/front.html.twig b/templates/modlog/front.html.twig index 3e357846c..6bc0864f1 100644 --- a/templates/modlog/front.html.twig +++ b/templates/modlog/front.html.twig @@ -1,4 +1,9 @@ {% extends 'base.html.twig' %} +{% set V_TRUE = constant('App\\Controller\\User\\ThemeSettingsController::TRUE') %} +{% set MBIN_MODERATION_LOG_SHOW_USER_AVATARS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_USER_AVATARS') %} +{% set showAvatars = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_USER_AVATARS) is same as V_TRUE %} +{% set MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS') %} +{% set showIcons = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS) is same as V_TRUE %} {% use 'modlog/_blocks.html.twig' %} {%- block title -%} @@ -28,6 +33,8 @@ {%- with { log: log, showMagazine: true, + showAvatars: showAvatars, + showIcons: showIcons, } only -%} {{ block(log.type) }} {%- endwith -%} diff --git a/templates/modlog/magazine.html.twig b/templates/modlog/magazine.html.twig index cddfdba5c..a34c84cf0 100644 --- a/templates/modlog/magazine.html.twig +++ b/templates/modlog/magazine.html.twig @@ -1,11 +1,16 @@ {% extends 'base.html.twig' %} +{% set V_TRUE = constant('App\\Controller\\User\\ThemeSettingsController::TRUE') %} +{% set MBIN_MODERATION_LOG_SHOW_USER_AVATARS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_USER_AVATARS') %} +{% set showAvatars = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_USER_AVATARS) is same as V_TRUE %} +{% set MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS = constant('App\\Controller\\User\\ThemeSettingsController::MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS') %} +{% set showIcons = app.request.cookies.get(MBIN_MODERATION_LOG_SHOW_MAGAZINE_ICONS) is same as V_TRUE %} {% use 'modlog/_blocks.html.twig' %} {%- block title -%} {{- 'magazines'|trans }} - {{ parent() -}} {%- endblock -%} -{% block mainClass %}page-magazines{% endblock %} +{% block mainClass %}page-magazines page-modlog{% endblock %} {% block header_nav %} {% endblock %} @@ -24,6 +29,8 @@ {%- with { log: log, showMagazine: false, + showAvatars: showAvatars, + showIcons: showIcons, } only -%} {{ block(log.type) }} {%- endwith -%}