2019-04-10 12:52:34 +00:00
|
|
|
<?php
|
|
|
|
|
2019-04-08 17:08:57 +00:00
|
|
|
/**
|
|
|
|
* 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
|
|
|
|
*/
|
|
|
|
|
2020-08-24 21:49:04 +00:00
|
|
|
use MediaWiki\Config\ServiceOptions;
|
2024-05-19 12:45:56 +00:00
|
|
|
use MediaWiki\Context\RequestContext;
|
2019-04-10 12:52:34 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2019-07-09 16:10:31 +00:00
|
|
|
use MediaWiki\Minerva\LanguagesHelper;
|
2019-04-08 17:08:57 +00:00
|
|
|
use MediaWiki\Minerva\Menu\Definitions;
|
2024-03-24 18:26:16 +00:00
|
|
|
use MediaWiki\Minerva\Menu\PageActions\DefaultOverflowBuilder;
|
|
|
|
use MediaWiki\Minerva\Menu\PageActions\EmptyOverflowBuilder;
|
|
|
|
use MediaWiki\Minerva\Menu\PageActions\PageActionsDirector;
|
|
|
|
use MediaWiki\Minerva\Menu\PageActions\ToolbarBuilder;
|
|
|
|
use MediaWiki\Minerva\Menu\PageActions\UserNamespaceOverflowBuilder;
|
2019-05-24 00:07:27 +00:00
|
|
|
use MediaWiki\Minerva\Permissions\IMinervaPagePermissions;
|
2020-01-26 19:26:31 +00:00
|
|
|
use MediaWiki\Minerva\Permissions\MinervaPagePermissions;
|
2019-04-10 21:43:50 +00:00
|
|
|
use MediaWiki\Minerva\SkinOptions;
|
2022-03-04 16:40:54 +00:00
|
|
|
use MediaWiki\Minerva\Skins\SkinMinerva;
|
2020-05-01 01:16:53 +00:00
|
|
|
use MediaWiki\Minerva\Skins\SkinUserPageHelper;
|
2024-01-06 15:31:38 +00:00
|
|
|
use MediaWiki\SpecialPage\SpecialPage;
|
2019-04-10 12:52:34 +00:00
|
|
|
|
|
|
|
return [
|
2021-05-03 14:12:42 +00:00
|
|
|
'Minerva.Menu.Definitions' => static function ( MediaWikiServices $services ): Definitions {
|
2021-11-23 09:18:46 +00:00
|
|
|
return new Definitions(
|
2024-03-28 08:26:54 +00:00
|
|
|
$services->getSpecialPageFactory()
|
2021-11-23 09:18:46 +00:00
|
|
|
);
|
2019-07-25 10:34:50 +00:00
|
|
|
},
|
2019-06-21 16:52:22 +00:00
|
|
|
'Minerva.Menu.PageActionsDirector' =>
|
2024-03-24 18:26:16 +00:00
|
|
|
static function ( MediaWikiServices $services ): PageActionsDirector {
|
2020-05-31 14:35:29 +00:00
|
|
|
/**
|
|
|
|
* @var SkinOptions $skinOptions
|
|
|
|
* @var SkinMinerva $skin
|
|
|
|
* @var SkinUserPageHelper $userPageHelper
|
|
|
|
*/
|
|
|
|
$skinOptions = $services->getService( 'Minerva.SkinOptions' );
|
2021-12-06 08:34:15 +00:00
|
|
|
// FIXME: RequestContext should not be accessed in service container.
|
2020-05-31 14:35:29 +00:00
|
|
|
$context = RequestContext::getMain();
|
|
|
|
$title = $context->getTitle();
|
2021-12-06 08:34:15 +00:00
|
|
|
if ( !$title ) {
|
|
|
|
$title = SpecialPage::getTitleFor( 'Badtitle' );
|
|
|
|
}
|
2020-05-31 14:35:29 +00:00
|
|
|
$user = $context->getUser();
|
2024-03-24 09:19:59 +00:00
|
|
|
$userPageHelper = $services->getService( 'Minerva.SkinUserPageHelper' )
|
|
|
|
->setContext( $context )
|
|
|
|
->setTitle( $title->inNamespace( NS_USER_TALK ) ?
|
|
|
|
$context->getSkin()->getRelevantTitle()->getSubjectPage() :
|
|
|
|
$title
|
|
|
|
);
|
2020-05-31 14:35:29 +00:00
|
|
|
$languagesHelper = $services->getService( 'Minerva.LanguagesHelper' );
|
2019-12-12 22:49:48 +00:00
|
|
|
|
2024-03-23 17:31:24 +00:00
|
|
|
$permissions = $services->getService( 'Minerva.Permissions' )
|
|
|
|
->setContext( $context );
|
|
|
|
|
2021-04-27 20:39:57 +00:00
|
|
|
$watchlistManager = $services->getWatchlistManager();
|
|
|
|
|
2024-03-24 18:26:16 +00:00
|
|
|
$toolbarBuilder = new ToolbarBuilder(
|
2020-05-31 14:35:29 +00:00
|
|
|
$title,
|
|
|
|
$user,
|
|
|
|
$context,
|
2024-03-23 17:31:24 +00:00
|
|
|
$permissions,
|
2020-05-31 14:35:29 +00:00
|
|
|
$skinOptions,
|
2024-03-24 09:19:59 +00:00
|
|
|
$userPageHelper,
|
2020-08-24 21:49:04 +00:00
|
|
|
$languagesHelper,
|
2024-03-24 18:26:16 +00:00
|
|
|
new ServiceOptions( ToolbarBuilder::CONSTRUCTOR_OPTIONS,
|
2021-04-27 20:39:57 +00:00
|
|
|
$services->getMainConfig() ),
|
|
|
|
$watchlistManager
|
2020-05-31 14:35:29 +00:00
|
|
|
);
|
|
|
|
if ( $skinOptions->get( SkinOptions::TOOLBAR_SUBMENU ) ) {
|
2024-03-24 09:19:59 +00:00
|
|
|
$overflowBuilder = $userPageHelper->isUserPage() ?
|
2024-03-24 18:26:16 +00:00
|
|
|
new UserNamespaceOverflowBuilder(
|
2021-03-09 19:43:14 +00:00
|
|
|
$title,
|
|
|
|
$context,
|
2024-03-23 17:31:24 +00:00
|
|
|
$permissions,
|
2021-03-09 19:43:14 +00:00
|
|
|
$languagesHelper
|
|
|
|
) :
|
2024-03-24 18:26:16 +00:00
|
|
|
new DefaultOverflowBuilder(
|
2023-07-22 01:00:15 +00:00
|
|
|
$title,
|
2021-03-09 19:43:14 +00:00
|
|
|
$context,
|
2024-03-23 17:31:24 +00:00
|
|
|
$permissions
|
2021-03-09 19:43:14 +00:00
|
|
|
);
|
2020-05-31 14:35:29 +00:00
|
|
|
} else {
|
2024-03-24 18:26:16 +00:00
|
|
|
$overflowBuilder = new EmptyOverflowBuilder();
|
2020-05-31 14:35:29 +00:00
|
|
|
}
|
2019-05-23 22:34:10 +00:00
|
|
|
|
2024-03-24 18:26:16 +00:00
|
|
|
return new PageActionsDirector(
|
2020-05-31 14:35:29 +00:00
|
|
|
$toolbarBuilder,
|
|
|
|
$overflowBuilder,
|
|
|
|
$context
|
|
|
|
);
|
|
|
|
},
|
2021-05-03 14:12:42 +00:00
|
|
|
'Minerva.SkinUserPageHelper' => static function ( MediaWikiServices $services ): SkinUserPageHelper {
|
2019-07-31 11:10:57 +00:00
|
|
|
return new SkinUserPageHelper(
|
2024-03-24 09:19:59 +00:00
|
|
|
$services->getUserFactory(),
|
|
|
|
$services->getUserNameUtils()
|
2019-07-31 11:10:57 +00:00
|
|
|
);
|
2019-04-10 21:43:50 +00:00
|
|
|
},
|
2024-03-02 19:34:53 +00:00
|
|
|
'Minerva.LanguagesHelper' => static function ( MediaWikiServices $services ): LanguagesHelper {
|
|
|
|
return new LanguagesHelper(
|
2024-03-23 21:43:33 +00:00
|
|
|
$services->getLanguageConverterFactory()
|
2024-03-02 19:34:53 +00:00
|
|
|
);
|
2019-07-09 16:10:31 +00:00
|
|
|
},
|
2024-03-03 13:31:09 +00:00
|
|
|
'Minerva.SkinOptions' => static function ( MediaWikiServices $services ): SkinOptions {
|
|
|
|
return new SkinOptions(
|
2024-03-24 10:49:33 +00:00
|
|
|
$services->getHookContainer(),
|
|
|
|
$services->getService( 'Minerva.SkinUserPageHelper' )
|
2024-03-03 13:31:09 +00:00
|
|
|
);
|
2019-05-24 00:07:27 +00:00
|
|
|
},
|
2021-05-03 14:12:42 +00:00
|
|
|
'Minerva.Permissions' => static function ( MediaWikiServices $services ): IMinervaPagePermissions {
|
2024-03-23 17:31:24 +00:00
|
|
|
return new MinervaPagePermissions(
|
2019-10-08 17:22:31 +00:00
|
|
|
$services->getService( 'Minerva.SkinOptions' ),
|
|
|
|
$services->getService( 'Minerva.LanguagesHelper' ),
|
2021-05-28 20:15:31 +00:00
|
|
|
$services->getPermissionManager(),
|
2023-07-17 17:31:07 +00:00
|
|
|
$services->getContentHandlerFactory(),
|
2024-02-26 07:35:55 +00:00
|
|
|
$services->getUserFactory(),
|
|
|
|
$services->getWatchlistManager()
|
2019-10-08 17:22:31 +00:00
|
|
|
);
|
2019-04-10 12:52:34 +00:00
|
|
|
}
|
|
|
|
];
|