EditPage: Allow language of copyright warning to be specified
authorAlex Monk <krenair@gmail.com>
Tue, 27 Sep 2016 00:23:21 +0000 (01:23 +0100)
committerLegoktm <legoktm.wikipedia@gmail.com>
Tue, 27 Sep 2016 03:35:38 +0000 (03:35 +0000)
This avoids global state, and is necessary in places where the
global user language cannot be used, such as load.php.

Bug: T146686
Change-Id: I80a813a76b551643b68430e6a0ab553b2e1dfb11

includes/EditPage.php

index 406673d..9116d4f 100644 (file)
@@ -3496,7 +3496,7 @@ HTML
         * @param string $format Output format, valid values are any function of a Message object
         * @return string
         */
-       public static function getCopyrightWarning( $title, $format = 'plain' ) {
+       public static function getCopyrightWarning( $title, $format = 'plain', $langcode = null ) {
                global $wgRightsText;
                if ( $wgRightsText ) {
                        $copywarnMsg = [ 'copyrightwarning',
@@ -3509,8 +3509,12 @@ HTML
                // Allow for site and per-namespace customization of contribution/copyright notice.
                Hooks::run( 'EditPageCopyrightWarning', [ $title, &$copywarnMsg ] );
 
+               $msg = call_user_func_array( 'wfMessage', $copywarnMsg )->title( $title );
+               if ( $langcode ) {
+                       $msg->inLanguage( $langcode );
+               }
                return "<div id=\"editpage-copywarn\">\n" .
-                       call_user_func_array( 'wfMessage', $copywarnMsg )->title( $title )->$format() . "\n</div>";
+                       $msg->$format() . "\n</div>";
        }
 
        /**