1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
|
<?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 = array(
'id' => $this->mID,
'cols' => $this->getCols(),
'rows' => $this->getRows(),
'spellcheck' => $this->getSpellCheck(),
) + $this->getTooltipAndAccessKey();
if ( $this->mClass !== '' ) {
$attribs['class'] = $this->mClass;
}
$allowedParams = array(
'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'] = array( $this->mClass );
}
$allowedParams = array(
'placeholder',
'tabindex',
'disabled',
'readonly',
'required',
'autofocus',
);
$attribs += $this->getAttributes( $allowedParams, array(
'tabindex' => 'tabIndex',
'readonly' => 'readOnly',
) );
return new OOUI\TextInputWidget( array(
'id' => $this->mID,
'name' => $this->mName,
'multiline' => true,
'value' => $value,
'rows' => $this->getRows(),
) + $attribs );
}
}
|