MediaWiki REL1_34
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}
This class provides some basic services that Lua libraries will probably need.
checkType( $name, $argIdx, $arg, $expectType)
Check the type of a variable.
getEngine()
Get the engine.
checkTypeOptional( $name, $argIdx, &$arg, $expectType, $default)
Check the type of a variable, with default if null.
getParser()
Get the parser.
incrementExpensiveFunctionCount()
Increment the expensive function count, and throw if limit exceeded.
static singleton()
Get an instance of this class.