-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFileList.php
81 lines (73 loc) · 2.64 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
<?php
/**
* File List extension.
*
* Author: Jens Nyman <[email protected]> (VTK Ghent)
*
* This extension implements a new tag, <filelist>, which generates a list of
* all images or other media that was uploaded to the page. Also, the tag adds
* an input field to add a new file.
*
* Usage:
* <filelist/>
*
*/
if (!defined('MEDIAWIKI')) die("Mediawiki not set");
/****************** EXTENSION SETTINGS ******************/
// configuration array of extension
$wgFileListConfig = array(
'upload_anonymously' => false,
'defaultdeleteperm' => true,
'hideForm' => true,
);
$wgExtensionCredits['parserhook'][] = array(
'name' => 'FileList',
'author' => 'Jens Nyman, Simon Peeters (VTK Ghent)',
'descriptionmsg' => 'fl_credits_desc',
'url' => 'https://github.com/SimonPe/FileList',
);
$wgAutoloadClasses['FileList'] = dirname(__FILE__) . '/FileList.body.php';
$wgAutoloadClasses['FlUpload'] = dirname(__FILE__) . '/includes/uploads.php';
$wgAutoloadClasses['FlAction'] = dirname(__FILE__) . '/includes/actions.php';
$wgAutoloadClasses['FlFile'] = dirname(__FILE__) . '/includes/file.php';
$wgExtensionMessagesFiles['FileList'] = dirname( __FILE__ ) . '/FileList.i18n.php';
/****************** SET HOOKS ******************/
$wgExtensionFunctions[] = 'wfFileList';
function wfFileList() {
global $wgParser;
$wgParser->setHook('filelist', 'FileList::onHookHtml');
Hooks::register('UploadCreateFromRequest', 'FlUpload::attachHook');
Hooks::register('UnknownAction', 'FlAction::onUnknownAction');
Hooks::register('SpecialMovepageAfterMove', 'FlAction::onSpecialMovepageAfterMove');
if (FLGetConf('defaultdeleteperm'))
Hooks::register('UserCanDeletFile', 'FlAction::onUserCanDeletFile');
}
$wgResourceModules['ext.FileList'] = array(
'scripts' => array( 'js/form.js', 'js/tableSort.js', 'js/list.js', 'js/iAjaxForm.js'),
'messages' => array( 'fl_empty_file', 'fl_remove_confirm' ),
'localBasePath' => dirname( __FILE__ ),
'remoteExtPath' => basename(dirname(__FILE__)),
);
function FLGetConf($key) {
global $wgFileListConfig;
if(isset($wgFileListConfig[$key]))
return $wgFileListConfig[$key];
if(isset($GLOBALS['wg'.$key]))
return $GLOBALS['wg'.$key];
switch ($key) {
case 'ExtPath':
global $wgExtensionAssetsPath;
return $wgExtensionAssetsPath . '/' . basename(dirname(__FILE__)) . '/';
default:
return -1;
}
}
/**
* get prefix from page name
*
* @param string $pagename
* @return string
*/
function get_prefix_from_page_name($pageName) {
return str_replace(' ', '_', $pageName) . '_-_';
}