forked from SLboat/ClipUpload
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ClipUpload.php
82 lines (70 loc) · 2.43 KB
/
ClipUpload.php
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
/**
* Initialization file for the ClipUpload extension.
*
* @link https://www.mediawiki.org/wiki/Extension:ClipUpload Documentation
* @link https://www.mediawiki.org/wiki/Extension_talk:ClipUpload Support
* @link https://github.com/SLboat/ClipUpload/issues Issue tracker
* @link https://github.com/SLboat/ClipUpload Source Code
* @link http://see.sl088.com Author
*
* @ingroup Extensions
*
* @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
* @author Slboat
*/
if ( !defined( 'MEDIAWIKI' ) ) {
echo "This file is an extension to the MediaWiki software and cannot be used standalone.\n";
die( 1 );
}
$wgExtensionCredits['parserhook'][] = [
'path' => __FILE__,
'name' => 'ClipUpload',
'url' => 'https://www.mediawiki.org/wiki/Extension:ClipUpload',
'descriptionmsg' => 'clipup-desc',
'version' => '1.3.1',
'author' => '[http://see.sl088.com SLboat]',
'license-name' => 'GPL-2.0+',
];
$wgMessagesDirs['ClipUpload'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['ClipUploadMagic'] = __DIR__ . '/ClipUpload.i18n.magic.php';
$wgHooks['EditPage::showEditForm:initial'][] = 'ClipSetup';
$wgResourceModules['ext.ClipUpload'] = [
'scripts' => [
'js/paste.js',
'js/inline-attach.js',
'js/clipupload.js',
'js/ink-go.js',
],
'messages' => [
'clipup-desc',
'clipup-notLoadConfig',
'clipup-progressText',
'clipup-failduploadText',
'clipup-uploadingText',
'clipup-urlText',
'clipup-notsamesize',
'clipup-istoolarge',
'clipup-errdoingupload',
'clipup-mwfeedbackerrorText',
],
'localBasePath' => __DIR__,
'remoteExtPath' => 'ClipUpload',
];
$wgClipUpComment = 'This file was uploaded from the clipboard ([[Category:Clipboard upload]]).';
$wgClipUpMaxFileSize = 500; // Maximum file size in kilobytes
$wgClipUpCheckSameFileSize = false; // Check if the uploaded file has the same size
function ClipSetup( $editPage ) {
$config = $editPage->getConfig();
$configData = [
'comment' => $config->ClipUpComment,
'maxFileSize' => $config->ClipUpMaxFileSize,
'checkSameFileSize' => $config->ClipUpCheckSameFileSize,
];
$configJson = json_encode( $configData );
$editPage->getOutput()->addInlineScript(
"var clipUpConfig = $configJson;"
);
$editPage->getOutput()->addModules( 'ext.ClipUpload' );
return true;
}