X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FXml.php;h=d1a56bf78e6dd10df5d9fcefbb93d13c2b9946d6;hb=8d52cf3d128f4a1d9810fc8ede4cb6ce2e38e84b;hp=40be80bc5beae1c8223e48829fe8b2e6d0edb167;hpb=4b5773a4de8156c026be2aab92e059793d612fdd;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/Xml.php b/includes/Xml.php index 40be80bc5b..d1a56bf78e 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 ) { @@ -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 @@ -453,7 +454,7 @@ class Xml { /** * Convenience function to build an HTML submit button * When $wgUseMediaWikiUIEverywhere is true it will default to a progressive button - * @param string $value Label text for the button + * @param string $value Label text for the button (unescaped) * @param array $attribs Optional custom attributes * @return string HTML */ @@ -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 ) {