-
Notifications
You must be signed in to change notification settings - Fork 0
/
FileList.php
126 lines (106 loc) · 3.9 KB
/
FileList.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
<?php
if ( !defined( 'MEDIAWIKI' ) )
die('This file is meant to be run inside MediaWiki');
// Are file uploads anonymous?
$wgFileListAnonymous = false;
// SI values or binary? (base 1000 or base 1024?)
$wgFileListFileSizeSystem = 'si';
// The separator used between the page title and the filename
$wgFileListSeparator = '_--_';
// Force download instead of open
// Set this to true by default, because 'opening' php/perl/python/...
// files will cause their execution on the server!
$wgFileListForceDownload = false;
// Set default permissions: only sysops are allowed to delete all files
$wgGroupPermissions['*']['fl-delete-all'] = false;
$wgGroupPermissions['sysop']['fl-delete-all'] = true;
$wgFileListIcons = array(
'pdf' => 'pdf',
'rar' => 'rar',
'7z' => 'rar',
'gz' => 'zip',
'zip' => 'zip',
'txt' => 'txt',
'doc' => 'doc',
'docx' => 'doc',
'ppt' => 'ppt',
'pptx' => 'ppt',
'xls' => 'xls',
'xlsx' => 'xls',
'odt' => 'odt',
'odp' => 'odt',
'ods' => 'odt',
'jpg' => 'gif',
'jpeg' => 'gif',
'gif' => 'gif',
'png' => 'gif',
);
// Override default settings with our default values
$wgFileExtensions = array_merge( $wgFileExtensions, array(
// pdf
'pdf',
// common archive formats
'rar','zip','7z','gz',
// Microsoft Office
'doc','ppt','xls',
// The new Microsofto Office formats
// remark: not the .docm, .pptm and .xlsm variants
// because they allow macros
'docx','pptx','xlsx',
// OpenOffice/LibreOffice
'odt','odp','ods',
// simple text files
'txt', 'rtf',
// AutoCad
'cad',
// images
'jpg', 'jpeg', 'gif', 'png', 'eps', 'svg'
) );
/* Not very secure, but needed because otherwise all .doc files *
* generated by Office 2007 or later will be seen as containing *
* a jar, which is not allowed for security reasons. */
$wgAllowJavaUploads = true;
/* Add this extension to Special:Version */
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'FileList',
'version' => '0.1',
'author' => '[https://github.com/LitusProject The Litus Project]',
'descriptionmsg' => 'fl_credits_desc',
'url' => 'https://github.com/LitusProject/MediaWikiFileList'
);
/* Add our class to the autoloader */
$wgAutoloadClasses['FileList'] = dirname( __FILE__ ) . '/FileList.body.php';
/* Add our initialization function */
$wgHooks['ParserFirstCallInit'][] = 'wfFileListInit';
/* Install the 'magic word' filelist */
$wgExtensionMessagesFiles['FileListMagic'] = dirname( __FILE__ ) . '/FileList.i18n.magic.php';
/* Install our i18n file */
$wgExtensionMessagesFiles['FileList'] = dirname( __FILE__ ) . '/FileList.i18n.php';
// TODO: this hook appears to be deprecated, but no information found except @ http://www.mediawiki.org/wiki/Manual:Hooks/UnknownAction
/* Install new ?action= style actions */
$wgHooks['UnknownAction'][] = 'FileList::onUnknownAction';
/* before upload: remove user info (ensure anonymity) */
$wgHooks['UploadForm:BeforeProcessing'][] = 'FileList::onUploadBeforeProcessing';
/* upload complete: redirect appropriately */
$wgHooks['SpecialUploadComplete'][] = 'FileList::onUploadComplete';
/* move page: move all files as well */
$wgHooks['SpecialMovepageAfterMove'][] = 'FileList::onMovePage';
/* Install our .js and .css files */
$wgResourceModules['ext.FileList'] = array(
'scripts' => 'ext.FileList.js',
'styles' => 'ext.FileList.css',
'messages' => array(
'fl-empty-file'
),
'position' => 'bottom',
'localBasePath' => dirname( __FILE__ ) . '/modules',
'remoteExtPath' => 'FileList/modules'
);
/* Initialisation function */
function wfFileListInit( Parser &$parser) {
// add the parser hook
$parser->setFunctionHook( 'filelist', 'FileList::parserFunction' );
// return control to MW
return true;
}