Merge "Add validation of the content model edited by EditPage"
[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 getInputHTML( $value ) {
16 $attribs = array(
17 'id' => $this->mID,
18 'name' => $this->mName,
19 'cols' => $this->getCols(),
20 'rows' => $this->getRows(),
21 ) + $this->getTooltipAndAccessKey();
22
23 if ( $this->mClass !== '' ) {
24 $attribs['class'] = $this->mClass;
25 }
26
27 if ( !empty( $this->mParams['disabled'] ) ) {
28 $attribs['disabled'] = 'disabled';
29 }
30
31 if ( !empty( $this->mParams['readonly'] ) ) {
32 $attribs['readonly'] = 'readonly';
33 }
34
35 if ( isset( $this->mParams['placeholder'] ) ) {
36 $attribs['placeholder'] = $this->mParams['placeholder'];
37 }
38
39 foreach ( array( 'required', 'autofocus' ) as $param ) {
40 if ( isset( $this->mParams[$param] ) ) {
41 $attribs[$param] = '';
42 }
43 }
44
45 return Html::element( 'textarea', $attribs, $value );
46 }
47 }