* Special page allowing users with the appropriate permissions to view
* and restore deleted content
*
- * @package MediaWiki
- * @subpackage Special pages
+ * @addtogroup SpecialPage
*/
/**
- *
+ * Constructor
*/
function wfSpecialUndelete( $par ) {
- global $wgRequest;
+ global $wgRequest;
$form = new UndeleteForm( $wgRequest, $par );
$form->execute();
}
/**
- *
- * @package MediaWiki
- * @subpackage SpecialPage
+ * Used to show archived pages and eventually restore them.
+ * @addtogroup SpecialPage
*/
class PageArchive {
protected $title;
function listRevisions() {
$dbr = wfGetDB( DB_SLAVE );
$res = $dbr->select( 'archive',
- array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment' ),
+ array( 'ar_minor_edit', 'ar_timestamp', 'ar_user', 'ar_user_text', 'ar_comment', 'ar_len' ),
array( 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey() ),
'PageArchive::listRevisions',
* if not a file page.
*
* @return ResultWrapper
- * @fixme Does this belong in Image for fuller encapsulation?
+ * @todo Does this belong in Image for fuller encapsulation?
*/
function listFiles() {
if( $this->title->getNamespace() == NS_IMAGE ) {
'ar_timestamp',
'ar_minor_edit',
'ar_flags',
- 'ar_text_id' ),
+ 'ar_text_id',
+ 'ar_len' ),
array( 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDbkey(),
'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
* @return int number of revisions restored
*/
private function undeleteRevisions( $timestamps ) {
- global $wgDBtype;
-
$restoreAll = empty( $timestamps );
$dbw = wfGetDB( DB_MASTER );
# Does this page already exist? We'll have to update it...
$article = new Article( $this->title );
- $options = ( $wgDBtype == 'postgres' )
- ? '' // pg doesn't support this?
- : 'FOR UPDATE';
+ $options = 'FOR UPDATE';
$page = $dbw->selectRow( 'page',
array( 'page_id', 'page_latest' ),
array( 'page_namespace' => $this->title->getNamespace(),
'ar_timestamp',
'ar_minor_edit',
'ar_flags',
- 'ar_text_id' ),
+ 'ar_text_id',
+ 'ar_len' ),
/* WHERE */ array(
'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDBkey(),
'timestamp' => $row->ar_timestamp,
'minor_edit' => $row->ar_minor_edit,
'text_id' => $row->ar_text_id,
+ 'len' => $row->ar_len
) );
$revision->insertOn( $dbw );
$restored++;
}
if( $revision ) {
- # FIXME: Update latest if newer as well...
- if( $newid ) {
- // Attach the latest revision to the page...
- $article->updateRevisionOn( $dbw, $revision, $previousRevId );
-
+ // Attach the latest revision to the page...
+ $wasnew = $article->updateIfNewerOn( $dbw, $revision, $previousRevId );
+
+ if( $newid || $wasnew ) {
// Update site stats, link tables, etc
$article->createUpdates( $revision );
}
if( $newid ) {
+ wfRunHooks( 'ArticleUndelete', array( &$this->title, true ) );
Article::onArticleCreate( $this->title );
} else {
+ wfRunHooks( 'ArticleUndelete', array( &$this->title, false ) );
Article::onArticleEdit( $this->title );
}
} else {
}
/**
- *
- * @package MediaWiki
- * @subpackage SpecialPage
+ * The HTML form for Special:Undelete, which allows users with the appropriate
+ * permissions to view and restore deleted content.
+ * @addtogroup SpecialPage
*/
class UndeleteForm {
var $mAction, $mTarget, $mTimestamp, $mRestore, $mTargetObj;
if( $this->mPreview ) {
$wgOut->addHtml( "<hr />\n" );
- $wgOut->addWikiTextTitle( $rev->getText(), $archive->title, false );
+ $wgOut->addWikiTextTitleTidy( $rev->getText(), $this->mTargetObj, false );
}
$wgOut->addHtml(
}
$wgOut->addHTML( "<h2>" . htmlspecialchars( wfMsg( "history" ) ) . "</h2>\n" );
-
+
if( $haveRevisions ) {
# The page's stored (deleted) history:
$wgOut->addHTML("<ul>");
$pageLink = $wgLang->timeanddate( $ts, true );
}
$userLink = $sk->userLink( $row->ar_user, $row->ar_user_text ) . $sk->userToolLinks( $row->ar_user, $row->ar_user_text );
+ $stxt = '';
+ if (!is_null($size = $row->ar_len)) {
+ if ($size == 0) {
+ $stxt = wfMsgHtml('historyempty');
+ } else {
+ $stxt = wfMsgHtml('historysize', $wgLang->formatNum( $size ) );
+ }
+ }
$comment = $sk->commentBlock( $row->ar_comment );
- $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $comment</li>\n" );
+ $wgOut->addHTML( "<li>$checkBox $pageLink . . $userLink $stxt $comment</li>\n" );
}
$revisions->free();