2023-11-21 17:01:04 +00:00
|
|
|
<?php
|
|
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
|
|
|
|
use MediaWiki\Skins\Vector\Constants;
|
|
|
|
use MediaWiki\Skins\Vector\FeatureManagement\FeatureManager;
|
|
|
|
use MessageLocalizer;
|
|
|
|
|
|
|
|
/**
|
2024-02-26 19:58:28 +00:00
|
|
|
* VectorComponentClientPrefs component
|
2023-11-21 17:01:04 +00:00
|
|
|
*/
|
|
|
|
class VectorComponentClientPrefs implements VectorComponent {
|
|
|
|
|
|
|
|
/** @var MessageLocalizer */
|
|
|
|
private $localizer;
|
|
|
|
|
|
|
|
/** @var bool */
|
|
|
|
private $isPinned;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public const ID = 'vector-client-prefs';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param MessageLocalizer $localizer
|
|
|
|
* @param FeatureManager $featureManager
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
MessageLocalizer $localizer,
|
|
|
|
FeatureManager $featureManager
|
|
|
|
) {
|
|
|
|
$this->localizer = $localizer;
|
2024-04-10 21:08:22 +00:00
|
|
|
// FIXME: isPinned is no longer accurate because the appearance menu uses client preferences
|
2023-11-21 17:01:04 +00:00
|
|
|
$this->isPinned = $featureManager->isFeatureEnabled( Constants::FEATURE_CLIENT_PREFS_PINNED );
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getTemplateData(): array {
|
|
|
|
$pinnedContainer = new VectorComponentPinnableContainer( self::ID, $this->isPinned );
|
|
|
|
$pinnableElement = new VectorComponentPinnableElement( self::ID );
|
|
|
|
$pinnableHeader = new VectorComponentPinnableHeader(
|
|
|
|
$this->localizer,
|
|
|
|
$this->isPinned,
|
|
|
|
// Name
|
|
|
|
self::ID,
|
|
|
|
// Feature name
|
|
|
|
'client-prefs-pinned'
|
|
|
|
);
|
|
|
|
|
|
|
|
$data = $pinnableElement->getTemplateData() +
|
|
|
|
$pinnedContainer->getTemplateData();
|
|
|
|
|
|
|
|
return $data + [
|
|
|
|
'data-pinnable-header' => $pinnableHeader->getTemplateData()
|
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|