merged master
[lhc/web/wiklou.git] / includes / specials / SpecialUndelete.php
index 542ecff..f242b42 100644 (file)
@@ -341,11 +341,14 @@ class PageArchive {
         * @param $comment String
         * @param $fileVersions Array
         * @param $unsuppress Boolean
+        * @param $user User doing the action, or null to use $wgUser
         *
         * @return array(number of file revisions restored, number of image revisions restored, log message)
         * on success, false on failure
         */
-       function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false ) {
+       function undelete( $timestamps, $comment = '', $fileVersions = array(), $unsuppress = false, User $user = null ) {
+               global $wgContLang, $wgUser;
+
                // If both the set of text revisions and file revisions are empty,
                // restore everything. Otherwise, just restore the requested items.
                $restoreAll = empty( $timestamps ) && empty( $fileVersions );
@@ -374,8 +377,6 @@ class PageArchive {
                }
 
                // Touch the log!
-               global $wgContLang;
-               $log = new LogPage( 'delete' );
 
                if( $textRestored && $filesRestored ) {
                        $reason = wfMsgExt( 'undeletedrevisions-files', array( 'content', 'parsemag' ),
@@ -395,7 +396,17 @@ class PageArchive {
                if( trim( $comment ) != '' ) {
                        $reason .= wfMsgForContent( 'colon-separator' ) . $comment;
                }
-               $log->addEntry( 'restore', $this->title, $reason );
+
+               if ( $user === null ) {
+                       $user = $wgUser;
+               }
+
+               $logEntry = new ManualLogEntry( 'delete', 'restore' );
+               $logEntry->setPerformer( $user );
+               $logEntry->setTarget( $this->title );
+               $logEntry->setComment( $reason );
+               $logid = $logEntry->insert();
+               $logEntry->publish( $logid );
 
                return array( $textRestored, $filesRestored, $reason );
        }
@@ -783,8 +794,8 @@ class SpecialUndelete extends SpecialPage {
                                );
                        } else {
                                // The title is no longer valid, show as text
-                               $title = Title::makeTitle( $row->ar_namespace, $row->ar_title );
-                               $item = htmlspecialchars( $title->getPrefixedText() );
+                               $item = Html::element( 'span', array( 'class' => 'mw-invalidtitle' ),
+                                       Linker::getInvalidTitleDescription( $this->getContext(), $row->ar_namespace, $row->ar_title ) );
                        }
                        $revs = $this->msg( 'undeleterevisions' )->numParams( $row->count )->parse();
                        $out->addHTML( "<li>{$item} ({$revs})</li>\n" );
@@ -941,7 +952,8 @@ class SpecialUndelete extends SpecialPage {
                                "</td>\n" .
                        "</tr>" .
                        $diffEngine->generateContentDiffBody(
-                               $previousRev->getContent(), $currentRev->getContent() ) .
+                               $previousRev->getContent( Revision::FOR_THIS_USER, $this->getUser() ),
+                               $currentRev->getContent( Revision::FOR_THIS_USER, $this->getUser() ) ) .
                        "</table>" .
                        "</div>\n"
                );
@@ -1418,7 +1430,9 @@ class SpecialUndelete extends SpecialPage {
                        $this->mTargetTimestamp,
                        $this->mComment,
                        $this->mFileVersions,
-                       $this->mUnsuppress );
+                       $this->mUnsuppress,
+                       $this->getUser()
+               );
 
                if( is_array( $ok ) ) {
                        if ( $ok[1] ) { // Undeleted file count