MediaWiki REL1_32
ApiSpamBlacklist.php
Go to the documentation of this file.
1<?php
32
33 public function execute() {
35 $matches = BaseBlacklist::getInstance( 'spam' )->filter( $params['url'], null, true );
36 $res = $this->getResult();
37
38 if ( $matches !== false ) {
39 // this url is blacklisted.
40 $res->addValue( 'spamblacklist', 'result', 'blacklisted' );
41 $res->setIndexedTagName( $matches, 'match' );
42 $res->addValue( 'spamblacklist', 'matches', $matches );
43 } else {
44 // not blacklisted
45 $res->addValue( 'spamblacklist', 'result', 'ok' );
46 }
47 }
48
49 public function getAllowedParams() {
50 return [
51 'url' => [
54 ]
55 ];
56 }
57
62 protected function getExamplesMessages() {
63 return [
64 'action=spamblacklist&url=http://www.example.com/|http://www.example.org/'
65 => 'apihelp-spamblacklist-example-1',
66 ];
67 }
68
69 public function getHelpUrls() {
70 return [ 'https://www.mediawiki.org/wiki/Extension:SpamBlacklist/API' ];
71 }
72}
This abstract class implements many basic API functions, and is the base of all API classes.
Definition ApiBase.php:37
const PARAM_REQUIRED
(boolean) Is the parameter required?
Definition ApiBase.php:111
getResult()
Get the result object.
Definition ApiBase.php:659
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:770
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition ApiBase.php:51
SpamBlacklist extension API.
getAllowedParams()
Returns an array of allowed parameters (parameter name) => (default value) or (parameter name) => (ar...
getHelpUrls()
Return links to more detailed help pages about the module.
execute()
Evaluates the parameters, performs the requested query, and sets up the result.
static getInstance( $type)
Returns an instance of the given blacklist.
$res
Definition database.txt:21
$params