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