disallow embedded line breaks in ISBNs; allowing them breaks things in a most interes...
[lhc/web/wiklou.git] / includes / SpecialUndelete.php
index 26eb15a..f152f64 100644 (file)
@@ -139,7 +139,9 @@ class PageArchive {
                        return new Revision( array(
                                'page'       => $this->title->getArticleId(),
                                'id'         => $row->ar_rev_id,
-                               'text'       => ($row->ar_text_id ? null : $row->ar_text),
+                               'text'       => ($row->ar_text_id
+                                       ? null
+                                       : Revision::getRevisionText( $row, 'ar_' ) ),
                                'comment'    => $row->ar_comment,
                                'user'       => $row->ar_user,
                                'user_text'  => $row->ar_user_text,
@@ -276,12 +278,12 @@ class PageArchive {
         * @return int number of revisions restored
         */
        private function undeleteRevisions( $timestamps ) {
-               global $wgParser, $wgDBtype;
+               global $wgDBtype;
 
                $restoreAll = empty( $timestamps );
                
                $dbw =& wfGetDB( DB_MASTER );
-               extract( $dbw->tableNames( 'page', 'archive' ) );
+               $page = $dbw->tableName( 'archive' );
 
                # Does this page already exist? We'll have to update it...
                $article = new Article( $this->title );
@@ -346,7 +348,6 @@ class PageArchive {
                }
                
                $revision = null;
-               $newRevId = $previousRevId;
                $restored = 0;
 
                while( $row = $dbw->fetchObject( $result ) ) {
@@ -373,7 +374,7 @@ class PageArchive {
                                'minor_edit' => $row->ar_minor_edit,
                                'text_id'    => $row->ar_text_id,
                                ) );
-                       $newRevId = $revision->insertOn( $dbw );
+                       $revision->insertOn( $dbw );
                        $restored++;
                }
 
@@ -451,6 +452,7 @@ class UndeleteForm {
                        $timestamps = array();
                        $this->mFileVersions = array();
                        foreach( $_REQUEST as $key => $val ) {
+                               $matches = array();
                                if( preg_match( '/^ts(\d{14})$/', $key, $matches ) ) {
                                        array_push( $timestamps, $matches[1] );
                                }
@@ -482,7 +484,7 @@ class UndeleteForm {
        }
 
        /* private */ function showList() {
-               global $wgLang, $wgContLang, $wgOut;
+               global $wgLang, $wgContLang, $wgUser, $wgOut;
 
                # List undeletable articles
                $result = PageArchive::listAllPages();
@@ -494,11 +496,12 @@ class UndeleteForm {
                }
                $wgOut->addWikiText( wfMsg( "undeletepagetext" ) );
 
-               $undelete =& SpecialPage::getTitleFor( 'Undelete' );
+               $sk = $wgUser->getSkin();
+               $undelete = SpecialPage::getTitleFor( 'Undelete' );
                $wgOut->addHTML( "<ul>\n" );
                while( $row = $result->fetchObject() ) {
                        $title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
-                       $link = Linker::makeKnownLinkObj( $undelete, htmlspecialchars( $title->getPrefixedText() ), 'target=' . $title->getPrefixedUrl() );
+                       $link = $sk->makeKnownLinkObj( $undelete, htmlspecialchars( $title->getPrefixedText() ), 'target=' . $title->getPrefixedUrl() );
                        $revs = wfMsgHtml( 'undeleterevisions', $wgLang->formatNum( $row->count ) );
                        $wgOut->addHtml( "<li>{$link} ({$revs})</li>\n" );
                }
@@ -529,7 +532,8 @@ class UndeleteForm {
                
                if( $this->mPreview ) {
                        $wgOut->addHtml( "<hr />\n" );
-                       $wgOut->addWikiText( $rev->getText() );
+                       $article = new Article ( $archive->title );  # OutputPage wants an Article obj
+                       $wgOut->addPrimaryWikiText( $rev->getText(), $article, false );
                }
                
                $self = SpecialPage::getTitleFor( "Undelete" );
@@ -581,6 +585,7 @@ class UndeleteForm {
        /* private */ function showHistory() {
                global $wgLang, $wgUser, $wgOut;
 
+               $sk = $wgUser->getSkin();
                if ( $this->mAllowed ) {
                        $wgOut->setPagetitle( wfMsg( "undeletepage" ) );
                } else {
@@ -588,8 +593,8 @@ class UndeleteForm {
                }
 
                $archive = new PageArchive( $this->mTargetObj );
-               $text = $archive->getLastRevisionText();
                /*
+               $text = $archive->getLastRevisionText();
                if( is_null( $text ) ) {
                        $wgOut->addWikiText( wfMsg( "nohistory" ) );
                        return;
@@ -669,15 +674,15 @@ class UndeleteForm {
                                $ts = wfTimestamp( TS_MW, $row->ar_timestamp );
                                if ( $this->mAllowed ) {
                                        $checkBox = wfCheck( "ts$ts" );
-                                       $pageLink = Linker::makeKnownLinkObj( $titleObj,
+                                       $pageLink = $sk->makeKnownLinkObj( $titleObj,
                                                $wgLang->timeanddate( $ts, true ),
                                                "target=$target&timestamp=$ts" );
                                } else {
                                        $checkBox = '';
                                        $pageLink = $wgLang->timeanddate( $ts, true );
                                }
-                               $userLink = Linker::userLink( $row->ar_user, $row->ar_user_text ) . Linker::userToolLinks( $row->ar_user, $row->ar_user_text );
-                               $comment = Linker::commentBlock( $row->ar_comment );
+                               $userLink = $sk->userLink( $row->ar_user, $row->ar_user_text ) . $sk->userToolLinks( $row->ar_user, $row->ar_user_text );
+                               $comment = $sk->commentBlock( $row->ar_comment );
                                $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $comment</li>\n" );
        
                        }
@@ -697,14 +702,14 @@ class UndeleteForm {
                                        $checkBox = wfCheck( "fileid" . $row->fa_id );
                                        $key = urlencode( $row->fa_storage_key );
                                        $target = urlencode( $this->mTarget );
-                                       $pageLink = Linker::makeKnownLinkObj( $titleObj,
+                                       $pageLink = $sk->makeKnownLinkObj( $titleObj,
                                                $wgLang->timeanddate( $ts, true ),
                                                "target=$target&file=$key" );
                                } else {
                                        $checkBox = '';
                                        $pageLink = $wgLang->timeanddate( $ts, true );
                                }
-                               $userLink = Linker::userLink( $row->fa_user, $row->fa_user_text ) . Linker::userToolLinks( $row->fa_user, $row->fa_user_text );
+                               $userLink = $sk->userLink( $row->fa_user, $row->fa_user_text ) . $sk->userToolLinks( $row->fa_user, $row->fa_user_text );
                                $data =
                                        wfMsgHtml( 'widthheight',
                                                $wgLang->formatNum( $row->fa_width ),
@@ -712,7 +717,7 @@ class UndeleteForm {
                                        ' (' .
                                        wfMsgHtml( 'nbytes', $wgLang->formatNum( $row->fa_size ) ) .
                                        ')';
-                               $comment = Linker::commentBlock( $row->fa_description );
+                               $comment = $sk->commentBlock( $row->fa_description );
                                $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $data $comment</li>\n" );
                        }
                        $files->free();
@@ -730,10 +735,9 @@ class UndeleteForm {
        }
 
        function undelete() {
-               global $wgOut;
+               global $wgOut, $wgUser;
                if( !is_null( $this->mTargetObj ) ) {
                        $archive = new PageArchive( $this->mTargetObj );
-                       $ok = true;
                        
                        $ok = $archive->undelete(
                                $this->mTargetTimestamp,
@@ -741,7 +745,8 @@ class UndeleteForm {
                                $this->mFileVersions );
                        
                        if( $ok ) {
-                               $link = Linker::makeKnownLinkObj( $this->mTargetObj );
+                               $skin =& $wgUser->getSkin();
+                               $link = $skin->makeKnownLinkObj( $this->mTargetObj );
                                $wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );
                                return true;
                        }