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 Validator MediaWiki extension.
*
* @licence GNU GPL v2+
* @author Jeroen De Dauw < jeroendedauw@gmail.com >
*/
if ( defined( 'ParamProcessor_VERSION' ) ) {
// Do not initialize more than once.
return 1;
}
define( 'Validator_VERSION', '2.2.1' );
define( 'ParamProcessor_VERSION', Validator_VERSION ); // @deprecated since 1.0
// Internationalization
$GLOBALS['wgMessagesDirs']['Validator'] = __DIR__ . '/i18n';
$GLOBALS['wgExtensionFunctions'][] = function () {
if ( version_compare( $GLOBALS['wgVersion'], '1.23c', '<' ) ) {
die( '<b>Error:</b> This version of Validator requires MediaWiki 1.23 or above.' );
}
if ( is_readable( __DIR__ . '/vendor/autoload.php' ) ) {
include_once( __DIR__ . '/vendor/autoload.php' );
}
if ( !class_exists( ParamProcessor\Processor::class ) ) {
throw new Exception( 'Validator depends on the ParamProcessor library.' );
}
// Display extension information
$GLOBALS['wgExtensionCredits']['other'][] = array(
'path' => __FILE__,
'name' => 'Validator',
'version' => Validator_VERSION,
'author' => array(
'[https://www.mediawiki.org/wiki/User:Jeroen_De_Dauw Jeroen De Dauw]'
),
'url' => 'https://github.com/JeroenDeDauw/Validator',
'descriptionmsg' => 'validator-desc',
'license-name' => 'GPL-2.0+'
);
/**
* Hook to add PHPUnit test cases.
* @see https://www.mediawiki.org/wiki/Manual:Hooks/UnitTestsList
*
* @since 1.0
*
* @param array $files
*
* @return boolean
*/
$GLOBALS['wgHooks']['UnitTestsList'][] = function( array &$files ) {
// @codeCoverageIgnoreStart
$directoryIterator = new RecursiveDirectoryIterator( __DIR__ . '/tests/phpunit/' );
/**
* @var SplFileInfo $fileInfo
*/
foreach ( new RecursiveIteratorIterator( $directoryIterator ) as $fileInfo ) {
if ( substr( $fileInfo->getFilename(), -8 ) === 'Test.php' ) {
$files[] = $fileInfo->getPathname();
}
}
return true;
// @codeCoverageIgnoreEnd
};
$GLOBALS['wgDataValues']['mediawikititle'] = ParamProcessor\MediaWikiTitleValue::class;
$GLOBALS['wgParamDefinitions']['title'] = array(
'string-parser' => ParamProcessor\TitleParser::class,
'validator' => ValueValidators\TitleValidator::class,
);
};
|