This repository has been archived on 2024-06-01. You can view files and clone it, but cannot push or open issues or pull requests.
docker-mediawiki/build/mediawiki_override/extensions/AdvancedSearch/includes/SearchnamespaceTokenModule.php
2022-12-30 13:49:41 +02:00

57 lines
1.1 KiB
PHP

<?php
namespace AdvancedSearch;
use ResourceLoaderContext;
use ResourceLoaderModule;
use ResourceLoaderWikiModule;
use Xml;
/**
* ResourceLoader module providing the users "searchnamespace" token.
*/
class SearchnamespaceTokenModule extends ResourceLoaderWikiModule {
/**
* @var int
*/
protected $origin = self::ORIGIN_CORE_INDIVIDUAL;
/**
* @var string[]
*/
protected $targets = [ 'desktop', 'mobile' ];
/**
* @param ResourceLoaderContext $context
*
* @return string JavaScript code
*/
public function getScript( ResourceLoaderContext $context ) {
$user = $context->getUserObj();
// Use FILTER_NOMIN annotation to prevent needless minification and caching (T84960).
return ResourceLoader::FILTER_NOMIN .
Xml::encodeJsCall(
'mw.user.tokens.set',
[ 'searchnamespaceToken', $user->getEditToken( 'searchnamespace' ) ],
(bool)ResourceLoader::inDebugMode()
);
}
/**
* @return bool
*/
public function supportsURLLoading() {
return false;
}
/**
* @return string
*/
public function getGroup() {
// Private modules can not be loaded as a dependency, only via OutputPage::addModules().
return 'private';
}
}