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 ];
|
|
|
|
|
|
|
|
$pinnableDropdownData = [
|
|
|
|
'id' => 'vector-page-tools',
|
|
|
|
'class' => 'vector-page-tools',
|
|
|
|
'label' => $this->skin->msg( 'toolbox' ),
|
2022-12-07 22:15:31 +00:00
|
|
|
'is-pinned' => $this->isPinned,
|
2022-12-02 18:09:52 +00:00
|
|
|
'has-multiple-menus' => true,
|
2022-12-07 22:15:31 +00:00
|
|
|
'data-pinnable-header' => $this->pinnableHeader ? $this->pinnableHeader->getTemplateData() : null,
|
2022-12-02 18:09:52 +00:00
|
|
|
'data-menus' => $menusData
|
|
|
|
];
|
|
|
|
return $pinnableDropdownData;
|
|
|
|
}
|
|
|
|
}
|