wiki.techinc.nl/includes/htmlform/HTMLTextAreaField.php
Kunal Mehta 6e9b4f0e9c Convert all array() syntax to []
Per wikitech-l consensus:
 https://lists.wikimedia.org/pipermail/wikitech-l/2016-February/084821.html

Notes:
* Disabled CallTimePassByReference due to false positives (T127163)

Change-Id: I2c8ce713ce6600a0bb7bf67537c87044c7a45c4b
2016-02-17 01:33:00 -08:00

82 lines
1.8 KiB
PHP

<?php
class HTMLTextAreaField extends HTMLFormField {
const DEFAULT_COLS = 80;
const DEFAULT_ROWS = 25;
function getCols() {
return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
}
function getRows() {
return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
}
function getSpellCheck() {
$val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
if ( is_bool( $val ) ) {
// "spellcheck" attribute literally requires "true" or "false" to work.
return $val === true ? 'true' : 'false';
}
return null;
}
function getInputHTML( $value ) {
$attribs = [
'id' => $this->mID,
'cols' => $this->getCols(),
'rows' => $this->getRows(),
'spellcheck' => $this->getSpellCheck(),
] + $this->getTooltipAndAccessKey();
if ( $this->mClass !== '' ) {
$attribs['class'] = $this->mClass;
}
$allowedParams = [
'placeholder',
'tabindex',
'disabled',
'readonly',
'required',
'autofocus'
];
$attribs += $this->getAttributes( $allowedParams );
return Html::textarea( $this->mName, $value, $attribs );
}
function getInputOOUI( $value ) {
if ( isset( $this->mParams['cols'] ) ) {
throw new Exception( "OOUIHTMLForm does not support the 'cols' parameter for textareas" );
}
$attribs = $this->getTooltipAndAccessKey();
if ( $this->mClass !== '' ) {
$attribs['classes'] = [ $this->mClass ];
}
$allowedParams = [
'placeholder',
'tabindex',
'disabled',
'readonly',
'required',
'autofocus',
];
$attribs += $this->getAttributes( $allowedParams, [
'tabindex' => 'tabIndex',
'readonly' => 'readOnly',
] );
return new OOUI\TextInputWidget( [
'id' => $this->mID,
'name' => $this->mName,
'multiline' => true,
'value' => $value,
'rows' => $this->getRows(),
] + $attribs );
}
}