Added a separate error message for mkdir failures
[lhc/web/wiklou.git] / includes / htmlform / HTMLTextAreaField.php
1 <?php
2
3 class HTMLTextAreaField extends HTMLFormField {
4 const DEFAULT_COLS = 80;
5 const DEFAULT_ROWS = 25;
6
7 function getCols() {
8 return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
9 }
10
11 function getRows() {
12 return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
13 }
14
15 function getSpellCheck() {
16 $val = isset( $this->mParams['spellcheck'] ) ? $this->mParams['spellcheck'] : null;
17 if ( is_bool( $val ) ) {
18 // "spellcheck" attribute literally requires "true" or "false" to work.
19 return $val === true ? 'true' : 'false';
20 }
21 return null;
22 }
23
24 function getInputHTML( $value ) {
25 $attribs = array(
26 'id' => $this->mID,
27 'cols' => $this->getCols(),
28 'rows' => $this->getRows(),
29 'spellcheck' => $this->getSpellCheck(),
30 ) + $this->getTooltipAndAccessKey();
31
32 if ( $this->mClass !== '' ) {
33 $attribs['class'] = $this->mClass;
34 }
35
36 $allowedParams = array(
37 'placeholder',
38 'tabindex',
39 'disabled',
40 'readonly',
41 'required',
42 'autofocus'
43 );
44
45 $attribs += $this->getAttributes( $allowedParams );
46 return Html::textarea( $this->mName, $value, $attribs );
47 }
48
49 function getInputOOUI( $value ) {
50 if ( isset( $this->mParams['cols'] ) ) {
51 throw new Exception( "OOUIHTMLForm does not support the 'cols' parameter for textareas" );
52 }
53
54 $attribs = $this->getTooltipAndAccessKey();
55
56 if ( $this->mClass !== '' ) {
57 $attribs['classes'] = array( $this->mClass );
58 }
59
60 $allowedParams = array(
61 'placeholder',
62 'tabindex',
63 'disabled',
64 'readonly',
65 'required',
66 'autofocus',
67 );
68
69 $attribs += $this->getAttributes( $allowedParams, array(
70 'tabindex' => 'tabIndex',
71 'readonly' => 'readOnly',
72 ) );
73
74 return new OOUI\TextInputWidget( array(
75 'id' => $this->mID,
76 'name' => $this->mName,
77 'multiline' => true,
78 'value' => $value,
79 'rows' => $this->getRows(),
80 ) + $attribs );
81 }
82 }