Use local context to get messages and time formatting methods of Language class
authorAlexandre Emsenhuber <ialex.wiki@gmail.com>
Wed, 2 May 2012 21:13:47 +0000 (23:13 +0200)
committerAlexandre Emsenhuber <ialex.wiki@gmail.com>
Fri, 4 May 2012 05:53:55 +0000 (07:53 +0200)
Change-Id: I04d460a63f40e13e7f84cb168a9001516b1215fa

includes/specials/SpecialRevisiondelete.php

index 0388f5b..b754760 100644 (file)
@@ -221,7 +221,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $links = array();
                        $links[] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Log' ),
-                               wfMsgHtml( 'viewpagelogs' ),
+                               $this->msg( 'viewpagelogs' )->escaped(),
                                array(),
                                array( 'page' => $this->targetObj->getPrefixedText() )
                        );
@@ -229,7 +229,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                # Give a link to the page history
                                $links[] = Linker::linkKnown(
                                        $this->targetObj,
-                                       wfMsgHtml( 'pagehist' ),
+                                       $this->msg( 'pagehist' )->escaped(),
                                        array(),
                                        array( 'action' => 'history' )
                                );
@@ -238,7 +238,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                        $undelete = SpecialPage::getTitleFor( 'Undelete' );
                                        $links[] = Linker::linkKnown(
                                                $undelete,
-                                               wfMsgHtml( 'deletedhist' ),
+                                               $this->msg( 'deletedhist' )->escaped(),
                                                array(),
                                                array( 'target' => $this->targetObj->getPrefixedDBkey() )
                                        );
@@ -276,7 +276,8 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $this->getOutput()->addWikiMsg( 'revdelete-no-file' );
                        return;
                }
-               if( !$oimage->userCan( File::DELETED_FILE, $this->getUser() ) ) {
+               $user = $this->getUser();
+               if( !$oimage->userCan( File::DELETED_FILE, $user ) ) {
                        if( $oimage->isDeleted( File::DELETED_RESTRICTED ) ) {
                                $this->getOutput()->permissionRequired( 'suppressrevision' );
                        } else {
@@ -284,21 +285,22 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        }
                        return;
                }
-               if ( !$this->getUser()->matchEditToken( $this->token, $archiveName ) ) {
+               if ( !$user->matchEditToken( $this->token, $archiveName ) ) {
+                       $lang = $this->getLanguage();
                        $this->getOutput()->addWikiMsg( 'revdelete-show-file-confirm',
                                $this->targetObj->getText(),
-                               $this->getLanguage()->date( $oimage->getTimestamp() ),
-                               $this->getLanguage()->time( $oimage->getTimestamp() ) );
+                               $lang->userDate( $oimage->getTimestamp(), $user ),
+                               $lang->userTime( $oimage->getTimestamp(), $user ) );
                        $this->getOutput()->addHTML(
                                Xml::openElement( 'form', array(
                                        'method' => 'POST',
                                        'action' => $this->getTitle()->getLocalUrl(
                                                'target=' . urlencode( $oimage->getName() ) .
                                                '&file=' . urlencode( $archiveName ) .
-                                               '&token=' . urlencode( $this->getUser()->getEditToken( $archiveName ) ) )
+                                               '&token=' . urlencode( $user->getEditToken( $archiveName ) ) )
                                        )
                                ) .
-                               Xml::submitButton( wfMsg( 'revdelete-show-file-submit' ) ) .
+                               Xml::submitButton( $this->msg( 'revdelete-show-file-submit' )->text() ) .
                                '</form>'
                        );
                        return;
@@ -377,22 +379,23 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        $out = Xml::openElement( 'form', array( 'method' => 'post',
                                        'action' => $this->getTitle()->getLocalUrl( array( 'action' => 'submit' ) ),
                                        'id' => 'mw-revdel-form-revisions' ) ) .
-                               Xml::fieldset( wfMsg( 'revdelete-legend' ) ) .
+                               Xml::fieldset( $this->msg( 'revdelete-legend' )->text() ) .
                                $this->buildCheckBoxes() .
                                Xml::openElement( 'table' ) .
                                "<tr>\n" .
                                        '<td class="mw-label">' .
-                                               Xml::label( wfMsg( 'revdelete-log' ), 'wpRevDeleteReasonList' ) .
+                                               Xml::label( $this->msg( 'revdelete-log' )->text(), 'wpRevDeleteReasonList' ) .
                                        '</td>' .
                                        '<td class="mw-input">' .
                                                Xml::listDropDown( 'wpRevDeleteReasonList',
-                                                       wfMsgForContent( 'revdelete-reason-dropdown' ),
-                                                       wfMsgForContent( 'revdelete-reasonotherlist' ), '', 'wpReasonDropDown', 1
+                                                       $this->msg( 'revdelete-reason-dropdown' )->inContentLanguage()->text(),
+                                                       $this->msg( 'revdelete-reasonotherlist' )->inContentLanguage()->text(),
+                                                       '', 'wpReasonDropDown', 1
                                                ) .
                                        '</td>' .
                                "</tr><tr>\n" .
                                        '<td class="mw-label">' .
-                                               Xml::label( wfMsg( 'revdelete-otherreason' ), 'wpReason' ) .
+                                               Xml::label( $this->msg( 'revdelete-otherreason' )->text(), 'wpReason' ) .
                                        '</td>' .
                                        '<td class="mw-input">' .
                                                Xml::input( 'wpReason', 60, $this->otherReason, array( 'id' => 'wpReason', 'maxlength' => 100 ) ) .
@@ -400,7 +403,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                "</tr><tr>\n" .
                                        '<td></td>' .
                                        '<td class="mw-submit">' .
-                                               Xml::submitButton( wfMsgExt('revdelete-submit','parsemag',$numRevisions),
+                                               Xml::submitButton( $this->msg( 'revdelete-submit', $numRevisions )->text(),
                                                        array( 'name' => 'wpSubmit' ) ) .
                                        '</td>' .
                                "</tr>\n" .
@@ -420,7 +423,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                $title = Title::makeTitle( NS_MEDIAWIKI, 'revdelete-reason-dropdown' );
                                $link = Linker::link(
                                        $title,
-                                       wfMsgHtml( 'revdelete-edit-reasonlist' ),
+                                       $this->msg( 'revdelete-edit-reasonlist' )->escaped(),
                                        array(),
                                        array( 'action' => 'edit' )
                                );
@@ -459,7 +462,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                        }
                        foreach( $this->checks as $item ) {
                                list( $message, $name, $field ) = $item;
-                               $innerHTML = Xml::checkLabel( wfMsg($message), $name, $name, $bitfield & $field );
+                               $innerHTML = Xml::checkLabel( $this->msg( $message )->text(), $name, $name, $bitfield & $field );
                                if( $field == Revision::DELETED_RESTRICTED )
                                        $innerHTML = "<b>$innerHTML</b>";
                                $line = Xml::tags( 'td', array( 'class' => 'mw-input' ), $innerHTML );
@@ -468,9 +471,9 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                // Otherwise, use tri-state radios
                } else {
                        $html .= '<tr>';
-                       $html .= '<th class="mw-revdel-checkbox">'.wfMsgHtml('revdelete-radio-same').'</th>';
-                       $html .= '<th class="mw-revdel-checkbox">'.wfMsgHtml('revdelete-radio-unset').'</th>';
-                       $html .= '<th class="mw-revdel-checkbox">'.wfMsgHtml('revdelete-radio-set').'</th>';
+                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-same' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-unset' )->escaped() . '</th>';
+                       $html .= '<th class="mw-revdel-checkbox">' . $this->msg( 'revdelete-radio-set' )->escaped() . '</th>';
                        $html .= "<th></th></tr>\n";
                        foreach( $this->checks as $item ) {
                                list( $message, $name, $field ) = $item;
@@ -483,7 +486,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                                $line = '<td class="mw-revdel-checkbox">' . Xml::radio( $name, -1, $selected == -1 ) . '</td>';
                                $line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 0, $selected == 0 ) . '</td>';
                                $line .= '<td class="mw-revdel-checkbox">' . Xml::radio( $name, 1, $selected == 1 ) . '</td>';
-                               $label = wfMsgHtml($message);
+                               $label = $this->msg( $message )->escaped();
                                if( $field == Revision::DELETED_RESTRICTED ) {
                                        $label = "<b>$label</b>";
                                }
@@ -512,7 +515,7 @@ class SpecialRevisionDelete extends UnlistedSpecialPage {
                $comment = $listReason;
                if( $comment != 'other' && $this->otherReason != '' ) {
                        // Entry from drop down menu + additional comment
-                       $comment .= wfMsgForContent( 'colon-separator' ) . $this->otherReason;
+                       $comment .= $this->msg( 'colon-separator' )->inContentLanguage()->text() . $this->otherReason;
                } elseif( $comment == 'other' ) {
                        $comment = $this->otherReason;
                }