2022-10-27 19:36:08 +00:00
|
|
|
<?php
|
|
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
|
|
|
|
use Html;
|
|
|
|
use Skin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* VectorComponentMainMenuActionLanguageSwitchAlert component
|
|
|
|
*/
|
|
|
|
class VectorComponentMainMenuActionLanguageSwitchAlert implements VectorComponent {
|
|
|
|
/** @var Skin */
|
|
|
|
private $skin;
|
2023-05-19 16:45:26 +00:00
|
|
|
/** @var int */
|
|
|
|
private $numLanguages;
|
2022-10-27 19:36:08 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* @param Skin $skin
|
2023-05-19 16:45:26 +00:00
|
|
|
* @param int $numLanguages
|
2022-10-27 19:36:08 +00:00
|
|
|
*/
|
2023-05-19 16:45:26 +00:00
|
|
|
public function __construct( Skin $skin, int $numLanguages ) {
|
2022-10-27 19:36:08 +00:00
|
|
|
$this->skin = $skin;
|
2023-05-19 16:45:26 +00:00
|
|
|
$this->numLanguages = $numLanguages;
|
2022-10-27 19:36:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @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(
|
2023-05-19 16:45:26 +00:00
|
|
|
'lang-alert', $skin, $languageSwitchAlert, $headingOptions,
|
|
|
|
( $this->numLanguages === 0 ? 'vector-main-menu-action-lang-alert-empty' : '' )
|
2022-10-27 19:36:08 +00:00
|
|
|
);
|
|
|
|
return $component->getTemplateData();
|
|
|
|
}
|
|
|
|
}
|