MediaWiki REL1_34
ApiSpamBlacklist.php
Go to the documentation of this file.
1<?php
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' => [
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}
This abstract class implements many basic API functions, and is the base of all API classes.
Definition ApiBase.php:42
const PARAM_REQUIRED
(boolean) Is the parameter required?
Definition ApiBase.php:118
getResult()
Get the result object.
Definition ApiBase.php:640
extractRequestParams( $options=[])
Using getAllowedParams(), this function makes an array of the values provided by the user,...
Definition ApiBase.php:761
const PARAM_ISMULTI
(boolean) Accept multiple pipe-separated values for this parameter (e.g.
Definition ApiBase.php:58
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.