*
* @return string Valid HTML.
*/
- abstract function getInputHTML( $value );
+ abstract public function getInputHTML( $value );
/**
* Same as getInputHTML, but returns an OOUI object.
* @param string $value
* @return OOUI\Widget|false
*/
- function getInputOOUI( $value ) {
+ public function getInputOOUI( $value ) {
return false;
}
* @return bool
*/
public function canDisplayErrors() {
- return true;
+ return $this->hasVisibleOutput();
}
/**
*
* @return Message
*/
- function msg() {
+ public function msg() {
$args = func_get_args();
if ( $this->mParent ) {
* @param array $alldata The data collected from the form
* @return bool
*/
- function isHidden( $alldata ) {
+ public function isHidden( $alldata ) {
if ( !$this->mHideIf ) {
return false;
}
*
* @return bool True to cancel the submission
*/
- function cancelSubmit( $value, $alldata ) {
+ public function cancelSubmit( $value, $alldata ) {
return false;
}
* @return bool|string True on success, or String error to display, or
* false to fail validation without displaying an error.
*/
- function validate( $value, $alldata ) {
+ public function validate( $value, $alldata ) {
if ( $this->isHidden( $alldata ) ) {
return true;
}
return true;
}
- function filter( $value, $alldata ) {
+ public function filter( $value, $alldata ) {
if ( isset( $this->mFilterCallback ) ) {
$value = call_user_func( $this->mFilterCallback, $value, $alldata, $this->mParent );
}
* @param WebRequest $request
* @return string The value
*/
- function loadDataFromRequest( $request ) {
+ public function loadDataFromRequest( $request ) {
if ( $request->getCheck( $this->mName ) ) {
return $request->getText( $this->mName );
} else {
* @since 1.22 The 'label' attribute no longer accepts raw HTML, use 'label-raw' instead
* @throws MWException
*/
- function __construct( $params ) {
+ public function __construct( $params ) {
$this->mParams = $params;
if ( isset( $params['parent'] ) && $params['parent'] instanceof HTMLForm ) {
$this->mFilterCallback = $params['filter-callback'];
}
- if ( isset( $params['flatlist'] ) ) {
- $this->mClass .= ' mw-htmlform-flatlist';
- }
-
if ( isset( $params['hidelabel'] ) ) {
$this->mShowEmptyLabels = false;
}
*
* @return string Complete HTML table row.
*/
- function getTableRow( $value ) {
+ public function getTableRow( $value ) {
list( $errors, $errorClass ) = $this->getErrorsAndErrorClass( $value );
$inputHtml = $this->getInputHTML( $value );
$fieldType = get_class( $this );
}
$fieldType = get_class( $this );
- $helpText = $this->getHelpText();
+ $help = $this->getHelpText();
$errors = $this->getErrorsRaw( $value );
foreach ( $errors as &$error ) {
$error = new OOUI\HtmlSnippet( $error );
$config = [
'classes' => [ "mw-htmlform-field-$fieldType", $this->mClass ],
'align' => $this->getLabelAlignOOUI(),
- 'help' => $helpText !== null ? new OOUI\HtmlSnippet( $helpText ) : null,
+ 'help' => ( $help !== null && $help !== '' ) ? new OOUI\HtmlSnippet( $help ) : null,
'errors' => $errors,
'notices' => $notices,
'infusable' => $infusable,
/**
* Determine the help text to display
* @since 1.20
- * @return string HTML
+ * @return string|null HTML
*/
public function getHelpText() {
$helptext = null;
* @since 1.28
* @return string[]
*/
- function getNotices() {
+ public function getNotices() {
$notices = [];
if ( isset( $this->mParams['notice-message'] ) ) {
/**
* @return string HTML
*/
- function getLabel() {
+ public function getLabel() {
return is_null( $this->mLabel ) ? '' : $this->mLabel;
}
- function getLabelHtml( $cellAttributes = [] ) {
+ public function getLabelHtml( $cellAttributes = [] ) {
# Don't output a for= attribute for labels with no associated input.
# Kind of hacky here, possibly we don't want these to be <label>s at all.
$for = [];
return $html;
}
- function getDefault() {
+ public function getDefault() {
if ( isset( $this->mDefault ) ) {
return $this->mDefault;
} else {
* @param array $array
* @return array
*/
- static function forceToStringRecursive( $array ) {
+ public static function forceToStringRecursive( $array ) {
if ( is_array( $array ) ) {
return array_map( [ __CLASS__, 'forceToStringRecursive' ], $array );
} else {