Split includes/HTMLForm
[lhc/web/wiklou.git] / includes / htmlform / HTMLTextAreaField.php
1 <?php
2 class HTMLTextAreaField extends HTMLFormField {
3 const DEFAULT_COLS = 80;
4 const DEFAULT_ROWS = 25;
5
6 function getCols() {
7 return isset( $this->mParams[ 'cols' ] ) ? $this->mParams[ 'cols' ] : static::DEFAULT_COLS;
8 }
9
10 function getRows() {
11 return isset( $this->mParams[ 'rows' ] ) ? $this->mParams[ 'rows' ] : static::DEFAULT_ROWS;
12 }
13
14 function getInputHTML( $value ) {
15 $attribs = array(
16 'id' => $this->mID,
17 'name' => $this->mName,
18 'cols' => $this->getCols(),
19 'rows' => $this->getRows(),
20 ) + $this->getTooltipAndAccessKey();
21
22 if ( $this->mClass !== '' ) {
23 $attribs[ 'class' ] = $this->mClass;
24 }
25
26 if ( ! empty( $this->mParams[ 'disabled' ] ) ) {
27 $attribs[ 'disabled' ] = 'disabled';
28 }
29
30 if ( ! empty( $this->mParams[ 'readonly' ] ) ) {
31 $attribs[ 'readonly' ] = 'readonly';
32 }
33
34 if ( isset( $this->mParams[ 'placeholder' ] ) ) {
35 $attribs[ 'placeholder' ] = $this->mParams[ 'placeholder' ];
36 }
37
38 foreach ( array( 'required', 'autofocus' ) as $param ) {
39 if ( isset( $this->mParams[ $param ] ) ) {
40 $attribs[ $param ] = '';
41 }
42 }
43
44 return Html::element( 'textarea', $attribs, $value );
45 }
46 }