mediawiki-extensions-AbuseF.../includes/EditBox/PlainEditBoxBuiler.php
Daimona Eaytoy 6ba8e93537 Create distinct builders for plain and ace editor
Change-Id: I9d2b7572fed6e0b3660d3b0d5dad324d6b75fde9
2021-03-08 09:44:58 +00:00

28 lines
642 B
PHP

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