From 40a22ea09ed82dccb35541e95fc6fd61d2152669 Mon Sep 17 00:00:00 2001 From: thomas-topway-it Date: Tue, 30 Jul 2024 00:17:55 +0400 Subject: [PATCH] Add user avatar in PersonalTools (#400) * add user-avatar * add userAvatar * fix comment * add avatar * fix comment * added global parameter chameleonDisableAvatar * restore Fix deprecated Hooks usage --------- Co-authored-by: Bernhard Krabina (cherry picked from commit ab5b9cc0e28a5cc6a4f2657c06249c44d93a67e3) --- .../styles/Components/NavbarHorizontal.scss | 14 ++++ .../NavbarHorizontal/PersonalTools.php | 67 ++++++++++++++++--- 2 files changed, 73 insertions(+), 8 deletions(-) diff --git a/resources/styles/Components/NavbarHorizontal.scss b/resources/styles/Components/NavbarHorizontal.scss index 0798b080..b94d3867 100644 --- a/resources/styles/Components/NavbarHorizontal.scss +++ b/resources/styles/Components/NavbarHorizontal.scss @@ -155,4 +155,18 @@ a.navbar-more-tools, a.navbar-usernotloggedin, a.navbar-userloggedin, a.navbar-tool-link, a:visited.navbar-tool-link { color: $navbar-light-color; } + + .navbar-tool.avatar { + background: white; + border-radius: 99px; + overflow: hidden; + } + + a.navbar-userloggedin-avatar { + width: 41px; + height: 41px; + background-size: contain; + background-repeat: no-repeat; + background-position: center; + } } diff --git a/src/Components/NavbarHorizontal/PersonalTools.php b/src/Components/NavbarHorizontal/PersonalTools.php index 4fd0c991..c79208e3 100644 --- a/src/Components/NavbarHorizontal/PersonalTools.php +++ b/src/Components/NavbarHorizontal/PersonalTools.php @@ -36,6 +36,7 @@ * Provides a PersonalTools component to be included in a NavbarHorizontal component. * * @author Stephan Gambke + * @reviewer thomas-topway-it - user-avatar (for KM-A) * @since 1.6 * @ingroup Skins */ @@ -54,6 +55,9 @@ class PersonalTools extends Component { private const SHOW_USER_NAME_YES = 'yes'; private const ATTR_PROMOTE_LONE_ITEMS = 'promoteLoneItems'; + /** @var avatarUrl */ + protected $avatarUrl = null; + /** * @return String * @throws \FatalError @@ -61,6 +65,8 @@ class PersonalTools extends Component { */ public function getHtml() { $tools = $this->getSkinTemplate()->getPersonalTools(); + + $this->setUserAvatar(); // Flatten classes to avoid MW bug: https://phabricator.wikimedia.org/T262160 // NB: This bug is finally fixed in MW >=1.36. @@ -99,7 +105,8 @@ public function getHtml() { return $echoHtml . $this->indent() . '' . $this->indent() . '