Completed
Push — master ( 48889d...507809 )
by Stephan
02:32
created

src/SpecialBatchUpload.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
/**
3
 * File containing the SpecialBatchUpload class
4
 *
5
 * @copyright (C) 2016, Stephan Gambke
6
 * @license   GNU General Public License, version 2 (or any later version)
7
 *
8
 * This software is free software; you can redistribute it and/or
9
 * modify it under the terms of the GNU General Public License
10
 * as published by the Free Software Foundation; either version 2
11
 * of the License, or (at your option) any later version.
12
 *
13
 * This software is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU General Public License
19
 * along with this program; if not, see <http://www.gnu.org/licenses/>.
20
 *
21
 * @file
22
 * @ingroup SimpleBatchUpload
23
 */
24
25
namespace SimpleBatchUpload;
26
use SpecialPage;
27
28
/**
29
 * Class SpecialBatchUpload
30
 *
31
 * @package SimpleBatchUpload
32
 * @ingroup SimpleBatchUpload
33
 */
34
class SpecialBatchUpload extends SpecialPage {
35
36
	/**
37
	 * @param string $name Name of the special page, as seen in links and URLs
38
	 * @param string $restriction User right required, e.g. "block" or "delete"
39
	 * @param bool $listed Whether the page is listed in Special:Specialpages
40
	 */
41
	function __construct( $name = '', $restriction = '', $listed = true	) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
42
		parent::__construct( 'BatchUpload', 'upload', $listed );
43
	}
44
45
	/**
46
	 * Under which header this special page is listed in Special:SpecialPages
47
	 * See messages 'specialpages-group-*' for valid names
48
	 * This method defaults to group 'other'
49
	 *
50
	 * @return string
51
	 */
52
	protected function getGroupName() {
53
		return 'media';
54
	}
55
56
	/**
57
	 * Execute method
58
	 * Checks user permissions
59
	 *
60
	 * This must be overridden by subclasses; it will be made abstract in a future version
61
	 *
62
	 * @param null|string $par
63
	 * @throws \MWException
64
	 */
65
	function execute( $par ) {
0 ignored issues
show
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
66
67
		$this->setHeaders();
68
		$this->checkPermissions();
69
70
//		$request = $this->getRequest();
0 ignored issues
show
Unused Code Comprehensibility introduced by
55% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
71
		$output = $this->getOutput();
72
73
		# Get request data from, e.g.
74
//		$param = $request->getText( 'param' );
75
76
		$html = '<span id="fileupload-dropzone" class="fileinput-button">
77
        <i class="glyphicon glyphicon-plus"></i>
78
        <span>Select files (or drop them here)...</span>
79
        <!-- The file input field used as target for the file upload widget -->
80
        <input id="fileupload" type="file" name="file" data-url="' . wfScript( 'api' ) . '" data-token="' . $this->getUser()->getEditToken() . '" multiple>
81
    </span><ul id="fileupload-results"></ul>
82
    ';
83
		$output->addHTML( $html );
84
		$output->addModules( 'ext.SimpleBatchUpload' );
85
		$output->addModuleStyles( [ 'ext.SimpleBatchUpload', 'ext.SimpleBatchUpload.jquery-file-upload' ] );
86
	}
87
88
}
89