2021-03-04 11:24:20 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace MediaWiki\Extension\AbuseFilter\EditBox;
|
|
|
|
|
2024-03-29 12:40:23 +00:00
|
|
|
use MediaWiki\Html\Html;
|
2021-03-04 11:24:20 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Class responsible for building a plain text filter edit box
|
|
|
|
*/
|
2023-11-16 19:00:41 +00:00
|
|
|
class PlainEditBoxBuilder extends EditBoxBuilder {
|
2021-03-04 11:24:20 +00:00
|
|
|
/**
|
|
|
|
* @inheritDoc
|
|
|
|
*/
|
2021-07-21 18:51:12 +00:00
|
|
|
public function getEditBox( string $rules, bool $isUserAllowed, bool $externalForm ): string {
|
2021-03-04 11:24:20 +00:00
|
|
|
$rules = rtrim( $rules ) . "\n";
|
2024-05-04 08:14:01 +00:00
|
|
|
$editorAttribs = [
|
2024-03-29 12:40:23 +00:00
|
|
|
'name' => 'wpFilterRules',
|
2024-05-04 08:14:01 +00:00
|
|
|
'id' => 'wpFilterRules',
|
|
|
|
// Rules are in English
|
|
|
|
'dir' => 'ltr',
|
|
|
|
'cols' => 40,
|
2024-03-29 12:40:23 +00:00
|
|
|
'rows' => 15,
|
2024-05-04 08:14:01 +00:00
|
|
|
];
|
2021-03-04 11:24:20 +00:00
|
|
|
if ( !$isUserAllowed ) {
|
|
|
|
$editorAttribs['readonly'] = 'readonly';
|
|
|
|
}
|
|
|
|
if ( $externalForm ) {
|
|
|
|
$editorAttribs['form'] = 'wpFilterForm';
|
|
|
|
}
|
2024-03-29 12:40:23 +00:00
|
|
|
return Html::element( 'textarea', $editorAttribs, $rules );
|
2021-03-04 11:24:20 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|