$title = Title::newFromText( $prefix );
if( $title ) {
$ns = $title->getNamespace();
- $encPrefix = $dbr->escapeLike( $title->getDbKey() );
+ $encPrefix = $dbr->escapeLike( $title->getDBkey() );
} else {
// Prolly won't work too good
// @todo handle bare namespace names cleanly?
'fa_user',
'fa_user_text',
'fa_timestamp' ),
- array( 'fa_name' => $this->title->getDbKey() ),
+ array( 'fa_name' => $this->title->getDBkey() ),
__METHOD__,
array( 'ORDER BY' => 'fa_timestamp DESC' ) );
$ret = $dbr->resultObject( $res );
'ar_text_id',
'ar_len' ),
array( 'ar_namespace' => $this->title->getNamespace(),
- 'ar_title' => $this->title->getDbkey(),
+ 'ar_title' => $this->title->getDBkey(),
'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
__METHOD__ );
if( $row ) {
$row = $dbr->selectRow( 'archive',
'ar_timestamp',
array( 'ar_namespace' => $this->title->getNamespace(),
- 'ar_title' => $this->title->getDbkey(),
+ 'ar_title' => $this->title->getDBkey(),
'ar_timestamp < ' .
$dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
__METHOD__,
array( 'rev_id', 'rev_timestamp' ),
array(
'page_namespace' => $this->title->getNamespace(),
- 'page_title' => $this->title->getDbkey(),
+ 'page_title' => $this->title->getDBkey(),
'page_id = rev_page',
'rev_timestamp < ' .
$dbr->addQuotes( $dbr->timestamp( $timestamp ) ) ),
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 );
'ar_minor_edit',
'ar_flags',
'ar_text_id',
+ 'ar_page_id',
'ar_len' ),
/* WHERE */ array(
'ar_namespace' => $this->title->getNamespace(),
);
if( $dbw->numRows( $result ) < count( $timestamps ) ) {
wfDebug( __METHOD__.": couldn't find all requested rows\n" );
- return self::UNDELETE_NOTAVAIL;
+ return false;
}
$revision = null;
) );
$revision->insertOn( $dbw );
$restored++;
+
+ wfRunHooks( 'ArticleRevisionUndeleted', array( &$this->title, $revision, $row->ar_page_id ) );
}
// Was anything restored at all?
if($restored == 0)
if( $par != "" ) {
$this->mTarget = $par;
}
- if ( $wgUser->isAllowed( 'delete' ) && !$wgUser->isBlocked() ) {
+ if ( $wgUser->isAllowed( 'undelete' ) && !$wgUser->isBlocked() ) {
$this->mAllowed = true;
} else {
$this->mAllowed = false;
$wgOut->setPageTitle( wfMsg( 'undeletepage' ) );
$link = $skin->makeKnownLinkObj(
- $self,
- htmlspecialchars( $this->mTargetObj->getPrefixedText() ),
- 'target=' . $this->mTargetObj->getPrefixedUrl()
+ SpecialPage::getTitleFor( 'Undelete', $this->mTargetObj->getPrefixedDBkey() ),
+ htmlspecialchars( $this->mTargetObj->getPrefixedText() )
);
$time = htmlspecialchars( $wgLang->timeAndDate( $timestamp, true ) );
$user = $skin->userLink( $rev->getUser(), $rev->getUserText() )
$wgOut->addHtml( '<hr />' );
}
} else {
- $wgOut->addHtml( 'No previous revision found.' );
+ $wgOut->addHtml( wfMsgHtml( 'undelete-nodiff' ) );
}
}
function undelete() {
global $wgOut, $wgUser;
+ if ( wfReadOnly() ) {
+ $wgOut->readOnlyPage();
+ return;
+ }
if( !is_null( $this->mTargetObj ) ) {
$archive = new PageArchive( $this->mTargetObj );