Merge "Use mw.util.getUrl( null ) to get the default mw.config.get( 'wgPageName' )"
[lhc/web/wiklou.git] / includes / Xml.php
index 8c65461..b368a13 100644 (file)
@@ -20,6 +20,8 @@
  * @file
  */
 
+use MediaWiki\MediaWikiServices;
+
 /**
  * Module of static functions for generating XML
  */
@@ -45,12 +47,10 @@ class Xml {
                }
                if ( is_null( $contents ) ) {
                        $out .= '>';
+               } elseif ( $allowShortTag && $contents === '' ) {
+                       $out .= ' />';
                } else {
-                       if ( $allowShortTag && $contents === '' ) {
-                               $out .= ' />';
-                       } else {
-                               $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
-                       }
+                       $out .= '>' . htmlspecialchars( $contents, ENT_NOQUOTES ) . "</$element>";
                }
                return $out;
        }
@@ -79,9 +79,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 +88,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 );
        }
@@ -267,7 +266,7 @@ class Xml {
        /**
         * Convenience function to build an HTML text input field
         * @param string $name Value of the name attribute
-        * @param int $size Value of the size attribute
+        * @param int|false $size Value of the size attribute
         * @param mixed $value Value of the value attribute
         * @param array $attribs Other attributes
         * @return string HTML
@@ -290,7 +289,7 @@ class Xml {
        /**
         * Convenience function to build an HTML password input field
         * @param string $name Value of the name attribute
-        * @param int $size Value of the size attribute
+        * @param int|false $size Value of the size attribute
         * @param mixed $value Value of the value attribute
         * @param array $attribs Other attributes
         * @return string HTML
@@ -453,7 +452,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
         */
@@ -601,7 +600,7 @@ class Xml {
         *
         * @param string|bool $legend Legend of the fieldset. If evaluates to false,
         *   legend is not added.
-        * @param string $content Pre-escaped content for the fieldset. If false,
+        * @param string|false $content Pre-escaped content for the fieldset. If false,
         *   only open fieldset is returned.
         * @param array $attribs Any attributes to fieldset-element.
         *