2022-12-02 18:09:52 +00:00
|
|
|
<?php
|
|
|
|
namespace MediaWiki\Skins\Vector\Components;
|
|
|
|
|
|
|
|
use Skin;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* VectorComponentMainMenu component
|
|
|
|
*/
|
|
|
|
class VectorComponentPageTools implements VectorComponent {
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
private $toolbox;
|
|
|
|
|
|
|
|
/** @var array */
|
|
|
|
private $actionsMenu;
|
|
|
|
|
2022-12-07 22:15:31 +00:00
|
|
|
/** @var bool */
|
|
|
|
private $isPinned;
|
|
|
|
|
2022-12-02 18:09:52 +00:00
|
|
|
/** @var Skin */
|
|
|
|
private $skin;
|
|
|
|
|
2022-12-07 22:15:31 +00:00
|
|
|
/** @var VectorComponentPinnableHeader|null */
|
2022-12-02 18:09:52 +00:00
|
|
|
private $pinnableHeader;
|
|
|
|
|
|
|
|
/** @var string */
|
|
|
|
public const TOOLBOX_ID = 'p-tb';
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @param array $toolbox
|
|
|
|
* @param array $actionsMenu
|
2022-12-07 22:15:31 +00:00
|
|
|
* @param bool $isPinned
|
2022-12-02 18:09:52 +00:00
|
|
|
* @param Skin $skin
|
|
|
|
*/
|
|
|
|
public function __construct(
|
|
|
|
array $toolbox,
|
|
|
|
array $actionsMenu,
|
2022-12-07 22:15:31 +00:00
|
|
|
bool $isPinned,
|
2022-12-02 18:09:52 +00:00
|
|
|
Skin $skin
|
|
|
|
) {
|
2022-12-07 22:15:31 +00:00
|
|
|
$user = $skin->getUser();
|
2022-12-02 18:09:52 +00:00
|
|
|
$this->toolbox = $toolbox;
|
|
|
|
$this->actionsMenu = $actionsMenu;
|
2022-12-07 22:15:31 +00:00
|
|
|
$this->isPinned = $isPinned;
|
|
|
|
$this->pinnableHeader = $user->isRegistered() ? new VectorComponentPinnableHeader(
|
|
|
|
$skin->getContext(),
|
|
|
|
$isPinned,
|
|
|
|
// Name
|
|
|
|
'vector-page-tools',
|
|
|
|
// Feature name
|
|
|
|
'page-tools-pinned'
|
|
|
|
) : null;
|
2022-12-02 18:09:52 +00:00
|
|
|
$this->skin = $skin;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
|
|
|
public function getTemplateData(): array {
|
|
|
|
$menusData = [ $this->toolbox, $this->actionsMenu ];
|
2022-12-07 01:05:22 +00:00
|
|
|
$id = 'vector-page-tools';
|
|
|
|
$pinnedContainer = new VectorComponentPinnedContainer( $id, $this->isPinned );
|
|
|
|
$pinnableElement = new VectorComponentPinnableElement( $id );
|
2022-12-02 18:09:52 +00:00
|
|
|
|
2022-12-07 01:05:22 +00:00
|
|
|
$data = $pinnableElement->getTemplateData() +
|
|
|
|
$pinnedContainer->getTemplateData();
|
|
|
|
return $data + [
|
2022-12-07 22:15:31 +00:00
|
|
|
'data-pinnable-header' => $this->pinnableHeader ? $this->pinnableHeader->getTemplateData() : null,
|
2022-12-07 01:05:22 +00:00
|
|
|
'data-menus' => $menusData,
|
2022-12-02 18:09:52 +00:00
|
|
|
];
|
|
|
|
}
|
|
|
|
}
|