2023-08-31 16:29:54 +00:00
|
|
|
<?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 = [
|
2023-09-01 12:39:59 +00:00
|
|
|
'addReference' => [
|
2023-08-31 16:29:54 +00:00
|
|
|
'minimumCharacters' => 50,
|
2023-09-11 20:56:42 +00:00
|
|
|
'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,
|
2023-09-28 16:48:05 +00:00
|
|
|
'maximumEditcount' => 100,
|
|
|
|
'ignoreSections' => [],
|
|
|
|
'ignoreLeadSection' => false,
|
2023-08-31 16:29:54 +00:00
|
|
|
],
|
|
|
|
];
|
|
|
|
|
|
|
|
/**
|
|
|
|
* 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 ?? [] );
|
|
|
|
}
|
|
|
|
}
|