mediawiki-extensions-AbuseF.../includes/EditBox/PlainEditBoxBuilder.php
Matěj Suchánek f9dcf46d70 Replace most Xml methods with Html
Xml::buildForm and Xml::fieldset are left.

Change-Id: Iff88869fd002165ec9ee80897d4deb585005b9d1
2024-05-08 13:08:52 +02:00

34 lines
744 B
PHP

<?php
namespace MediaWiki\Extension\AbuseFilter\EditBox;
use MediaWiki\Html\Html;
/**
* Class responsible for building a plain text filter edit box
*/
class PlainEditBoxBuilder extends EditBoxBuilder {
/**
* @inheritDoc
*/
public function getEditBox( string $rules, bool $isUserAllowed, bool $externalForm ): string {
$rules = rtrim( $rules ) . "\n";
$editorAttribs = [
'name' => 'wpFilterRules',
'id' => 'wpFilterRules',
// Rules are in English
'dir' => 'ltr',
'cols' => 40,
'rows' => 15,
];
if ( !$isUserAllowed ) {
$editorAttribs['readonly'] = 'readonly';
}
if ( $externalForm ) {
$editorAttribs['form'] = 'wpFilterForm';
}
return Html::element( 'textarea', $editorAttribs, $rules );
}
}