return ($n > 0);
}
- const UNDELETE_NOTHINGRESTORED = 0; // No revisions could be restored
- const UNDELETE_NOTAVAIL = -1; // Not all requested revisions are available
- const UNDELETE_UNKNOWNERR = -2; // Unknown error
/**
* Restore the given (or all) text and file revisions for the page.
* Once restored, the items will be removed from the archive tables.
* @param string $comment
* @param array $fileVersions
*
- * @return array(number of revisions restored, number of file versions restored, log reason) on success or UNDELETE_* on failure
+ * @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() ) {
// If both the set of text revisions and file revisions are empty,
if( $restoreText ) {
$textRestored = $this->undeleteRevisions( $timestamps );
- if($textRestored < 0) // It must be one of UNDELETE_*
- return $textRestored;
+ if($textRestored === false) // It must be one of UNDELETE_*
+ return false;
} else {
$textRestored = 0;
}
$wgContLang->formatNum( $filesRestored ) );
} else {
wfDebug( "Undelete: nothing undeleted...\n" );
- return self::UNDELETE_NOTHINGRESTORED;
+ return false;
}
if( trim( $comment ) != '' )
* @param string $comment
* @param array $fileVersions
*
- * @return int number of revisions restored on success or UNDELETE_* on failure
+ * @return mixed number of revisions restored or false on failure
*/
private function undeleteRevisions( $timestamps ) {
- if ( wfReadOnly() ) return 0;
+ if ( wfReadOnly() )
+ return false;
$restoreAll = empty( $timestamps );
);
if( $dbw->numRows( $result ) < count( $timestamps ) ) {
wfDebug( __METHOD__.": couldn't find all requested rows\n" );
- return self::UNDELETE_NOTAVAIL;
+ return false;
}
$revision = null;
wfRunHooks( 'ArticleUndelete', array( &$this->title, false ) );
Article::onArticleEdit( $this->title );
}
+
+ if( $this->title->getNamespace() == NS_IMAGE ) {
+ $update = new HTMLCacheUpdate( $this->title, 'imagelinks' );
+ $update->doUpdate();
+ }
} else {
// Revision couldn't be created. This is very weird
return self::UNDELETE_UNKNOWNERR;
function showSearchForm() {
global $wgOut, $wgScript;
- $wgOut->addWikiText( wfMsg( 'undelete-header' ) );
+ $wgOut->addWikiMsg( 'undelete-header' );
$wgOut->addHtml(
Xml::openElement( 'form', array(
global $wgLang, $wgContLang, $wgUser, $wgOut;
if( $result->numRows() == 0 ) {
- $wgOut->addWikiText( wfMsg( 'undelete-no-results' ) );
+ $wgOut->addWikiMsg( 'undelete-no-results' );
return;
}
- $wgOut->addWikiText( wfMsg( "undeletepagetext" ) );
+ $wgOut->addWikiMsg( "undeletepagetext" );
$sk = $wgUser->getSkin();
$undelete = SpecialPage::getTitleFor( 'Undelete' );
$rev = $archive->getRevision( $timestamp );
if( !$rev ) {
- $wgOut->addWikiTexT( wfMsg( 'undeleterevision-missing' ) );
+ $wgOut->addWikiMsg( 'undeleterevision-missing' );
return;
}
/*
$text = $archive->getLastRevisionText();
if( is_null( $text ) ) {
- $wgOut->addWikiText( wfMsg( "nohistory" ) );
+ $wgOut->addWikiMsg( "nohistory" );
return;
}
*/
if ( $this->mAllowed ) {
- $wgOut->addWikiText( wfMsg( "undeletehistory" ) );
+ $wgOut->addWikiMsg( "undeletehistory" );
} else {
- $wgOut->addWikiText( wfMsg( "undeletehistorynoadmin" ) );
+ $wgOut->addWikiMsg( "undeletehistorynoadmin" );
}
# List all stored revisions
$revisions->free();
$wgOut->addHTML("</ul>");
} else {
- $wgOut->addWikiText( wfMsg( "nohistory" ) );
+ $wgOut->addWikiMsg( "nohistory" );
}
if( $haveFiles ) {
$this->mFileVersions );
if( is_array($ok) ) {
+ if ( $ok[1] ) // Undeleted file count
+ wfRunHooks( 'FileUndeleteComplete', array(
+ $this->mTargetObj, $this->mFileVersions,
+ $wgUser, $this->mComment) );
+
$skin = $wgUser->getSkin();
$link = $skin->makeKnownLinkObj( $this->mTargetObj );
$wgOut->addHtml( wfMsgWikiHtml( 'undeletedpage', $link ) );