mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TitleBlacklist
synced 2024-11-15 10:17:49 +00:00
9056a338cb
Change-Id: Ib8d5776cc83ff34c68093c43146218c4a470939d
34 lines
1 KiB
PHP
34 lines
1 KiB
PHP
<?php
|
|
|
|
class Scribunto_LuaTitleBlacklistLibrary extends Scribunto_LuaLibraryBase {
|
|
public function register() {
|
|
$lib = array(
|
|
'test' => array( $this, 'test' ),
|
|
);
|
|
|
|
return $this->getEngine()->registerInterface( __DIR__ . '/mw.ext.TitleBlacklist.lua', $lib, array() );
|
|
}
|
|
|
|
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 ) {
|
|
return array( array(
|
|
'params' => $entry->getParams(),
|
|
'regex' => $entry->getRegex(),
|
|
'raw' => $entry->getRaw(),
|
|
'version' => $entry->getFormatVersion(),
|
|
'message' => $entry->getErrorMessage( $action ),
|
|
'custommessage' => $entry->getCustomMessage()
|
|
) );
|
|
}
|
|
return array( null );
|
|
}
|
|
|
|
}
|