mirror of
https://gerrit.wikimedia.org/r/mediawiki/skins/Vector.git
synced 2024-11-14 11:15:33 +00:00
d1c0e6cd6f
The languages alert is misleading when there are no languages and the user has JS disabled. This change adds a class to the alert if there are 0 languages, and then adds "display: none" to the alert if the client-nojs class is present. This is the same approach being used for the language switcher button. Bug: T326185 Change-Id: Iee292d661ed1f47700f588053712f5f547022b17
47 lines
1.1 KiB
PHP
47 lines
1.1 KiB
PHP
<?php
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
use Html;
|
|
use Skin;
|
|
|
|
/**
|
|
* VectorComponentMainMenuActionLanguageSwitchAlert component
|
|
*/
|
|
class VectorComponentMainMenuActionLanguageSwitchAlert implements VectorComponent {
|
|
/** @var Skin */
|
|
private $skin;
|
|
/** @var int */
|
|
private $numLanguages;
|
|
|
|
/**
|
|
* @param Skin $skin
|
|
* @param int $numLanguages
|
|
*/
|
|
public function __construct( Skin $skin, int $numLanguages ) {
|
|
$this->skin = $skin;
|
|
$this->numLanguages = $numLanguages;
|
|
}
|
|
|
|
/**
|
|
* @inheritDoc
|
|
*/
|
|
public function getTemplateData(): array {
|
|
$skin = $this->skin;
|
|
$languageSwitchAlert = [
|
|
'html-content' => Html::noticeBox(
|
|
$skin->msg( 'vector-language-redirect-to-top' )->parse(),
|
|
'vector-language-sidebar-alert'
|
|
),
|
|
];
|
|
$headingOptions = [
|
|
'heading' => $skin->msg( 'vector-languages' )->plain(),
|
|
];
|
|
|
|
$component = new VectorComponentMainMenuAction(
|
|
'lang-alert', $skin, $languageSwitchAlert, $headingOptions,
|
|
( $this->numLanguages === 0 ? 'vector-main-menu-action-lang-alert-empty' : '' )
|
|
);
|
|
return $component->getTemplateData();
|
|
}
|
|
}
|