Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
Total | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
CRAP | |
0.00% |
0 / 1 |
ApiFlickrBlacklist | |
0.00% |
0 / 27 |
|
0.00% |
0 / 3 |
42 | |
0.00% |
0 / 1 |
execute | |
0.00% |
0 / 12 |
|
0.00% |
0 / 1 |
20 | |||
getAllowedParams | |
0.00% |
0 / 9 |
|
0.00% |
0 / 1 |
2 | |||
getExamplesMessages | |
0.00% |
0 / 6 |
|
0.00% |
0 / 1 |
2 |
1 | <?php |
2 | |
3 | namespace MediaWiki\Extension\UploadWizard; |
4 | |
5 | use ApiBase; |
6 | use Wikimedia\ParamValidator\ParamValidator; |
7 | |
8 | /** |
9 | * API module to fetch blacklisting details of a flickr image |
10 | * |
11 | * @since 1.2 |
12 | * |
13 | * @file |
14 | * @ingroup Upload |
15 | * @ingroup API |
16 | * |
17 | * @license GPL-2.0-or-later |
18 | * @author Nischay Nahata <nischayn22@gmail.com> |
19 | */ |
20 | class ApiFlickrBlacklist extends ApiBase { |
21 | public function execute() { |
22 | $params = $this->extractRequestParams(); |
23 | $this->requireOnlyOneParameter( $params, 'url', 'list' ); |
24 | |
25 | $flickrBlacklist = new FlickrBlacklist( Config::getConfig(), |
26 | $this->getContext() ); |
27 | |
28 | if ( $params['list'] ) { |
29 | $list = $flickrBlacklist->getBlacklist(); |
30 | $this->getResult()->setIndexedTagName( $list, 'item' ); |
31 | $this->getResult()->addValue( 'flickrblacklist', 'list', $list ); |
32 | } |
33 | |
34 | if ( $params['url'] !== null ) { |
35 | if ( $flickrBlacklist->isBlacklisted( $params['url'] ) ) { |
36 | $this->getResult()->addValue( 'flickrblacklist', 'result', 'bad' ); |
37 | } else { |
38 | $this->getResult()->addValue( 'flickrblacklist', 'result', 'ok' ); |
39 | } |
40 | } |
41 | } |
42 | |
43 | public function getAllowedParams() { |
44 | return [ |
45 | 'url' => [ |
46 | ParamValidator::PARAM_TYPE => 'string', |
47 | ], |
48 | 'list' => [ |
49 | ParamValidator::PARAM_TYPE => 'boolean', |
50 | ParamValidator::PARAM_DEFAULT => false, |
51 | ], |
52 | ]; |
53 | } |
54 | |
55 | /** |
56 | * @inheritDoc |
57 | */ |
58 | protected function getExamplesMessages() { |
59 | return [ |
60 | 'action=flickrblacklist&url=http%3A//farm1.staticflickr.com/44/147426941_98baf36fd1_o.jpg' |
61 | => 'apihelp-flickrblacklist-example-1', |
62 | 'action=flickrblacklist&list=' |
63 | => 'apihelp-flickrblacklist-example-2', |
64 | ]; |
65 | } |
66 | } |