diff options
author | Fomafix <fomafix@googlemail.com> | 2016-12-27 22:14:16 +0100 |
---|---|---|
committer | Krinkle <krinklemail@gmail.com> | 2018-06-24 01:20:13 +0000 |
commit | 125cbd8c017b872c78f047c08f494a458883db23 (patch) | |
tree | 4e271c169d5558200f9577e2767403d2ffe9e360 /includes/htmlform/HTMLFormField.php | |
parent | 0dead475ab85cbd9c106c8fbaa38779b0c16aaea (diff) | |
download | mediawikicore-125cbd8c017b872c78f047c08f494a458883db23.tar.gz mediawikicore-125cbd8c017b872c78f047c08f494a458883db23.zip |
Use \u{00A0} instead of   or
Directly use the UTF-8 encoding of the 'NO-BREAK SPACE' (U+00A0) instead of
the HTML/XML entities   or   or .
With the UTF-8 character the generated HTML is shorter and better to read.
Also change the special value for the label in HTMLForm from   to
U+00A0 but also support   for backward compability.
Bug: T154300
Change-Id: I882599ac1120789bb4e524c4394870680caca4f4
Diffstat (limited to 'includes/htmlform/HTMLFormField.php')
-rw-r--r-- | includes/htmlform/HTMLFormField.php | 20 |
1 files changed, 13 insertions, 7 deletions
diff --git a/includes/htmlform/HTMLFormField.php b/includes/htmlform/HTMLFormField.php index a70157572a07..31c72607fcba 100644 --- a/includes/htmlform/HTMLFormField.php +++ b/includes/htmlform/HTMLFormField.php @@ -397,9 +397,9 @@ abstract class HTMLFormField { if ( isset( $params['label-message'] ) ) { $this->mLabel = $this->getMessage( $params['label-message'] )->parse(); } elseif ( isset( $params['label'] ) ) { - if ( $params['label'] === ' ' ) { + if ( $params['label'] === ' ' || $params['label'] === "\u{00A0}" ) { // Apparently some things set   directly and in an odd format - $this->mLabel = ' '; + $this->mLabel = "\u{00A0}"; } else { $this->mLabel = htmlspecialchars( $params['label'] ); } @@ -546,7 +546,7 @@ abstract class HTMLFormField { $horizontalLabel = $this->mParams['horizontal-label'] ?? false; if ( $horizontalLabel ) { - $field = ' ' . $inputHtml . "\n$errors"; + $field = "\u{00A0}" . $inputHtml . "\n$errors"; } else { $field = Html::rawElement( 'div', @@ -630,7 +630,7 @@ abstract class HTMLFormField { // the element could specify, that the label doesn't need to be added $label = $this->getLabel(); - if ( $label && $label !== ' ' ) { + if ( $label && $label !== "\u{00A0}" ) { $config['label'] = new OOUI\HtmlSnippet( $label ); } @@ -745,7 +745,7 @@ abstract class HTMLFormField { $label = $this->getLabelHtml( $cellAttributes ); $html = "\n" . $errors . - $label . ' ' . + $label . "\u{00A0}" . $inputHtml . $helptext; @@ -926,7 +926,13 @@ abstract class HTMLFormField { * @return string HTML */ public function getLabel() { - return is_null( $this->mLabel ) ? '' : $this->mLabel; + if ( is_null( $this->mLabel ) ) { + return ''; + } + if ( $this->mLabel === ' ' ) { + return "\u{00A0}"; + } + return $this->mLabel; } public function getLabelHtml( $cellAttributes = [] ) { @@ -940,7 +946,7 @@ abstract class HTMLFormField { $labelValue = trim( $this->getLabel() ); $hasLabel = false; - if ( $labelValue !== ' ' && $labelValue !== '' ) { + if ( $labelValue !== "\u{00A0}" && $labelValue !== '' ) { $hasLabel = true; } |