1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* File containing the SimpleBatchUpload class |
4
|
|
|
* |
5
|
|
|
* @copyright (C) 2016 - 2017, 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
|
|
|
* This software is distributed in the hope that it will be useful, |
13
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
14
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
15
|
|
|
* GNU General Public License for more details. |
16
|
|
|
* You should have received a copy of the GNU General Public License |
17
|
|
|
* along with this program; if not, see <http://www.gnu.org/licenses/>. |
18
|
|
|
* |
19
|
|
|
* @file |
20
|
|
|
* @ingroup SimpleBatchUpload |
21
|
|
|
*/ |
22
|
|
|
|
23
|
|
|
namespace SimpleBatchUpload; |
24
|
|
|
|
25
|
|
|
/** |
26
|
|
|
* Class ExtensionManager |
27
|
|
|
* |
28
|
|
|
* @package SimpleBatchUpload |
29
|
|
|
*/ |
30
|
|
|
class SimpleBatchUpload { |
31
|
|
|
|
32
|
|
|
public static function initCallback() { |
33
|
|
|
|
34
|
|
|
$configuration = ( new self() )->getConfiguration(); |
35
|
|
|
|
36
|
|
|
foreach ( $configuration as $varname => $value ) { |
37
|
|
|
$GLOBALS[ $varname ] = array_replace_recursive( $GLOBALS[ $varname ], $value ); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @return array |
44
|
|
|
*/ |
45
|
|
|
public function getConfiguration() { |
46
|
|
|
|
47
|
|
|
$configuration = []; |
48
|
|
|
|
49
|
|
|
$configuration[ 'wgExtensionMessagesFiles' ][ 'SimpleBatchUploadAlias' ] = __DIR__ . '/SimpleBatchUpload.alias.php'; |
50
|
|
|
$configuration[ 'wgExtensionMessagesFiles' ][ 'SimpleBatchUploadMagic' ] = __DIR__ . '/SimpleBatchUpload.magic.php'; |
51
|
|
|
|
52
|
|
|
$configuration[ 'wgSpecialPages' ][ 'BatchUpload' ] = '\SimpleBatchUpload\SpecialBatchUpload'; |
53
|
|
|
|
54
|
|
|
$configuration[ 'wgHooks' ][ 'ParserFirstCallInit' ][ 'ext.simplebatchupload' ] = [ $this, 'registerParserFunction' ]; |
55
|
|
|
|
56
|
|
|
$configuration[ 'wgResourceModules' ] = $this->getUploadSupportModuleDefinition() + $this->getUploadModuleDefinition(); |
57
|
|
|
|
58
|
|
|
return $configuration; |
59
|
|
|
|
60
|
|
|
} |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @param \Parser $parser |
|
|
|
|
64
|
|
|
* @return bool |
65
|
|
|
*/ |
66
|
|
|
public function registerParserFunction( &$parser ) { |
67
|
|
|
$parser->setFunctionHook( 'batchupload', [ new UploadButtonRenderer( $parser->getOutput() ), 'renderParserFunction' ], SFH_OBJECT_ARGS ); |
|
|
|
|
68
|
|
|
return true; |
69
|
|
|
} |
70
|
|
|
|
71
|
|
|
|
72
|
|
|
/** |
73
|
|
|
* @return array |
74
|
|
|
*/ |
75
|
|
|
protected function getUploadSupportModuleDefinition() { |
76
|
|
|
|
77
|
|
|
return [ 'ext.SimpleBatchUpload.jquery-file-upload' => |
78
|
|
|
|
79
|
|
|
$this->getBasePathsForComposerModules() + |
80
|
|
|
|
81
|
|
|
[ |
82
|
|
|
'scripts' => [ '/vendor/blueimp/jquery-file-upload/js/jquery.fileupload.js' ], |
83
|
|
|
'styles' => [ '/vendor/blueimp/jquery-file-upload/css/jquery.fileupload.css' ], |
84
|
|
|
'position' => 'top', |
85
|
|
|
'dependencies' => [ 'jquery.ui.widget' ], |
86
|
|
|
], |
87
|
|
|
]; |
88
|
|
|
|
89
|
|
|
} |
90
|
|
|
|
91
|
|
|
/** |
92
|
|
|
* @return array |
93
|
|
|
*/ |
94
|
|
|
protected function getUploadModuleDefinition() { |
95
|
|
|
|
96
|
|
|
return [ 'ext.SimpleBatchUpload' => |
97
|
|
|
|
98
|
|
|
$this->getBasePathsForNonComposerModules() + |
99
|
|
|
|
100
|
|
|
[ |
101
|
|
|
'scripts' => [ 'res/ext.SimpleBatchUpload.js' ], |
102
|
|
|
'styles' => [ 'res/ext.SimpleBatchUpload.css' ], |
103
|
|
|
'position' => 'top', |
104
|
|
|
'dependencies' => [ 'ext.SimpleBatchUpload.jquery-file-upload', 'mediawiki.Title', 'mediawiki.api.edit', 'mediawiki.jqueryMsg' ], |
105
|
|
|
'messages' => [ 'simplebatchupload-comment' ], |
106
|
|
|
], |
107
|
|
|
]; |
108
|
|
|
} |
109
|
|
|
|
110
|
|
|
/** |
111
|
|
|
* @return string[] |
112
|
|
|
*/ |
113
|
|
|
protected function getBasePathsForNonComposerModules() { |
114
|
|
|
return [ |
115
|
|
|
'localBasePath' => dirname( __DIR__ ), |
116
|
|
|
'remoteBasePath' => $GLOBALS[ 'wgExtensionAssetsPath' ] . '/SimpleBatchUpload', |
117
|
|
|
]; |
118
|
|
|
} |
119
|
|
|
|
120
|
|
|
/** |
121
|
|
|
* @return string[] |
122
|
|
|
*/ |
123
|
|
|
protected function getBasePathsForComposerModules() { |
124
|
|
|
|
125
|
|
|
if ( file_exists( dirname( __DIR__ ) . '/vendor' ) ) { |
126
|
|
|
return $this->getBasePathsForNonComposerModules(); |
127
|
|
|
} |
128
|
|
|
|
129
|
|
|
return [ |
130
|
|
|
'localBasePath' => $GLOBALS[ 'IP' ], |
131
|
|
|
'remoteBasePath' => $GLOBALS[ 'wgScriptPath' ], |
132
|
|
|
]; |
133
|
|
|
} |
134
|
|
|
|
135
|
|
|
} |
136
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths