1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Verify that dependencies are present |
4
|
|
|
* |
5
|
|
|
* @copyright (C) 2017 Mark A. Hershberger |
6
|
|
|
* |
7
|
|
|
* This program is free software; you can redistribute it and/or |
8
|
|
|
* modify it under the terms of the GNU General Public License |
9
|
|
|
* as published by the Free Software Foundation; either version 2 |
10
|
|
|
* of the License, or (at your option) any later version. |
11
|
|
|
* |
12
|
|
|
* This program 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
|
|
|
* |
17
|
|
|
* You should have received a copy of the GNU General Public License |
18
|
|
|
* along with this program; if not, write to the Free Software |
19
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA |
20
|
|
|
* 02110-1301, USA. |
21
|
|
|
* |
22
|
|
|
* @file |
23
|
|
|
* @ingroup SimpleBatchUpload |
24
|
|
|
*/ |
25
|
|
|
|
26
|
|
|
namespace SimpleBatchUpload; |
27
|
|
|
|
28
|
|
|
use PHPVersionCheck; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Class ExtensionManager |
32
|
|
|
* |
33
|
|
|
* @package SimpleBatchUploadCheck |
34
|
|
|
*/ |
35
|
|
|
class DependencyCheck extends PHPVersionCheck { |
36
|
|
|
/** |
37
|
|
|
* Displays an error. |
38
|
|
|
*/ |
39
|
|
|
function checkVendorExistence() { |
|
|
|
|
40
|
|
|
global $wgResourceModules, $wgScriptPath, $IP; |
|
|
|
|
41
|
|
|
if ( !file_exists( __DIR__ . '/../vendor/autoload.php' ) ) { |
42
|
|
|
if ( !file_exists( "$IP/vendor/blueimp" ) ) { |
|
|
|
|
43
|
|
|
$shortText = "SimpleBatchUpload requires some external dependencies." . |
|
|
|
|
44
|
|
|
" Please run composer."; |
|
|
|
|
45
|
|
|
|
46
|
|
|
$longText = "Error: You are missing some external dependencies.\n" |
47
|
|
|
. "SimpleBatchUpload has some external dependencies that\n" |
48
|
|
|
. "need to be installed via composer."; |
|
|
|
|
49
|
|
|
|
50
|
|
|
$longHtml = <<<HTML |
51
|
|
|
MediaWiki now also has some external dependencies that need to be installed via |
52
|
|
|
composer. |
53
|
|
|
HTML; |
54
|
|
|
|
55
|
|
|
$this->triggerError( 'External dependencies', $shortText, $longText, |
56
|
|
|
$longHtml ); |
57
|
|
|
} |
58
|
|
|
// HACK! |
59
|
|
|
$mod = $wgResourceModules['ext.SimpleBatchUpload.jquery-file-upload']; |
60
|
|
|
$mod['localBasePath'] = $IP; |
61
|
|
|
$mod['remoteBasePath'] = $wgScriptPath; |
62
|
|
|
$wgResourceModules['ext.SimpleBatchUpload.jquery-file-upload'] = $mod; |
63
|
|
|
} |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* Callback hook |
68
|
|
|
*/ |
69
|
|
|
public static function initCallback() { |
70
|
|
|
$singleton = new self(); |
71
|
|
|
$singleton->checkVendorExistence(); |
72
|
|
|
} |
73
|
|
|
} |
74
|
|
|
|
Adding explicit visibility (
private
,protected
, orpublic
) is generally recommend to communicate to other developers how, and from where this method is intended to be used.