2013-11-19 12:55:50 +00:00
|
|
|
<?php
|
2013-11-19 13:08:16 +00:00
|
|
|
|
2013-11-19 12:55:50 +00:00
|
|
|
class HTMLTextAreaField extends HTMLFormField {
|
|
|
|
|
const DEFAULT_COLS = 80;
|
|
|
|
|
const DEFAULT_ROWS = 25;
|
|
|
|
|
|
|
|
|
|
function getCols() {
|
2013-11-19 13:08:16 +00:00
|
|
|
return isset( $this->mParams['cols'] ) ? $this->mParams['cols'] : static::DEFAULT_COLS;
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getRows() {
|
2013-11-19 13:08:16 +00:00
|
|
|
return isset( $this->mParams['rows'] ) ? $this->mParams['rows'] : static::DEFAULT_ROWS;
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getInputHTML( $value ) {
|
|
|
|
|
$attribs = array(
|
|
|
|
|
'id' => $this->mID,
|
|
|
|
|
'name' => $this->mName,
|
|
|
|
|
'cols' => $this->getCols(),
|
|
|
|
|
'rows' => $this->getRows(),
|
|
|
|
|
) + $this->getTooltipAndAccessKey();
|
|
|
|
|
|
|
|
|
|
if ( $this->mClass !== '' ) {
|
2013-11-19 13:08:16 +00:00
|
|
|
$attribs['class'] = $this->mClass;
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-19 13:08:16 +00:00
|
|
|
if ( !empty( $this->mParams['disabled'] ) ) {
|
|
|
|
|
$attribs['disabled'] = 'disabled';
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-19 13:08:16 +00:00
|
|
|
if ( !empty( $this->mParams['readonly'] ) ) {
|
|
|
|
|
$attribs['readonly'] = 'readonly';
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
2013-11-19 13:08:16 +00:00
|
|
|
if ( isset( $this->mParams['placeholder'] ) ) {
|
|
|
|
|
$attribs['placeholder'] = $this->mParams['placeholder'];
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
foreach ( array( 'required', 'autofocus' ) as $param ) {
|
2013-11-19 13:08:16 +00:00
|
|
|
if ( isset( $this->mParams[$param] ) ) {
|
|
|
|
|
$attribs[$param] = '';
|
2013-11-19 12:55:50 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return Html::element( 'textarea', $attribs, $value );
|
|
|
|
|
}
|
2013-11-19 13:08:16 +00:00
|
|
|
}
|