2019-05-23 22:34:10 +00:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License along
|
|
|
|
* with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
|
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
|
|
|
* http://www.gnu.org/copyleft/gpl.html
|
|
|
|
*
|
|
|
|
* @file
|
|
|
|
*/
|
|
|
|
|
|
|
|
namespace MediaWiki\Minerva\Menu\PageActions;
|
|
|
|
|
2024-03-23 21:43:33 +00:00
|
|
|
use MediaWiki\Context\IContextSource;
|
2019-07-09 16:10:31 +00:00
|
|
|
use MediaWiki\Minerva\LanguagesHelper;
|
2020-01-26 19:26:31 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Entries\LanguageSelectorEntry;
|
2019-05-23 22:34:10 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Group;
|
2019-06-24 17:59:11 +00:00
|
|
|
use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
|
2023-08-19 04:23:00 +00:00
|
|
|
use MediaWiki\Title\Title;
|
2019-05-23 22:34:10 +00:00
|
|
|
|
2023-03-24 21:56:18 +00:00
|
|
|
class UserNamespaceOverflowBuilder extends DefaultOverflowBuilder {
|
2019-05-23 22:34:10 +00:00
|
|
|
|
2024-03-23 21:43:33 +00:00
|
|
|
/**
|
|
|
|
* @var IContextSource
|
|
|
|
*/
|
|
|
|
private $context;
|
|
|
|
|
2019-06-24 17:59:11 +00:00
|
|
|
/**
|
2019-07-09 16:10:31 +00:00
|
|
|
* @var LanguagesHelper
|
2019-06-24 17:59:11 +00:00
|
|
|
*/
|
2019-07-09 16:10:31 +00:00
|
|
|
private $languagesHelper;
|
2019-06-24 17:59:11 +00:00
|
|
|
|
2019-05-23 22:34:10 +00:00
|
|
|
/**
|
|
|
|
* Initialize the overflow menu visible on the User namespace
|
2019-06-24 17:59:11 +00:00
|
|
|
* @param Title $title
|
2024-03-23 21:43:33 +00:00
|
|
|
* @param IContextSource $context
|
2019-06-24 17:59:11 +00:00
|
|
|
* @param IMinervaPagePermissions $permissions
|
2019-07-09 16:10:31 +00:00
|
|
|
* @param LanguagesHelper $languagesHelper
|
2019-05-23 22:34:10 +00:00
|
|
|
*/
|
2019-06-24 17:59:11 +00:00
|
|
|
public function __construct(
|
|
|
|
Title $title,
|
2024-03-23 21:43:33 +00:00
|
|
|
IContextSource $context,
|
2019-06-24 17:59:11 +00:00
|
|
|
IMinervaPagePermissions $permissions,
|
2019-07-09 16:10:31 +00:00
|
|
|
LanguagesHelper $languagesHelper
|
2019-06-24 17:59:11 +00:00
|
|
|
) {
|
2024-03-23 21:43:33 +00:00
|
|
|
$this->context = $context;
|
2019-07-09 16:10:31 +00:00
|
|
|
$this->languagesHelper = $languagesHelper;
|
2024-03-23 21:43:33 +00:00
|
|
|
parent::__construct( $title, $context, $permissions );
|
2019-05-23 22:34:10 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-03-09 19:43:14 +00:00
|
|
|
public function getGroup( array $toolbox, array $actions ): Group {
|
2023-03-24 21:56:18 +00:00
|
|
|
$group = parent::getGroup( $toolbox, $actions );
|
|
|
|
|
|
|
|
if ( $this->isAllowed( IMinervaPagePermissions::SWITCH_LANGUAGE ) ) {
|
|
|
|
$group->prependEntry( new LanguageSelectorEntry(
|
2023-07-22 01:00:15 +00:00
|
|
|
$this->getTitle(),
|
2024-03-23 21:43:33 +00:00
|
|
|
$this->languagesHelper->doesTitleHasLanguagesOrVariants(
|
|
|
|
$this->context->getOutput(),
|
|
|
|
$this->getTitle()
|
|
|
|
),
|
2023-03-24 21:56:18 +00:00
|
|
|
$this->getMessageLocalizer(),
|
2021-09-09 15:56:42 +00:00
|
|
|
false,
|
|
|
|
// no additional classes
|
|
|
|
'',
|
2019-06-24 17:59:11 +00:00
|
|
|
'minerva-page-actions-language-switcher'
|
|
|
|
) );
|
|
|
|
}
|
2019-05-23 22:34:10 +00:00
|
|
|
|
|
|
|
return $group;
|
|
|
|
}
|
|
|
|
}
|