MediaWiki  1.34.0
Scribunto_LuaTitleBlacklistLibrary.php
Go to the documentation of this file.
1 <?php
2 
4  public function register() {
5  $lib = [
6  'test' => [ $this, 'test' ],
7  ];
8 
9  return $this->getEngine()->registerInterface(
10  __DIR__ . '/mw.ext.TitleBlacklist.lua', $lib, []
11  );
12  }
13 
14  public function test( $action = null, $title = null ) {
15  $this->checkType( 'mw.ext.TitleBlacklist.test', 1, $action, 'string' );
16  $this->checkTypeOptional( 'mw.ext.TitleBlacklist.test', 2, $title, 'string', '' );
18  if ( $title == '' ) {
19  $title = $this->getParser()->mTitle->getPrefixedText();
20  }
21  $entry = TitleBlacklist::singleton()->isBlacklisted( $title, $action );
22  if ( $entry ) {
23  return [ [
24  'params' => $entry->getParams(),
25  'regex' => $entry->getRegex(),
26  'raw' => $entry->getRaw(),
27  'version' => $entry->getFormatVersion(),
28  'message' => $entry->getErrorMessage( $action ),
29  'custommessage' => $entry->getCustomMessage()
30  ] ];
31  }
32  return [ null ];
33  }
34 
35 }
TitleBlacklist\singleton
static singleton()
Get an instance of this class.
Definition: TitleBlacklist.php:36
Scribunto_LuaLibraryBase\getEngine
getEngine()
Get the engine.
Definition: LibraryBase.php:56
Scribunto_LuaLibraryBase\getParser
getParser()
Get the parser.
Definition: LibraryBase.php:74
Scribunto_LuaLibraryBase\checkType
checkType( $name, $argIdx, $arg, $expectType)
Check the type of a variable.
Definition: LibraryBase.php:141
Scribunto_LuaTitleBlacklistLibrary\test
test( $action=null, $title=null)
Definition: Scribunto_LuaTitleBlacklistLibrary.php:14
$title
$title
Definition: testCompression.php:34
Scribunto_LuaLibraryBase\checkTypeOptional
checkTypeOptional( $name, $argIdx, &$arg, $expectType, $default)
Check the type of a variable, with default if null.
Definition: LibraryBase.php:164
Scribunto_LuaLibraryBase
This class provides some basic services that Lua libraries will probably need.
Definition: LibraryBase.php:27
Scribunto_LuaTitleBlacklistLibrary
Definition: Scribunto_LuaTitleBlacklistLibrary.php:3
Scribunto_LuaLibraryBase\incrementExpensiveFunctionCount
incrementExpensiveFunctionCount()
Increment the expensive function count, and throw if limit exceeded.
Definition: LibraryBase.php:177