mediawiki-extensions-TitleB.../includes/Scribunto_LuaTitleBlacklistLibrary.php
Umherirrender 954db277fc Use namespaced classes
Changes to the use statements done automatically via script
Addition of missing use statement done manually

Change-Id: I3a7b448f3793f6690bb329a2e5255a558048ed5a
2024-06-10 22:05:45 +02:00

46 lines
1.3 KiB
PHP

<?php
namespace MediaWiki\Extension\TitleBlacklist;
use MediaWiki\Extension\Scribunto\Engines\LuaCommon\LibraryBase;
use MediaWiki\MediaWikiServices;
class Scribunto_LuaTitleBlacklistLibrary extends LibraryBase {
public function register() {
$lib = [
'test' => [ $this, 'test' ],
];
return $this->getEngine()->registerInterface(
__DIR__ . '/mw.ext.TitleBlacklist.lua', $lib, []
);
}
public function test( $action = null, $title = null ) {
$this->checkType( 'mw.ext.TitleBlacklist.test', 1, $action, 'string' );
$this->checkTypeOptional( 'mw.ext.TitleBlacklist.test', 2, $title, 'string', '' );
$this->incrementExpensiveFunctionCount();
if ( $title == '' ) {
$page = $this->getParser()->getPage();
if ( !$page ) {
// Nothing to check
return [ null ];
}
$title = MediaWikiServices::getInstance()->getTitleFormatter()->getPrefixedText( $page );
}
$entry = TitleBlacklist::singleton()->isBlacklisted( $title, $action );
if ( $entry ) {
return [ [
'params' => $entry->getParams(),
'regex' => $entry->getRegex(),
'raw' => $entry->getRaw(),
'version' => $entry->getFormatVersion(),
'message' => $entry->getErrorMessage( $action ),
'custommessage' => $entry->getCustomMessage()
] ];
}
return [ null ];
}
}