merged master after 1.20wmf3
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index 1163a96..e7c0ee0 100644 (file)
@@ -97,8 +97,8 @@ class PageArchive {
                                $condition,
                                __METHOD__,
                                array(
-                                       'GROUP BY' => 'ar_namespace,ar_title',
-                                       'ORDER BY' => 'ar_namespace,ar_title',
+                                       'GROUP BY' => array( 'ar_namespace', 'ar_title' ),
+                                       'ORDER BY' => array( 'ar_namespace', 'ar_title' ),
                                        'LIMIT' => 100,
                                )
                        )
@@ -112,12 +112,22 @@ class PageArchive {
         * @return ResultWrapper
         */
        function listRevisions() {
+               global $wgContentHandlerNoDB;
+
                $dbr = wfGetDB( DB_SLAVE );
+
+               $fields = array(
+                       'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text',
+                       'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1',
+               );
+
+               if ( !$wgContentHandlerNoDB ) {
+                       $fields[] = 'ar_content_format';
+                       $fields[] = 'ar_content_model';
+               }
+
                $res = $dbr->select( 'archive',
-                       array(
-                               'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text',
-                               'ar_comment', 'ar_len', 'ar_deleted', 'ar_rev_id', 'ar_sha1'
-                       ),
+                       $fields,
                        array( 'ar_namespace' => $this->title->getNamespace(),
                                   'ar_title' => $this->title->getDBkey() ),
                        'PageArchive::listRevisions',
@@ -174,26 +184,38 @@ class PageArchive {
         * @return Revision
         */
        function getRevision( $timestamp ) {
+               global $wgContentHandlerNoDB;
+
                $dbr = wfGetDB( DB_SLAVE );
+
+               $fields = array(
+                       'ar_rev_id',
+                       'ar_text',
+                       'ar_comment',
+                       'ar_user',
+                       'ar_user_text',
+                       'ar_timestamp',
+                       'ar_minor_edit',
+                       'ar_flags',
+                       'ar_text_id',
+                       'ar_deleted',
+                       'ar_len',
+                       'ar_sha1',
+               );
+
+               if ( !$wgContentHandlerNoDB ) {
+                       $fields[] = 'ar_content_format';
+                       $fields[] = 'ar_content_model';
+               }
+
                $row = $dbr->selectRow( 'archive',
-                       array(
-                               'ar_rev_id',
-                               'ar_text',
-                               'ar_comment',
-                               'ar_user',
-                               'ar_user_text',
-                               'ar_timestamp',
-                               'ar_minor_edit',
-                               'ar_flags',
-                               'ar_text_id',
-                               'ar_deleted',
-                               'ar_len' ),
+                       $fields,
                        array( 'ar_namespace' => $this->title->getNamespace(),
-                                  'ar_title' => $this->title->getDBkey(),
-                                  'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
+                                       'ar_title' => $this->title->getDBkey(),
+                                       'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
                        __METHOD__ );
                if( $row ) {
-                       return Revision::newFromArchiveRow( $row, array( 'page' => $this->title->getArticleId() ) );
+                       return Revision::newFromArchiveRow( $row, array( 'page' => $this->title->getArticleID() ) );
                } else {
                        return null;
                }
@@ -390,6 +412,8 @@ class PageArchive {
         * @return Mixed: number of revisions restored or false on failure
         */
        private function undeleteRevisions( $timestamps, $unsuppress = false, $comment = '' ) {
+               global $wgContentHandlerNoDB;
+
                if ( wfReadOnly() ) {
                        return false;
                }
@@ -403,13 +427,12 @@ class PageArchive {
                $article->loadPageData( 'fromdbmaster' );
                $oldcountable = $article->isCountable();
 
-               $options = 'FOR UPDATE'; // lock page
                $page = $dbw->selectRow( 'page',
                        array( 'page_id', 'page_latest' ),
                        array( 'page_namespace' => $this->title->getNamespace(),
                                   'page_title'     => $this->title->getDBkey() ),
                        __METHOD__,
-                       $options
+                       array( 'FOR UPDATE' ) // lock page
                );
                if( $page ) {
                        $makepage = false;
@@ -444,24 +467,31 @@ class PageArchive {
                        $oldones = "ar_timestamp IN ( {$oldts} )";
                }
 
+               $fields = array(
+                       'ar_rev_id',
+                       'ar_text',
+                       'ar_comment',
+                       'ar_user',
+                       'ar_user_text',
+                       'ar_timestamp',
+                       'ar_minor_edit',
+                       'ar_flags',
+                       'ar_text_id',
+                       'ar_deleted',
+                       'ar_page_id',
+                       'ar_len',
+                       'ar_sha1');
+
+               if ( !$wgContentHandlerNoDB ) {
+                       $fields[] = 'ar_content_format';
+                       $fields[] = 'ar_content_model';
+               }
+
                /**
                 * Select each archived revision...
                 */
                $result = $dbw->select( 'archive',
-                       /* fields */ array(
-                               'ar_rev_id',
-                               'ar_text',
-                               'ar_comment',
-                               'ar_user',
-                               'ar_user_text',
-                               'ar_timestamp',
-                               'ar_minor_edit',
-                               'ar_flags',
-                               'ar_text_id',
-                               'ar_deleted',
-                               'ar_page_id',
-                               'ar_len',
-                               'ar_sha1' ),
+                       $fields,
                        /* WHERE */ array(
                                'ar_namespace' => $this->title->getNamespace(),
                                'ar_title'     => $this->title->getDBkey(),
@@ -606,6 +636,7 @@ class SpecialUndelete extends SpecialPage {
                $this->mInvert = $request->getCheck( 'invert' ) && $posted;
                $this->mPreview = $request->getCheck( 'preview' ) && $posted;
                $this->mDiff = $request->getCheck( 'diff' );
+               $this->mDiffOnly = $request->getBool( 'diffonly', $this->getUser()->getOption( 'diffonly' ) );
                $this->mComment = $request->getText( 'wpComment' );
                $this->mUnsuppress = $request->getVal( 'wpUnsuppress' ) && $user->isAllowed( 'suppressrevision' );
                $this->mToken = $request->getVal( 'token' );
@@ -655,7 +686,7 @@ class SpecialUndelete extends SpecialPage {
 
                if ( is_null( $this->mTargetObj ) ) {
                        $out->addWikiMsg( 'undelete-header' );
-       
+
                        # Not all users can just browse every deleted page from the list
                        if ( $user->isAllowed( 'browsearchive' ) ) {
                                $this->showSearchForm();
@@ -705,13 +736,13 @@ class SpecialUndelete extends SpecialPage {
                        Xml::openElement( 'form', array(
                                'method' => 'get',
                                'action' => $wgScript ) ) .
-                       Xml::fieldset( wfMsg( 'undelete-search-box' ) ) .
+                       Xml::fieldset( $this->msg( 'undelete-search-box' )->text() ) .
                        Html::hidden( 'title',
                                $this->getTitle()->getPrefixedDbKey() ) .
-                       Xml::inputLabel( wfMsg( 'undelete-search-prefix' ),
+                       Xml::inputLabel( $this->msg( 'undelete-search-prefix' )->text(),
                                'prefix', 'prefix', 20,
                                $this->mSearchPrefix ) . ' ' .
-                       Xml::submitButton( wfMsg( 'undelete-search-submit' ) ) .
+                       Xml::submitButton( $this->msg( 'undelete-search-submit' )->text() ) .
                        Xml::closeElement( 'fieldset' ) .
                        Xml::closeElement( 'form' )
                );
@@ -737,22 +768,26 @@ class SpecialUndelete extends SpecialPage {
                        return;
                }
 
-               $out->addWikiMsg( 'undeletepagetext', $this->getLang()->formatNum( $result->numRows() ) );
+               $out->addWikiMsg( 'undeletepagetext', $this->getLanguage()->formatNum( $result->numRows() ) );
 
                $undelete = $this->getTitle();
                $out->addHTML( "<ul>\n" );
                foreach ( $result as $row ) {
                        $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
-                       $link = Linker::linkKnown(
-                               $undelete,
-                               htmlspecialchars( $title->getPrefixedText() ),
-                               array(),
-                               array( 'target' => $title->getPrefixedText() )
-                       );
-                       $revs = wfMsgExt( 'undeleterevisions',
-                               array( 'parseinline' ),
-                               $this->getLang()->formatNum( $row->count ) );
-                       $out->addHTML( "<li>{$link} ({$revs})</li>\n" );
+                       if ( $title !== null ) {
+                               $item = Linker::linkKnown(
+                                       $undelete,
+                                       htmlspecialchars( $title->getPrefixedText() ),
+                                       array(),
+                                       array( 'target' => $title->getPrefixedText() )
+                               );
+                       } else {
+                               // The title is no longer valid, show as text
+                               $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
+                               $item = htmlspecialchars( $title->getPrefixedText() );
+                       }
+                       $revs = $this->msg( 'undeleterevisions' )->numParams( $row->count )->parse();
+                       $out->addHTML( "<li>{$item} ({$revs})</li>\n" );
                }
                $result->free();
                $out->addHTML( "</ul>\n" );
@@ -792,7 +827,7 @@ class SpecialUndelete extends SpecialPage {
                        $previousRev = $archive->getPreviousRevision( $timestamp );
                        if( $previousRev ) {
                                $this->showDiff( $previousRev, $rev );
-                               if( $user->getOption( 'diffonly' ) ) {
+                               if( $this->mDiffOnly ) {
                                        return;
                                } else {
                                        $out->addHTML( '<hr />' );
@@ -807,11 +842,13 @@ class SpecialUndelete extends SpecialPage {
                        htmlspecialchars( $this->mTargetObj->getPrefixedText() )
                );
 
+               $lang = $this->getLanguage();
+
                // date and time are separate parameters to facilitate localisation.
                // $time is kept for backward compat reasons.
-               $time = $this->getLang()->timeAndDate( $timestamp, true );
-               $d = $this->getLang()->date( $timestamp, true );
-               $t = $this->getLang()->time( $timestamp, true );
+               $time = $lang->userTimeAndDate( $timestamp, $user );
+               $d = $lang->userDate( $timestamp, $user );
+               $t = $lang->userTime( $timestamp, $user );
                $userLink = Linker::revUserTools( $rev );
 
                if( $this->mPreview ) {
@@ -829,7 +866,7 @@ class SpecialUndelete extends SpecialPage {
                        }
                }
 
-               $out->addHTML( wfMessage( 'undelete-revision' )->rawParams( $link )->params(
+               $out->addHTML( $this->msg( 'undelete-revision' )->rawParams( $link )->params(
                        $time )->rawParams( $userLink )->params( $d, $t )->parse() . '</div>' );
                wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) );
 
@@ -866,11 +903,11 @@ class SpecialUndelete extends SpecialPage {
                        Xml::element( 'input', array(
                                'type' => 'submit',
                                'name' => 'preview',
-                               'value' => wfMsg( 'showpreview' ) ) ) .
+                               'value' => $this->msg( 'showpreview' )->text() ) ) .
                        Xml::element( 'input', array(
                                'name' => 'diff',
                                'type' => 'submit',
-                               'value' => wfMsg( 'showdiff' ) ) ) .
+                               'value' => $this->msg( 'showdiff' )->text() ) ) .
                        Xml::closeElement( 'form' ) .
                        Xml::closeElement( 'div' ) );
        }
@@ -884,7 +921,8 @@ class SpecialUndelete extends SpecialPage {
         * @return String: HTML
         */
        function showDiff( $previousRev, $currentRev ) {
-               $diffEngine = new DifferenceEngine( $this->getContext() );
+               $contentHandler = ContentHandler::getForTitle( $this->getTitle() );
+               $diffEngine = $contentHandler->createDifferenceEngine( $this->getContext() );
                $diffEngine->showDiffStyle();
                $this->getOutput()->addHTML(
                        "<div>" .
@@ -901,8 +939,8 @@ class SpecialUndelete extends SpecialPage {
                                $this->diffHeader( $currentRev, 'n' ) .
                                "</td>\n" .
                        "</tr>" .
-                       $diffEngine->generateDiffBody(
-                               $previousRev->getText(), $currentRev->getText() ) .
+                       $diffEngine->generateContentDiffBody(
+                               $previousRev->getContent(), $currentRev->getContent() ) .
                        "</table>" .
                        "</div>\n"
                );
@@ -928,19 +966,20 @@ class SpecialUndelete extends SpecialPage {
                        $targetQuery = array( 'oldid' => $rev->getId() );
                }
                // Add show/hide deletion links if available
-               $rdel = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj );
+               $user = $this->getUser();
+               $lang = $this->getLanguage();
+               $rdel = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj );
                if ( $rdel ) $rdel = " $rdel";
                return
                        '<div id="mw-diff-' . $prefix . 'title1"><strong>' .
                                Linker::link(
                                        $targetPage,
-                                       wfMsgExt(
+                                       $this->msg(
                                                'revisionasof',
-                                               array( 'escape' ),
-                                               $this->getLang()->timeanddate( $rev->getTimestamp(), true ),
-                                               $this->getLang()->date( $rev->getTimestamp(), true ),
-                                               $this->getLang()->time( $rev->getTimestamp(), true )
-                                       ),
+                                               $lang->userTimeAndDate( $rev->getTimestamp(), $user ),
+                                               $lang->userDate( $rev->getTimestamp(), $user ),
+                                               $lang->userTime( $rev->getTimestamp(), $user )
+                                       )->escaped(),
                                        array(),
                                        $targetQuery
                                ) .
@@ -957,21 +996,24 @@ class SpecialUndelete extends SpecialPage {
         * Show a form confirming whether a tokenless user really wants to see a file
         */
        private function showFileConfirmationForm( $key ) {
+               $out = $this->getOutput();
+               $lang = $this->getLanguage();
+               $user = $this->getUser();
                $file = new ArchivedFile( $this->mTargetObj, '', $this->mFilename );
-               $this->getOutput()->addWikiMsg( 'undelete-show-file-confirm',
+               $out->addWikiMsg( 'undelete-show-file-confirm',
                        $this->mTargetObj->getText(),
-                       $this->getLang()->date( $file->getTimestamp() ),
-                       $this->getLang()->time( $file->getTimestamp() ) );
-               $this->getOutput()->addHTML(
+                       $lang->userDate( $file->getTimestamp(), $user ),
+                       $lang->userTime( $file->getTimestamp(), $user ) );
+               $out->addHTML(
                        Xml::openElement( 'form', array(
                                'method' => 'POST',
                                'action' => $this->getTitle()->getLocalURL(
                                        'target=' . urlencode( $this->mTarget ) .
                                        '&file=' . urlencode( $key ) .
-                                       '&token=' . urlencode( $this->getUser()->getEditToken( $key ) ) )
+                                       '&token=' . urlencode( $user->getEditToken( $key ) ) )
                                )
                        ) .
-                       Xml::submitButton( wfMsg( 'undelete-show-file-submit' ) ) .
+                       Xml::submitButton( $this->msg( 'undelete-show-file-submit' )->text() ) .
                        '</form>'
                );
        }
@@ -993,7 +1035,7 @@ class SpecialUndelete extends SpecialPage {
 
                $repo = RepoGroup::singleton()->getLocalRepo();
                $path = $repo->getZonePath( 'deleted' ) . '/' . $repo->getDeletedHashPath( $key ) . $key;
-               StreamFile::stream( $path );
+               $repo->streamFile( $path );
        }
 
        private function showHistory() {
@@ -1003,7 +1045,7 @@ class SpecialUndelete extends SpecialPage {
                }
                $out->wrapWikiMsg(
                        "<div class='mw-undelete-pagetitle'>\n$1\n</div>\n",
-                       array( 'undeletepagetitle', $this->mTargetObj->getPrefixedText() )
+                       array( 'undeletepagetitle', wfEscapeWikiText( $this->mTargetObj->getPrefixedText() ) )
                );
 
                $archive = new PageArchive( $this->mTargetObj );
@@ -1075,24 +1117,24 @@ class SpecialUndelete extends SpecialPage {
                                        "<tr>
                                                <td>&#160;</td>
                                                <td class='mw-input'>" .
-                                                       Xml::checkLabel( wfMsg( 'revdelete-unsuppress' ), 'wpUnsuppress',
-                                                               'mw-undelete-unsuppress', $this->mUnsuppress ).
+                                                       Xml::checkLabel( $this->msg( 'revdelete-unsuppress' )->text(),
+                                                               'wpUnsuppress', 'mw-undelete-unsuppress', $this->mUnsuppress ).
                                                "</td>
                                        </tr>";
                        } else {
                                $unsuppressBox = '';
                        }
                        $table =
-                               Xml::fieldset( wfMsg( 'undelete-fieldset-title' ) ) .
+                               Xml::fieldset( $this->msg( 'undelete-fieldset-title' )->text() ) .
                                Xml::openElement( 'table', array( 'id' => 'mw-undelete-table' ) ) .
                                        "<tr>
                                                <td colspan='2' class='mw-undelete-extrahelp'>" .
-                                                       wfMsgExt( 'undeleteextrahelp', 'parse' ) .
+                                                       $this->msg( 'undeleteextrahelp' )->parseAsBlock() .
                                                "</td>
                                        </tr>
                                        <tr>
                                                <td class='mw-label'>" .
-                                                       Xml::label( wfMsg( 'undeletecomment' ), 'wpComment' ) .
+                                                       Xml::label( $this->msg( 'undeletecomment' )->text(), 'wpComment' ) .
                                                "</td>
                                                <td class='mw-input'>" .
                                                        Xml::input( 'wpComment', 50, $this->mComment, array( 'id' =>  'wpComment' ) ) .
@@ -1101,8 +1143,8 @@ class SpecialUndelete extends SpecialPage {
                                        <tr>
                                                <td>&#160;</td>
                                                <td class='mw-submit'>" .
-                                                       Xml::submitButton( wfMsg( 'undeletebtn' ), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) . ' ' .
-                                                       Xml::submitButton( wfMsg( 'undeleteinvert' ), array( 'name' => 'invert', 'id' => 'mw-undelete-invert' ) ) .
+                                                       Xml::submitButton( $this->msg( 'undeletebtn' )->text(), array( 'name' => 'restore', 'id' => 'mw-undelete-submit' ) ) . ' ' .
+                                                       Xml::submitButton( $this->msg( 'undeleteinvert' )->text(), array( 'name' => 'invert', 'id' => 'mw-undelete-invert' ) ) .
                                                "</td>
                                        </tr>" .
                                        $unsuppressBox .
@@ -1112,7 +1154,7 @@ class SpecialUndelete extends SpecialPage {
                        $out->addHTML( $table );
                }
 
-               $out->addHTML( Xml::element( 'h2', null, wfMsg( 'history' ) ) . "\n" );
+               $out->addHTML( Xml::element( 'h2', null, $this->msg( 'history' )->text() ) . "\n" );
 
                if( $haveRevisions ) {
                        # The page's stored (deleted) history:
@@ -1131,7 +1173,7 @@ class SpecialUndelete extends SpecialPage {
                }
 
                if( $haveFiles ) {
-                       $out->addHTML( Xml::element( 'h2', null, wfMsg( 'filehist' ) ) . "\n" );
+                       $out->addHTML( Xml::element( 'h2', null, $this->msg( 'filehist' )->text() ) . "\n" );
                        $out->addHTML( '<ul>' );
                        foreach ( $files as $row ) {
                                $out->addHTML( $this->formatFileRow( $row ) );
@@ -1153,7 +1195,7 @@ class SpecialUndelete extends SpecialPage {
 
        private function formatRevisionRow( $row, $earliestLiveTime, $remaining ) {
                $rev = Revision::newFromArchiveRow( $row,
-                       array( 'page' => $this->mTargetObj->getArticleId() ) );
+                       array( 'page' => $this->mTargetObj->getArticleID() ) );
                $stxt = '';
                $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
                // Build checkboxen...
@@ -1170,18 +1212,19 @@ class SpecialUndelete extends SpecialPage {
                } else {
                        $checkBox = '';
                }
+               $user = $this->getUser();
                // Build page & diff links...
                if( $this->mCanView ) {
                        $titleObj = $this->getTitle();
                        # Last link
                        if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
-                               $pageLink = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) );
-                               $last = wfMsgHtml( 'diff' );
+                               $pageLink = htmlspecialchars( $this->getLanguage()->userTimeAndDate( $ts, $user ) );
+                               $last = $this->msg( 'diff' )->escaped();
                        } elseif( $remaining > 0 || ( $earliestLiveTime && $ts > $earliestLiveTime ) ) {
                                $pageLink = $this->getPageLink( $rev, $titleObj, $ts );
                                $last = Linker::linkKnown(
                                        $titleObj,
-                                       wfMsgHtml( 'diff' ),
+                                       $this->msg( 'diff' )->escaped(),
                                        array(),
                                        array(
                                                'target' => $this->mTargetObj->getPrefixedText(),
@@ -1191,11 +1234,11 @@ class SpecialUndelete extends SpecialPage {
                                );
                        } else {
                                $pageLink = $this->getPageLink( $rev, $titleObj, $ts );
-                               $last = wfMsgHtml( 'diff' );
+                               $last = $this->msg( 'diff' )->escaped();
                        }
                } else {
-                       $pageLink = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) );
-                       $last = wfMsgHtml( 'diff' );
+                       $pageLink = htmlspecialchars( $this->getLanguage()->userTimeAndDate( $ts, $user ) );
+                       $last = $this->msg( 'diff' )->escaped();
                }
                // User links
                $userLink = Linker::revUserTools( $rev );
@@ -1207,7 +1250,7 @@ class SpecialUndelete extends SpecialPage {
                // Edit summary
                $comment = Linker::revComment( $rev );
                // Revision delete links
-               $revdlink = Linker::getRevDeleteLink( $this->getUser(), $rev, $this->mTargetObj );
+               $revdlink = Linker::getRevDeleteLink( $user, $rev, $this->mTargetObj );
                return "<li>$checkBox $revdlink ($last) $pageLink . . $userLink $stxt $comment</li>";
        }
 
@@ -1215,27 +1258,22 @@ class SpecialUndelete extends SpecialPage {
                $file = ArchivedFile::newFromRow( $row );
 
                $ts = wfTimestamp( TS_MW, $row->fa_timestamp );
+               $user = $this->getUser();
                if( $this->mAllowed && $row->fa_storage_key ) {
                        $checkBox = Xml::check( 'fileid' . $row->fa_id );
                        $key = urlencode( $row->fa_storage_key );
                        $pageLink = $this->getFileLink( $file, $this->getTitle(), $ts, $key );
                } else {
                        $checkBox = '';
-                       $pageLink = $this->getLang()->timeanddate( $ts, true );
+                       $pageLink = $this->getLanguage()->userTimeAndDate( $ts, $user );
                }
                $userLink = $this->getFileUser( $file );
-               $data =
-                       wfMsg( 'widthheight',
-                               $this->getLang()->formatNum( $row->fa_width ),
-                               $this->getLang()->formatNum( $row->fa_height ) ) .
-                       ' (' .
-                       wfMsg( 'nbytes', $this->getLang()->formatNum( $row->fa_size ) ) .
-                       ')';
-               $data = htmlspecialchars( $data );
+               $data = $this->msg( 'widthheight' )->numParams( $row->fa_width, $row->fa_height )->text();
+               $bytes = $this->msg( 'parentheses' )->rawParams( $this->msg( 'nbytes' )->numParams( $row->fa_size )->text() )->plain();
+               $data = htmlspecialchars( $data . ' ' . $bytes );
                $comment = $this->getFileComment( $file );
 
                // Add show/hide deletion links if available
-               $user = $this->getUser();
                $canHide = $user->isAllowed( 'deleterevision' );
                if( $canHide || ( $file->getVisibility() && $user->isAllowed( 'deletedhistory' ) ) ) {
                        if( !$file->userCan( File::DELETED_RESTRICTED, $user ) ) {
@@ -1260,17 +1298,20 @@ class SpecialUndelete extends SpecialPage {
         * Fetch revision text link if it's available to all users
         *
         * @param $rev Revision
+        * @param $titleObj Title
+        * @param $ts string Timestamp
         * @return string
         */
        function getPageLink( $rev, $titleObj, $ts ) {
-               $time = htmlspecialchars( $this->getLang()->timeanddate( $ts, true ) );
+               $user = $this->getUser();
+               $time = $this->getLanguage()->userTimeAndDate( $ts, $user );
 
-               if( !$rev->userCan( Revision::DELETED_TEXT, $this->getUser() ) ) {
+               if( !$rev->userCan( Revision::DELETED_TEXT, $user ) ) {
                        return '<span class="history-deleted">' . $time . '</span>';
                } else {
                        $link = Linker::linkKnown(
                                $titleObj,
-                               $time,
+                               htmlspecialchars( $time ),
                                array(),
                                array(
                                        'target' => $this->mTargetObj->getPrefixedText(),
@@ -1288,20 +1329,27 @@ class SpecialUndelete extends SpecialPage {
         * Fetch image view link if it's available to all users
         *
         * @param $file File
+        * @param $titleObj Title
+        * @param $ts string A timestamp
+        * @param $key String: a storage key
+        *
         * @return String: HTML fragment
         */
        function getFileLink( $file, $titleObj, $ts, $key ) {
-               if( !$file->userCan( File::DELETED_FILE, $this->getUser() ) ) {
-                       return '<span class="history-deleted">' . $this->getLang()->timeanddate( $ts, true ) . '</span>';
+               $user = $this->getUser();
+               $time = $this->getLanguage()->userTimeAndDate( $ts, $user );
+
+               if( !$file->userCan( File::DELETED_FILE, $user ) ) {
+                       return '<span class="history-deleted">' . $time . '</span>';
                } else {
                        $link = Linker::linkKnown(
                                $titleObj,
-                               $this->getLang()->timeanddate( $ts, true ),
+                               htmlspecialchars( $time ),
                                array(),
                                array(
                                        'target' => $this->mTargetObj->getPrefixedText(),
                                        'file' => $key,
-                                       'token' => $this->getUser()->getEditToken( $key )
+                                       'token' => $user->getEditToken( $key )
                                )
                        );
                        if( $file->isDeleted( File::DELETED_FILE ) ) {
@@ -1319,7 +1367,7 @@ class SpecialUndelete extends SpecialPage {
         */
        function getFileUser( $file ) {
                if( !$file->userCan( File::DELETED_USER, $this->getUser() ) ) {
-                       return '<span class="history-deleted">' . wfMsgHtml( 'rev-deleted-user' ) . '</span>';
+                       return '<span class="history-deleted">' . $this->msg( 'rev-deleted-user' )->escaped() . '</span>';
                } else {
                        $link = Linker::userLink( $file->getRawUser(), $file->getRawUserText() ) .
                                Linker::userToolLinks( $file->getRawUser(), $file->getRawUserText() );
@@ -1339,7 +1387,7 @@ class SpecialUndelete extends SpecialPage {
        function getFileComment( $file ) {
                if( !$file->userCan( File::DELETED_COMMENT, $this->getUser() ) ) {
                        return '<span class="history-deleted"><span class="comment">' .
-                               wfMsgHtml( 'rev-deleted-comment' ) . '</span></span>';
+                               $this->msg( 'rev-deleted-comment' )->escaped() . '</span></span>';
                } else {
                        $link = Linker::commentBlock( $file->getRawDescription() );
                        if( $file->isDeleted( File::DELETED_COMMENT ) ) {
@@ -1387,7 +1435,7 @@ class SpecialUndelete extends SpecialPage {
                // Show file deletion warnings and errors
                $status = $archive->getFileStatus();
                if( $status && !$status->isGood() ) {
-                       $out->addWikiText( $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) );
+                       $out->addWikiText( '<div class="error">' . $status->getWikiText( 'undelete-error-short', 'undelete-error-long' ) . '</div>' );
                }
        }
 }