X-Git-Url: http://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXml.php;h=9744aeefcc028f0920fff30c92a64ca89e2d889f;hb=6c2a31bbf5b2cf8cfcbd4f9df382217d69b5e18f;hp=4f2720ed859e299b6a2086201f198bf9bcb46d5d;hpb=a42f956a7100deca19c4209c8a83c95531253fa9;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index 4f2720ed85..9744aeefcc 100644 --- a/includes/Xml.php +++ b/includes/Xml.php @@ -20,6 +20,8 @@ * @file */ +use MediaWiki\MediaWikiServices; + /** * Module of static functions for generating XML */ @@ -31,7 +33,7 @@ class Xml { * characters (<, >, &) are escaped but illegals are not touched. * * @param string $element Element name - * @param array $attribs Name=>value pairs. Values will be escaped. + * @param array|null $attribs Name=>value pairs. Values will be escaped. * @param string $contents Null to make an open tag only; '' for a contentless closed tag (default) * @param bool $allowShortTag Whether '' in $contents will result in a contentless closed tag * @return string @@ -79,9 +81,8 @@ class Xml { } /** - * Format an XML element as with self::element(), but run text through the - * $wgContLang->normalize() validator first to ensure that no invalid UTF-8 - * is passed. + * Format an XML element as with self::element(), but run text through the content language's + * normalize() validator first to ensure that no invalid UTF-8 is passed. * * @param string $element * @param array $attribs Name=>value pairs. Values will be escaped. @@ -89,12 +90,12 @@ class Xml { * @return string */ public static function elementClean( $element, $attribs = [], $contents = '' ) { - global $wgContLang; if ( $attribs ) { $attribs = array_map( [ 'UtfNormal\Validator', 'cleanUp' ], $attribs ); } if ( $contents ) { - $contents = $wgContLang->normalize( $contents ); + $contents = + MediaWikiServices::getInstance()->getContentLanguage()->normalize( $contents ); } return self::element( $element, $attribs, $contents ); } @@ -103,7 +104,7 @@ class Xml { * This opens an XML element * * @param string $element Name of the element - * @param array $attribs Array of attributes, see Xml::expandAttributes() + * @param array|null $attribs Array of attributes, see Xml::expandAttributes() * @return string */ public static function openElement( $element, $attribs = null ) { @@ -124,11 +125,11 @@ class Xml { * content you have is already valid xml. * * @param string $element Element name - * @param array $attribs Array of attributes + * @param array|null $attribs Array of attributes * @param string $contents Content of the element * @return string */ - public static function tags( $element, $attribs = null, $contents ) { + public static function tags( $element, $attribs, $contents ) { return self::openElement( $element, $attribs ) . $contents . ""; } @@ -136,7 +137,7 @@ class Xml { * Create a date selector * * @param string $selected The month which should be selected, default ''. - * @param string $allmonths Value of a special item denoting all month. + * @param string|null $allmonths Value of a special item denoting all month. * Null to not include (default). * @param string $id Element identifier * @return string Html string containing the month selector @@ -197,7 +198,7 @@ class Xml { * * @param string $selected The language code of the selected language * @param bool $customisedOnly If true only languages which have some content are listed - * @param string $inLanguage The ISO code of the language to display the select list in (optional) + * @param string|null $inLanguage The ISO code of the language to display the select list in * @param array $overrideAttrs Override the attributes of the select tag (since 1.20) * @param Message|null $msg Label message key (since 1.20) * @return array Array containing 2 items: label HTML and select list HTML @@ -382,7 +383,7 @@ class Xml { $value = false, $attribs = [] ) { list( $label, $input ) = self::inputLabelSep( $label, $name, $id, $size, $value, $attribs ); - return $label . ' ' . $input; + return $label . "\u{00A0}" . $input; } /** @@ -420,7 +421,7 @@ class Xml { public static function checkLabel( $label, $name, $id, $checked = false, $attribs = [] ) { global $wgUseMediaWikiUIEverywhere; $chkLabel = self::check( $name, $checked, [ 'id' => $id ] + $attribs ) . - ' ' . + "\u{00A0}" . self::label( $label, $id, $attribs ); if ( $wgUseMediaWikiUIEverywhere ) { @@ -446,7 +447,7 @@ class Xml { $checked = false, $attribs = [] ) { return self::radio( $name, $value, $checked, [ 'id' => $id ] + $attribs ) . - ' ' . + "\u{00A0}" . self::label( $label, $id, $attribs ); } @@ -477,7 +478,7 @@ class Xml { /** * Convenience function to build an HTML drop-down list item. * @param string $text Text for this item. Will be HTML escaped - * @param string $value Form submission value; if empty, use text + * @param string|null $value Form submission value; if empty, use text * @param bool $selected If true, will be the default selected item * @param array $attribs Optional additional HTML attributes * @return string HTML @@ -503,7 +504,7 @@ class Xml { * @param string $other Text for the "Other reasons" option * @param string $selected Option which should be pre-selected * @param string $class CSS classes for the drop-down - * @param int $tabindex Value of the tabindex attribute + * @param int|null $tabindex Value of the tabindex attribute * @return string */ public static function listDropDown( $name = '', $list = '', $other = '', @@ -758,7 +759,7 @@ class Xml { * @param array $fields Associative array, key is the name of a message that * contains a description for the field, value is an HTML string * containing the appropriate input. - * @param string $submitLabel The name of a message containing a label for + * @param string|null $submitLabel The name of a message containing a label for * the submit button. * @param array $submitAttribs The attributes to add to the submit button * @return string HTML form. @@ -799,7 +800,7 @@ class Xml { * Build a table of data * @param array $rows An array of arrays of strings, each to be a row in a table * @param array $attribs An array of attributes to apply to the table tag [optional] - * @param array $headers An array of strings to use as table headers [optional] + * @param array|null $headers An array of strings to use as table headers [optional] * @return string */ public static function buildTable( $rows, $attribs = [], $headers = null ) {