Make $wgForceUIMsgAsContentMsg work a bit different for the messages we place in...
authorPlatonides <platonides@users.mediawiki.org>
Fri, 3 Dec 2010 00:21:50 +0000 (00:21 +0000)
committerPlatonides <platonides@users.mediawiki.org>
Fri, 3 Dec 2010 00:21:50 +0000 (00:21 +0000)
This is specially intended for commons, such that it no longer needs a bot changing the headers after each upload.

See http://commons.wikimedia.org/w/index.php?title=Commons%3AVillage_pump&action=historysubmit&diff=46619490&oldid=46619456#Uploading_a_new_file.2C_and_proceeding_updates

includes/specials/SpecialUpload.php

index 7a7a808..37db906 100644 (file)
@@ -486,21 +486,35 @@ class SpecialUpload extends SpecialPage {
         * Get the initial image page text based on a comment and optional file status information
         */
        public static function getInitialPageText( $comment = '', $license = '', $copyStatus = '', $source = '' ) {
-               global $wgUseCopyrightUpload;
+               global $wgUseCopyrightUpload, $wgForceUIMsgAsContentMsg;
+               $wgForceUIMsgAsContentMsg = (array) $wgForceUIMsgAsContentMsg;
+
+               /* These messages are transcluded into the actual text of the description page.
+                * Thus, forcing them as content messages makes the upload to produce an int: template
+                * instead of hardcoding it there in the uploader language.
+                */
+               foreach( array( 'license-header', 'filedesc', 'filestatus', 'filesource' ) as $msgName ) {
+                       if ( in_array( $msgName, $wgForceUIMsgAsContentMsg ) ) {
+                               $msg[$msgName] = "{{int:$msgName}}";
+                       } else {
+                               $msg[$msgName] = wfMsgForContent( $msgName );
+                       }
+               }
+
                if ( $wgUseCopyrightUpload ) {
                        $licensetxt = '';
                        if ( $license != '' ) {
-                               $licensetxt = '== ' . wfMsgForContent( 'license-header' ) . " ==\n" . '{{' . $license . '}}' . "\n";
+                               $licensetxt = '== ' . $msg[ 'license-header' ] . " ==\n" . '{{' . $license . '}}' . "\n";
                        }
-                       $pageText = '== ' . wfMsgForContent( 'filedesc' ) . " ==\n" . $comment . "\n" .
-                               '== ' . wfMsgForContent( 'filestatus' ) . " ==\n" . $copyStatus . "\n" .
+                       $pageText = '== ' . $msg[ 'filedesc' ] . " ==\n" . $comment . "\n" .
+                               '== ' . $msg[ 'filestatus' ] . " ==\n" . $copyStatus . "\n" .
                                "$licensetxt" .
-                               '== ' . wfMsgForContent( 'filesource' ) . " ==\n" . $source;
+                               '== ' . $msg[ 'filesource' ] . " ==\n" . $source;
                } else {
                        if ( $license != '' ) {
-                               $filedesc = $comment == '' ? '' : '== ' . wfMsgForContent( 'filedesc' ) . " ==\n" . $comment . "\n";
+                               $filedesc = $comment == '' ? '' : '== ' . $msg[ 'filedesc' ] . " ==\n" . $comment . "\n";
                                        $pageText = $filedesc .
-                                       '== ' . wfMsgForContent( 'license-header' ) . " ==\n" . '{{' . $license . '}}' . "\n";
+                                       '== ' . $msg[ 'license-header' ] . " ==\n" . '{{' . $license . '}}' . "\n";
                        } else {
                                $pageText = $comment;
                        }