2021-12-14 21:59:16 +00:00
|
|
|
<?php
|
|
|
|
|
2022-05-23 07:32:40 +00:00
|
|
|
namespace MediaWiki\Skins\Vector\ResourceLoader;
|
2021-12-14 21:59:16 +00:00
|
|
|
|
2023-03-03 09:45:53 +00:00
|
|
|
use MediaWiki\MainConfigNames;
|
2024-01-23 20:26:35 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
2022-05-25 05:12:31 +00:00
|
|
|
use MediaWiki\ResourceLoader as RL;
|
2022-05-23 07:32:40 +00:00
|
|
|
use MediaWiki\Skins\Vector\Constants;
|
2024-01-23 20:26:35 +00:00
|
|
|
use MediaWiki\Title\TitleValue;
|
2021-12-14 21:59:16 +00:00
|
|
|
|
2022-05-25 05:12:31 +00:00
|
|
|
class VectorResourceLoaderUserModule extends RL\UserModule {
|
2021-12-14 21:59:16 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2022-05-25 05:12:31 +00:00
|
|
|
protected function getPages( RL\Context $context ) {
|
2024-01-23 20:26:35 +00:00
|
|
|
$user = $context->getUserIdentity();
|
|
|
|
if ( !$user || !$user->isRegistered() ) {
|
|
|
|
return [];
|
|
|
|
}
|
2021-12-14 21:59:16 +00:00
|
|
|
$pages = [];
|
2023-01-19 21:19:16 +00:00
|
|
|
$config = $this->getConfig();
|
2023-03-03 09:45:53 +00:00
|
|
|
if ( $context->getSkin() === Constants::SKIN_NAME_MODERN &&
|
2023-01-19 21:19:16 +00:00
|
|
|
$config->get( 'VectorShareUserScripts' ) &&
|
2024-01-23 20:26:35 +00:00
|
|
|
$config->get( MainConfigNames::AllowUserCss )
|
2023-03-03 09:45:53 +00:00
|
|
|
) {
|
2024-01-23 20:26:35 +00:00
|
|
|
$titleFormatter = MediaWikiServices::getInstance()->getTitleFormatter();
|
|
|
|
$userPage = $titleFormatter->getPrefixedDBkey( new TitleValue( NS_USER, $user->getName() ) );
|
2021-12-14 21:59:16 +00:00
|
|
|
$pages["$userPage/vector.js"] = [ 'type' => 'script' ];
|
|
|
|
}
|
|
|
|
return $pages;
|
|
|
|
}
|
|
|
|
}
|