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;
|
|
|
|
|
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;
|
2019-05-23 22:34:10 +00:00
|
|
|
use MessageLocalizer;
|
2019-06-24 17:59:11 +00:00
|
|
|
use 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
|
|
|
|
2019-06-24 17:59:11 +00:00
|
|
|
/**
|
|
|
|
* @var Title
|
|
|
|
*/
|
|
|
|
private $title;
|
|
|
|
|
|
|
|
/**
|
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
|
2019-05-23 22:34:10 +00:00
|
|
|
* @param MessageLocalizer $msgLocalizer
|
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,
|
|
|
|
MessageLocalizer $msgLocalizer,
|
|
|
|
IMinervaPagePermissions $permissions,
|
2019-07-09 16:10:31 +00:00
|
|
|
LanguagesHelper $languagesHelper
|
2019-06-24 17:59:11 +00:00
|
|
|
) {
|
|
|
|
$this->title = $title;
|
2019-07-09 16:10:31 +00:00
|
|
|
$this->languagesHelper = $languagesHelper;
|
2023-03-24 21:56:18 +00:00
|
|
|
parent::__construct( $msgLocalizer, $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(
|
2019-07-09 16:10:31 +00:00
|
|
|
$this->title,
|
|
|
|
$this->languagesHelper->doesTitleHasLanguagesOrVariants( $this->title ),
|
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;
|
|
|
|
}
|
|
|
|
}
|