merging latest master
[lhc/web/wiklou.git] / includes / EditPage.php
index dfc13d5..b61f08d 100644 (file)
@@ -880,11 +880,11 @@ class EditPage {
                                                        # If we just undid one rev, use an autosummary
                                                        $firstrev = $oldrev->getNext();
                                                        if ( $firstrev && $firstrev->getId() == $undo ) {
-                                                               $undoSummary = wfMsgForContent( 'undo-summary', $undo, $undorev->getUserText() );
+                                                               $undoSummary = wfMessage( 'undo-summary', $undo, $undorev->getUserText() )->inContentLanguage()->text() ;
                                                                if ( $this->summary === '' ) {
                                                                        $this->summary = $undoSummary;
                                                                } else {
-                                                                       $this->summary = $undoSummary . wfMsgForContent( 'colon-separator' ) . $this->summary;
+                                                                       $this->summary = $undoSummary . wfMessage( 'colon-separator' )->inContentLanguage()->text()  . $this->summary;
                                                                }
                                                                $this->undidRev = $undo;
                                                        }
@@ -899,7 +899,7 @@ class EditPage {
 
                                        $class = ( $undoMsg == 'success' ? '' : 'error ' ) . "mw-undo-{$undoMsg}";
                                        $this->editFormPageTop .= $wgOut->parse( "<div class=\"{$class}\">" .
-                                               wfMsgNoTrans( 'undo-' . $undoMsg ) . '</div>', true, /* interface */true );
+                                               wfMessage( 'undo-' . $undoMsg )->plain() . '</div>', true, /* interface */true );
                                }
 
                                if ( $content === false ) {
@@ -921,7 +921,7 @@ class EditPage {
         *
         * This difers from Article::getContent() that when a missing revision is
         * encountered the result will be an empty string and not the
-        * 'missing-article' message.
+        * 'missing-revision' message.
         *
         * @since 1.19
         * @return string
@@ -1360,7 +1360,7 @@ class EditPage {
                                                // passed.
                                                if ( $this->summary === '' ) {
                                                        $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
-                                                       $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSectionTitle );
+                                                       $this->summary = wfMessage( 'newsectionsummary', $cleanSectionTitle )->inContentLanguage()->text() ;
                                                }
                                        } elseif ( $this->summary !== '' ) {
                                                // Insert the section title above the content.
@@ -1371,7 +1371,7 @@ class EditPage {
 
                                                // Create a link to the new section from the edit summary.
                                                $cleanSummary = $wgParser->stripSectionName( $this->summary );
-                                               $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSummary );
+                                               $this->summary = wfMessage( 'newsectionsummary', $cleanSummary )->inContentLanguage()->text() ;
                                        }
                                }
 
@@ -1512,14 +1512,14 @@ class EditPage {
                                                // passed.
                                                if ( $this->summary === '' ) {
                                                        $cleanSectionTitle = $wgParser->stripSectionName( $this->sectiontitle );
-                                                       $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSectionTitle );
+                                                       $this->summary = wfMessage( 'newsectionsummary', $cleanSectionTitle )->inContentLanguage()->text() ;
                                                }
                                        } elseif ( $this->summary !== '' ) {
                                                $sectionanchor = $wgParser->guessLegacySectionNameFromWikiText( $this->summary );
                                                # This is a new section, so create a link to the new section
                                                # in the revision summary.
                                                $cleanSummary = $wgParser->stripSectionName( $this->summary );
-                                               $this->summary = wfMsgForContent( 'newsectionsummary', $cleanSummary );
+                                               $this->summary = wfMessage( 'newsectionsummary', $cleanSummary )->inContentLanguage()->text() ;
                                        }
                                } elseif ( $this->section != '' ) {
                                        # Try to get a section anchor from the section source, redirect to edited section if header found
@@ -1966,8 +1966,8 @@ class EditPage {
                                : 'confirmrecreate';
                        $wgOut->addHTML(
                                '<div class="mw-confirm-recreate">' .
-                               wfMsgExt( $key, 'parseinline', $username, "<nowiki>$comment</nowiki>" ) .
-                               Xml::checkLabel( wfMsg( 'recreate' ), 'wpRecreate', 'wpRecreate', false,
+                               wfMessage( $key, $username, "<nowiki>$comment</nowiki>" )->parse() .
+                               Xml::checkLabel( wfMessage( 'recreate' )->text() , 'wpRecreate', 'wpRecreate', false,
                                        array( 'title' => Linker::titleAttrib( 'recreate' ), 'tabindex' => 1, 'id' => 'wpRecreate' )
                                ) .
                                '</div>'
@@ -2178,8 +2178,7 @@ class EditPage {
                                        // Something went wrong
 
                                        $wgOut->wrapWikiMsg( "<div class='errorbox'>\n$1\n</div>\n",
-                                               array( 'missing-article', $this->mTitle->getPrefixedText(),
-                                               wfMsgNoTrans( 'missingarticle-rev', $this->oldid ) ) );
+                                               array( 'missing-revision', $this->oldid ) );
                                }
                        }
                }
@@ -2317,7 +2316,7 @@ class EditPage {
                        }
                }
                $summary = $wgContLang->recodeForEdit( $summary );
-               $labelText = wfMsgExt( $isSubjectPreview ? 'subject' : 'summary', 'parseinline' );
+               $labelText = wfMessage( $isSubjectPreview ? 'subject' : 'summary' )->parse();
                list( $label, $input ) = $this->getSummaryInput( $summary, $labelText, array( 'class' => $summaryClass ), array() );
                $wgOut->addHTML( "{$label} {$input}" );
        }
@@ -2336,11 +2335,11 @@ class EditPage {
                global $wgParser;
 
                if ( $isSubjectPreview )
-                       $summary = wfMsgForContent( 'newsectionsummary', $wgParser->stripSectionName( $summary ) );
+                       $summary = wfMessage( 'newsectionsummary', $wgParser->stripSectionName( $summary )->inContentLanguage()->text()  );
 
                $message = $isSubjectPreview ? 'subject-preview' : 'summary-preview';
 
-               $summary = wfMsgExt( $message, 'parseinline' ) . Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview );
+               $summary = wfMessage( $message )->parse() . Linker::commentBlock( $summary, $this->mTitle, $isSubjectPreview );
                return Xml::tags( 'div', array( 'class' => 'mw-summary-preview' ), $summary );
        }
 
@@ -2554,8 +2553,8 @@ HTML
                $newContent = $newContent->preSaveTransform( $this->mTitle, $wgUser, $popts );
 
                if ( ( $oldContent && !$oldContent->isEmpty() ) || ( $newContent && !$newContent->isEmpty() ) ) {
-                       $oldtitle = wfMsgExt( $oldtitlemsg, array( 'parseinline' ) );
-                       $newtitle = wfMsgExt( 'yourtext', array( 'parseinline' ) );
+                       $oldtitle = wfMessage( $oldtitlemsg )->parse();
+                       $newtitle = wfMessage( 'yourtext' )->parse();
 
                        $de = $oldContent->getContentHandler()->createDifferenceEngine( $this->mArticle->getContext() );
                        $de->setContent( $oldContent, $newContent );
@@ -2608,17 +2607,18 @@ HTML
                global $wgRightsText;
                if ( $wgRightsText ) {
                        $copywarnMsg = array( 'copyrightwarning',
-                               '[[' . wfMsgForContent( 'copyrightpage' ) . ']]',
+                               '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text()  . ']]',
                                $wgRightsText );
                } else {
                        $copywarnMsg = array( 'copyrightwarning2',
-                               '[[' . wfMsgForContent( 'copyrightpage' ) . ']]' );
+                               '[[' . wfMessage( 'copyrightpage' )->inContentLanguage()->text()  . ']]' );
                }
                // Allow for site and per-namespace customization of contribution/copyright notice.
                wfRunHooks( 'EditPageCopyrightWarning', array( $title, &$copywarnMsg ) );
 
+               $msg = call_user_func_array( "wfMessage", $copywarnMsg );
                return "<div id=\"editpage-copywarn\">\n" .
-                       call_user_func_array( "wfMsgNoTrans", $copywarnMsg ) . "\n</div>";
+                       $msg->plain() . "\n</div>";
        }
 
        protected function showStandardInputs( &$tabindex = 2 ) {
@@ -2638,12 +2638,12 @@ HTML
 
                $cancel = $this->getCancelLink();
                if ( $cancel !== '' ) {
-                       $cancel .= wfMsgExt( 'pipe-separator' , 'escapenoentities' );
+                       $cancel .= wfMessage( 'pipe-separator' )->text();
                }
-               $edithelpurl = Skin::makeInternalOrExternalUrl( wfMsgForContent( 'edithelppage' ) );
+               $edithelpurl = Skin::makeInternalOrExternalUrl( wfMessage( 'edithelppage' )->inContentLanguage()->text()  );
                $edithelp = '<a target="helpwindow" href="' . $edithelpurl . '">' .
-                       htmlspecialchars( wfMsg( 'edithelp' ) ) . '</a> ' .
-                       htmlspecialchars( wfMsg( 'newwindow' ) );
+                       wfMessage( 'edithelp' )->escaped() . '</a> ' .
+                       wfMessage( 'newwindow' )->escaped();
                $wgOut->addHTML( "      <span class='editHelp'>{$cancel}{$edithelp}</span>\n" );
                $wgOut->addHTML( "</div><!-- editButtons -->\n</div><!-- editOptions -->\n" );
        }
@@ -2664,7 +2664,7 @@ HTML
                        $handler = ContentHandler::getForModelID( $this->content_model );
                        $de = $handler->createDifferenceEngine( $this->mArticle->getContext() );
                        $de->setContent( $content2, $content1 );
-                       $de->showDiff( wfMsgExt( 'yourtext', 'parseinline' ), wfMsg( 'storedversion' ) );
+                       $de->showDiff( wfMessage( 'yourtext' )->parse(), wfMessage( 'storedversion' )->text()  );
 
                        $wgOut->wrapWikiMsg( '<h2>$1</h2>', "yourtext" );
                        $this->showTextbox2();
@@ -2682,7 +2682,7 @@ HTML
 
                return Linker::linkKnown(
                        $this->getContextTitle(),
-                       wfMsgExt( 'cancel', array( 'parseinline' ) ),
+                       wfMessage( 'cancel' )->parse(),
                        array( 'id' => 'mw-editform-cancel' ),
                        $cancelParams
                );
@@ -2752,9 +2752,9 @@ HTML
                // Quick paranoid permission checks...
                if ( is_object( $data ) ) {
                        if ( $data->log_deleted & LogPage::DELETED_USER )
-                               $data->user_name = wfMsgHtml( 'rev-deleted-user' );
+                               $data->user_name = wfMessage( 'rev-deleted-user' )->escaped();
                        if ( $data->log_deleted & LogPage::DELETED_COMMENT )
-                               $data->log_comment = wfMsgHtml( 'rev-deleted-comment' );
+                               $data->log_comment = wfMessage( 'rev-deleted-comment' )->escaped();
                }
                return $data;
        }
@@ -2777,7 +2777,7 @@ HTML
                                // string, which happens when you initially edit
                                // a category page, due to automatic preview-on-open.
                                $parsedNote = $wgOut->parse( "<div class='previewnote'>" .
-                                       wfMsg( 'session_fail_preview_html' ) . "</div>", true, /* interface */true );
+                                       wfMessage( 'session_fail_preview_html' )->text()  . "</div>", true, /* interface */true );
                        }
                        wfProfileOut( __METHOD__ );
                        return $parsedNote;
@@ -2790,15 +2790,15 @@ HTML
 
                        if ( $this->mTriedSave && !$this->mTokenOk ) {
                                if ( $this->mTokenOkExceptSuffix ) {
-                                       $note = wfMsg( 'token_suffix_mismatch' );
+                                       $note = wfMessage( 'token_suffix_mismatch' )->text() ;
                                } else {
-                                       $note = wfMsg( 'session_fail_preview' );
+                                       $note = wfMessage( 'session_fail_preview' )->text() ;
                                }
                        } elseif ( $this->incompleteForm ) {
-                               $note = wfMsg( 'edit_form_incomplete' );
+                               $note = wfMessage( 'edit_form_incomplete' )->text() ;
                        } else {
-                               $note = wfMsg( 'previewnote' ) .
-                                       ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMsg( 'continue-editing' ) . ']]';
+                               $note = wfMessage( 'previewnote' )->text()  .
+                                       ' [[#' . self::EDITFORM_ID . '|' . $wgLang->getArrow() . ' ' . wfMessage( 'continue-editing' )->text()  . ']]';
                        }
 
                        $parserOptions = ParserOptions::newFromUser( $wgUser );
@@ -2828,12 +2828,12 @@ HTML
                                # Used messages to make sure grep find them:
                                # Messages: usercsspreview, userjspreview, sitecsspreview, sitejspreview
                                if( $level && $format ) {
-                                       $note = "<div id='mw-{$level}{$format}preview'>" . wfMsg( "{$level}{$format}preview" ) . "</div>";
+                                       $note = "<div id='mw-{$level}{$format}preview'>" . wfMessage( "{$level}{$format}preview" )->text()  . "</div>";
                                } else {
-                                       $note = wfMsg( 'previewnote' );
+                                       $note = wfMessage( 'previewnote' )->text() ;
                                }
                        } else {
-                               $note = wfMsg( 'previewnote' );
+                               $note = wfMessage( 'previewnote' )->text() ;
                        }
 
                        $rt = $content->getRedirectChain();
@@ -2876,18 +2876,18 @@ HTML
                                }
                        }
                } catch (MWContentSerializationException $ex) {
-                       $note .= "\n\n" . wfMsg('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() );
+                       $note .= "\n\n" . wfMessage('content-failed-to-parse', $this->content_model, $this->content_format, $ex->getMessage() )->parse();
                        $previewHTML = '';
                }
 
                if ( $this->isConflict ) {
-                       $conflict = '<h2 id="mw-previewconflict">' . htmlspecialchars( wfMsg( 'previewconflict' ) ) . "</h2>\n";
+                       $conflict = '<h2 id="mw-previewconflict">' . wfMessage( 'previewconflict' )->escaped() . "</h2>\n";
                } else {
                        $conflict = '<hr />';
                }
 
                $previewhead = "<div class='previewnote'>\n" .
-                       '<h2 id="mw-previewheader">' . htmlspecialchars( wfMsg( 'preview' ) ) . "</h2>" .
+                       '<h2 id="mw-previewheader">' . wfMessage( 'preview' )->escaped() . "</h2>" .
                        $wgOut->parse( $note, true, /* interface */true ) . $conflict . "</div>\n";
 
                $pageLang = $this->mTitle->getPageLanguage();
@@ -2951,8 +2951,8 @@ HTML
                                'id'     => 'mw-editbutton-bold',
                                'open'   => '\'\'\'',
                                'close'  => '\'\'\'',
-                               'sample' => wfMsg( 'bold_sample' ),
-                               'tip'    => wfMsg( 'bold_tip' ),
+                               'sample' => wfMessage( 'bold_sample' )->text() ,
+                               'tip'    => wfMessage( 'bold_tip' )->text() ,
                                'key'    => 'B'
                        ),
                        array(
@@ -2960,8 +2960,8 @@ HTML
                                'id'     => 'mw-editbutton-italic',
                                'open'   => '\'\'',
                                'close'  => '\'\'',
-                               'sample' => wfMsg( 'italic_sample' ),
-                               'tip'    => wfMsg( 'italic_tip' ),
+                               'sample' => wfMessage( 'italic_sample' )->text() ,
+                               'tip'    => wfMessage( 'italic_tip' )->text() ,
                                'key'    => 'I'
                        ),
                        array(
@@ -2969,8 +2969,8 @@ HTML
                                'id'     => 'mw-editbutton-link',
                                'open'   => '[[',
                                'close'  => ']]',
-                               'sample' => wfMsg( 'link_sample' ),
-                               'tip'    => wfMsg( 'link_tip' ),
+                               'sample' => wfMessage( 'link_sample' )->text() ,
+                               'tip'    => wfMessage( 'link_tip' )->text() ,
                                'key'    => 'L'
                        ),
                        array(
@@ -2978,8 +2978,8 @@ HTML
                                'id'     => 'mw-editbutton-extlink',
                                'open'   => '[',
                                'close'  => ']',
-                               'sample' => wfMsg( 'extlink_sample' ),
-                               'tip'    => wfMsg( 'extlink_tip' ),
+                               'sample' => wfMessage( 'extlink_sample' )->text() ,
+                               'tip'    => wfMessage( 'extlink_tip' )->text() ,
                                'key'    => 'X'
                        ),
                        array(
@@ -2987,8 +2987,8 @@ HTML
                                'id'     => 'mw-editbutton-headline',
                                'open'   => "\n== ",
                                'close'  => " ==\n",
-                               'sample' => wfMsg( 'headline_sample' ),
-                               'tip'    => wfMsg( 'headline_tip' ),
+                               'sample' => wfMessage( 'headline_sample' )->text() ,
+                               'tip'    => wfMessage( 'headline_tip' )->text() ,
                                'key'    => 'H'
                        ),
                        $imagesAvailable ? array(
@@ -2996,8 +2996,8 @@ HTML
                                'id'     => 'mw-editbutton-image',
                                'open'   => '[[' . $wgContLang->getNsText( NS_FILE ) . ':',
                                'close'  => ']]',
-                               'sample' => wfMsg( 'image_sample' ),
-                               'tip'    => wfMsg( 'image_tip' ),
+                               'sample' => wfMessage( 'image_sample' )->text() ,
+                               'tip'    => wfMessage( 'image_tip' )->text() ,
                                'key'    => 'D',
                        ) : false,
                        $imagesAvailable ? array(
@@ -3005,8 +3005,8 @@ HTML
                                'id'     => 'mw-editbutton-media',
                                'open'   => '[[' . $wgContLang->getNsText( NS_MEDIA ) . ':',
                                'close'  => ']]',
-                               'sample' => wfMsg( 'media_sample' ),
-                               'tip'    => wfMsg( 'media_tip' ),
+                               'sample' => wfMessage( 'media_sample' )->text() ,
+                               'tip'    => wfMessage( 'media_tip' )->text() ,
                                'key'    => 'M'
                        ) : false,
                        $wgUseTeX ? array(
@@ -3014,8 +3014,8 @@ HTML
                                'id'     => 'mw-editbutton-math',
                                'open'   => "<math>",
                                'close'  => "</math>",
-                               'sample' => wfMsg( 'math_sample' ),
-                               'tip'    => wfMsg( 'math_tip' ),
+                               'sample' => wfMessage( 'math_sample' )->text() ,
+                               'tip'    => wfMessage( 'math_tip' )->text() ,
                                'key'    => 'C'
                        ) : false,
                        array(
@@ -3023,8 +3023,8 @@ HTML
                                'id'     => 'mw-editbutton-nowiki',
                                'open'   => "<nowiki>",
                                'close'  => "</nowiki>",
-                               'sample' => wfMsg( 'nowiki_sample' ),
-                               'tip'    => wfMsg( 'nowiki_tip' ),
+                               'sample' => wfMessage( 'nowiki_sample' )->text() ,
+                               'tip'    => wfMessage( 'nowiki_tip' )->text() ,
                                'key'    => 'N'
                        ),
                        array(
@@ -3033,7 +3033,7 @@ HTML
                                'open'   => '--~~~~',
                                'close'  => '',
                                'sample' => '',
-                               'tip'    => wfMsg( 'sig_tip' ),
+                               'tip'    => wfMessage( 'sig_tip' )->text() ,
                                'key'    => 'Y'
                        ),
                        array(
@@ -3042,7 +3042,7 @@ HTML
                                'open'   => "\n----\n",
                                'close'  => '',
                                'sample' => '',
-                               'tip'    => wfMsg( 'hr_tip' ),
+                               'tip'    => wfMessage( 'hr_tip' )->text() ,
                                'key'    => 'R'
                        )
                );
@@ -3103,11 +3103,11 @@ HTML
                // don't show the minor edit checkbox if it's a new page or section
                if ( !$this->isNew ) {
                        $checkboxes['minor'] = '';
-                       $minorLabel = wfMsgExt( 'minoredit', array( 'parseinline' ) );
+                       $minorLabel = wfMessage( 'minoredit' )->parse();
                        if ( $wgUser->isAllowed( 'minoredit' ) ) {
                                $attribs = array(
                                        'tabindex'  => ++$tabindex,
-                                       'accesskey' => wfMsg( 'accesskey-minoredit' ),
+                                       'accesskey' => wfMessage( 'accesskey-minoredit' )->text() ,
                                        'id'        => 'wpMinoredit',
                                );
                                $checkboxes['minor'] =
@@ -3118,12 +3118,12 @@ HTML
                        }
                }
 
-               $watchLabel = wfMsgExt( 'watchthis', array( 'parseinline' ) );
+               $watchLabel = wfMessage( 'watchthis' )->parse();
                $checkboxes['watch'] = '';
                if ( $wgUser->isLoggedIn() ) {
                        $attribs = array(
                                'tabindex'  => ++$tabindex,
-                               'accesskey' => wfMsg( 'accesskey-watch' ),
+                               'accesskey' => wfMessage( 'accesskey-watch' )->text() ,
                                'id'        => 'wpWatchthis',
                        );
                        $checkboxes['watch'] =
@@ -3152,9 +3152,9 @@ HTML
                        'name'      => 'wpSave',
                        'type'      => 'submit',
                        'tabindex'  => ++$tabindex,
-                       'value'     => wfMsg( 'savearticle' ),
-                       'accesskey' => wfMsg( 'accesskey-save' ),
-                       'title'     => wfMsg( 'tooltip-save' ) . ' [' . wfMsg( 'accesskey-save' ) . ']',
+                       'value'     => wfMessage( 'savearticle' )->text() ,
+                       'accesskey' => wfMessage( 'accesskey-save' )->text() ,
+                       'title'     => wfMessage( 'tooltip-save' )->text()  . ' [' . wfMessage( 'accesskey-save' )->text()  . ']',
                );
                $buttons['save'] = Xml::element( 'input', $temp, '' );
 
@@ -3164,9 +3164,9 @@ HTML
                        'name'      => 'wpPreview',
                        'type'      => 'submit',
                        'tabindex'  => $tabindex,
-                       'value'     => wfMsg( 'showpreview' ),
-                       'accesskey' => wfMsg( 'accesskey-preview' ),
-                       'title'     => wfMsg( 'tooltip-preview' ) . ' [' . wfMsg( 'accesskey-preview' ) . ']',
+                       'value'     => wfMessage( 'showpreview' )->text() ,
+                       'accesskey' => wfMessage( 'accesskey-preview' )->text() ,
+                       'title'     => wfMessage( 'tooltip-preview' )->text()  . ' [' . wfMessage( 'accesskey-preview' )->text()  . ']',
                );
                $buttons['preview'] = Xml::element( 'input', $temp, '' );
                $buttons['live'] = '';
@@ -3176,9 +3176,9 @@ HTML
                        'name'      => 'wpDiff',
                        'type'      => 'submit',
                        'tabindex'  => ++$tabindex,
-                       'value'     => wfMsg( 'showdiff' ),
-                       'accesskey' => wfMsg( 'accesskey-diff' ),
-                       'title'     => wfMsg( 'tooltip-diff' ) . ' [' . wfMsg( 'accesskey-diff' ) . ']',
+                       'value'     => wfMessage( 'showdiff' )->text() ,
+                       'accesskey' => wfMessage( 'accesskey-diff' )->text() ,
+                       'title'     => wfMessage( 'tooltip-diff' )->text()  . ' [' . wfMessage( 'accesskey-diff' )->text()  . ']',
                );
                $buttons['diff'] = Xml::element( 'input', $temp, '' );
 
@@ -3259,7 +3259,7 @@ HTML
 
                $wgOut->prepareErrorPage( wfMessage( 'nosuchsectiontitle' ) );
 
-               $res = wfMsgExt( 'nosuchsectiontext', 'parse', $this->section );
+               $res = wfMessage( 'nosuchsectiontext', 'parse', $this->section )->parseAsBlock();
                wfRunHooks( 'EditPageNoSuchSection', array( &$this, &$res ) );
                $wgOut->addHTML( $res );