2014-01-07 18:08:24 +00:00
|
|
|
<?php
|
|
|
|
|
2022-04-08 13:20:08 +00:00
|
|
|
namespace MediaWiki\Extension\TitleBlacklist;
|
|
|
|
|
|
|
|
use Scribunto_LuaLibraryBase;
|
|
|
|
|
2014-01-07 18:08:24 +00:00
|
|
|
class Scribunto_LuaTitleBlacklistLibrary extends Scribunto_LuaLibraryBase {
|
|
|
|
public function register() {
|
2017-06-06 16:18:36 +00:00
|
|
|
$lib = [
|
|
|
|
'test' => [ $this, 'test' ],
|
|
|
|
];
|
2014-01-07 18:08:24 +00:00
|
|
|
|
2017-06-02 15:43:58 +00:00
|
|
|
return $this->getEngine()->registerInterface(
|
2017-06-06 16:18:36 +00:00
|
|
|
__DIR__ . '/mw.ext.TitleBlacklist.lua', $lib, []
|
2017-06-02 15:43:58 +00:00
|
|
|
);
|
2014-01-07 18:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
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 == '' ) {
|
|
|
|
$title = $this->getParser()->mTitle->getPrefixedText();
|
|
|
|
}
|
|
|
|
$entry = TitleBlacklist::singleton()->isBlacklisted( $title, $action );
|
|
|
|
if ( $entry ) {
|
2017-06-06 16:18:36 +00:00
|
|
|
return [ [
|
2014-01-07 18:08:24 +00:00
|
|
|
'params' => $entry->getParams(),
|
|
|
|
'regex' => $entry->getRegex(),
|
|
|
|
'raw' => $entry->getRaw(),
|
|
|
|
'version' => $entry->getFormatVersion(),
|
|
|
|
'message' => $entry->getErrorMessage( $action ),
|
|
|
|
'custommessage' => $entry->getCustomMessage()
|
2017-06-06 16:18:36 +00:00
|
|
|
] ];
|
2014-01-07 18:08:24 +00:00
|
|
|
}
|
2017-06-06 16:18:36 +00:00
|
|
|
return [ null ];
|
2014-01-07 18:08:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|