mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/VisualEditor
synced 2024-11-30 17:14:42 +00:00
5d6463ebba
Adds two new configs: * ignoreSections, array of section names that'll be compared * ignoreLeadSection, bool for whether to ignore the lead section Bug: T346949 Depends-On: I7ded925b91b1d86b3c76c4135c85a3f0be1dee5e Change-Id: I44f18fadcafbe011008d8abff566e2ccd7682f4f
40 lines
1 KiB
PHP
40 lines
1 KiB
PHP
<?php
|
|
/**
|
|
* Utilities for ResourceLoader modules used by EditCheck.
|
|
*
|
|
* @file
|
|
* @ingroup Extensions
|
|
* @license MIT
|
|
*/
|
|
|
|
namespace MediaWiki\Extension\VisualEditor\EditCheck;
|
|
|
|
use MessageLocalizer;
|
|
|
|
class ResourceLoaderData {
|
|
protected static array $defaults = [
|
|
'addReference' => [
|
|
'minimumCharacters' => 50,
|
|
'beforePunctuation' => false,
|
|
// TODO: when we have multiple edit checks this will likely be a generic block:
|
|
// account: loggedin, loggedout, anything non-truthy means allow either
|
|
'account' => false,
|
|
'maximumEditcount' => 100,
|
|
'ignoreSections' => [],
|
|
'ignoreLeadSection' => false,
|
|
],
|
|
];
|
|
|
|
/**
|
|
* Return configuration data for edit checks, fetched from an on-wiki JSON message
|
|
*
|
|
* @param MessageLocalizer $context
|
|
* @return array Configuration data for edit checks
|
|
*/
|
|
public static function getConfig( MessageLocalizer $context ) {
|
|
$raw_config = json_decode( $context->msg( 'editcheck-config.json' )->inContentLanguage()->plain(), true );
|
|
|
|
return array_replace_recursive( self::$defaults, $raw_config ?? [] );
|
|
}
|
|
}
|