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