blob: e028d38c4a8adfd958af54154ae5466fb8ff61c9 (
plain)
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
|
<?php
declare( strict_types = 1 );
namespace MediaWiki\Extension\Translate\Utilities;
/**
* A helper class added to work with configuration values of the Translate Extension
*
* Also used temporarily to simplify deprecation of old configuration variables. New
* variable names, if set, are given preference over the old ones.
* See: https://phabricator.wikimedia.org/T277965
*
* @author Abijeet Patro.
* @license GPL-2.0-or-later
* @since 2021.06
*/
class ConfigHelper {
/** @return bool|string */
public function getValidationExclusionFile() {
global $wgTranslateValidationExclusionFile;
return $wgTranslateValidationExclusionFile;
}
public function getTranslateAuthorExclusionList(): array {
global $wgTranslateAuthorExclusionList;
return $wgTranslateAuthorExclusionList;
}
public function getDisabledTargetLanguages(): array {
global $wgTranslateDisabledTargetLanguages;
return $wgTranslateDisabledTargetLanguages;
}
public function isAuthorExcluded( string $groupId, string $languageCode, string $username ): bool {
$hash = "$groupId;$languageCode;$username";
$authorExclusionList = $this->getTranslateAuthorExclusionList();
$excluded = false;
foreach ( $authorExclusionList as $rule ) {
list( $type, $regex ) = $rule;
if ( preg_match( $regex, $hash ) ) {
if ( $type === 'include' ) {
return false;
} else {
$excluded = true;
}
}
}
return $excluded;
}
}
|