diff --git a/includes/FluentTemplate.php b/includes/FluentTemplate.php index e08ec19..3c39a45 100644 --- a/includes/FluentTemplate.php +++ b/includes/FluentTemplate.php @@ -12,6 +12,7 @@ class FluentTemplate extends BaseTemplate { * Outputs the entire contents of the page */ public function execute() { + $skinConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('Fluent'); $html = ''; $html .= $this->get( 'headelement' ); $html .= Html::rawElement( 'header', [ 'id' => 'fabric-heading' ], @@ -34,7 +35,7 @@ public function execute() { [ 'id' => 'user-icon', 'title' => 'User icon' ], Html::rawElement( 'div', - [ 'id' => 'user-icon-img', 'style' => 'background-image: url("' . $this->getGravatarUrl() . '");' ] + [ 'id' => 'user-icon-img', 'style' => 'background-image: url("' . $this->getGravatarUrl($skinConfig->get('FluentDisableGravatar')) . '");' ] ) ) . $this->getUserLinks() @@ -310,24 +311,15 @@ protected function getPageLinks() { * @param bool $disableGravatar Whether or not to use Gravatar * @return string html */ - protected function getGravatarUrl() { - $skinConfig = MediaWikiServices::getInstance()->getConfigFactory()->makeConfig('Fluent'); - $isGravatarEnabled = $skinConfig->get('FluentDisableGravatar'); - $skin = $this->getSkin(); - $genericFace = - $this->config->get( 'CanonicalServer' ) . $skin->getConfig()->get( 'StylePath' ) . - '/Fluent/resources/default-user.png'; - if ( !$isGravatarEnabled ) { - return $genericFace; - } else { - $gravatarUrl = - 'https://www.gravatar.com/avatar/' . - md5( strtolower( trim( $this->getSkin()->getUser()->getEmail() ) ) ) . '?d=' . - urlencode( $genericFace ) . '&s=' . 100; - - return $gravatarUrl; - } + protected function getGravatarUrl(bool $disableGravatar = false) { + $skin = $this->getSkin(); + $genericFace = $this->config->get('CanonicalServer') . $skin->getConfig()->get('StylePath') . '/Fluent/resources/default-user.png'; + if ($disableGravatar) { + return $genericFace; } + $gravatarUrl = 'https://www.gravatar.com/avatar/' . md5(strtolower(trim($this->getSkin()->getUser()->getEmail()))) . '?d=' . urlencode($genericFace) . '&s=' . 100; + return $gravatarUrl; + } /** * Generates user tools menu @@ -560,10 +552,10 @@ protected function getPortlet( $name, $content, $msg = null, $setOptions = [] ) } $body = Html::rawElement( $options['body-wrapper'], $bodyDivOptions, $contentText . - $this->getSkin()->getAfterPortlet( $name ) + $this->getAfterPortlet( $name ) ); } else { - $body = $contentText . $this->getSkin()->getAfterPortlet( $name ); + $body = $contentText . $this->getAfterPortlet( $name ); } $html = Html::rawElement( 'div', $divOptions, diff --git a/skin.json b/skin.json index 03e7707..915372d 100644 --- a/skin.json +++ b/skin.json @@ -7,6 +7,12 @@ "namemsg": "fluent", "license-name": "CC0-1.0", "type": "skin", + "config": { + "FluentDisableGravatar": { + "value": false, + "help": "Control whether or not we should use Gravatar. You should set this to true for wikis not available over the internet" + } + }, "requires": { "MediaWiki": ">= 1.35.0" }, @@ -62,14 +68,5 @@ "SkinFluent": "includes/SkinFluent.php", "FluentTemplate": "includes/FluentTemplate.php" }, - "ConfigRegistry":{ - "Fluent":"GlobalVarConfig::newInstance" - }, - "config": { - "FluentDisableGravatar": { - "value": false, - "help": "Control whether or not we should use Gravatar. You should set this to true for wikis not available over the internet" - } - }, "manifest_version": 1 }