* revision of the page with the given timestamp.
*
* @return string
+ * @deprecated Use getRevision() for more flexible information
*/
function getRevisionText( $timestamp ) {
+ $rev = $this->getRevision( $timestamp );
+ return $rev ? $rev->getText() : null;
+ }
+
+ /**
+ * Return a Revision object containing data for the deleted revision.
+ * Note that the result *may* or *may not* have a null page ID.
+ * @param string $timestamp
+ * @return Revision
+ */
+ function getRevision( $timestamp ) {
$dbr =& wfGetDB( DB_SLAVE );
$row = $dbr->selectRow( 'archive',
- array( 'ar_text', 'ar_flags', 'ar_text_id' ),
+ array(
+ 'ar_rev_id',
+ 'ar_text',
+ 'ar_comment',
+ 'ar_user',
+ 'ar_user_text',
+ 'ar_timestamp',
+ 'ar_minor_edit',
+ 'ar_flags',
+ 'ar_text_id' ),
array( 'ar_namespace' => $this->title->getNamespace(),
'ar_title' => $this->title->getDbkey(),
'ar_timestamp' => $dbr->timestamp( $timestamp ) ),
__METHOD__ );
if( $row ) {
- return $this->getTextFromRow( $row );
+ return new Revision( array(
+ 'page' => $this->title->getArticleId(),
+ 'id' => $row->ar_rev_id,
+ 'text' => ($row->ar_text_id ? null : $row->ar_text),
+ 'comment' => $row->ar_comment,
+ 'user' => $row->ar_user,
+ 'user_text' => $row->ar_user_text,
+ 'timestamp' => $row->ar_timestamp,
+ 'minor_edit' => $row->ar_minor_edit,
+ 'text_id' => $row->ar_text_id ) );
} else {
return null;
}
if( $revision ) {
# FIXME: Update latest if newer as well...
if( $newid ) {
- # FIXME: update article count if changed...
+ // Attach the latest revision to the page...
$article->updateRevisionOn( $dbw, $revision, $previousRevId );
-
- # Finally, clean up the link tables
- $options = new ParserOptions;
- $parserOutput = $wgParser->parse( $revision->getText(), $this->title, $options,
- true, true, $newRevId );
- $u = new LinksUpdate( $this->title, $parserOutput );
- $u->doUpdate();
-
- #TODO: SearchUpdate, etc.
+
+ // Update site stats, link tables, etc
+ $article->createUpdates( $revision );
}
if( $newid ) {
function UndeleteForm( &$request, $par = "" ) {
global $wgUser;
- $this->mAction = $request->getText( 'action' );
- $this->mTarget = $request->getText( 'target' );
- $this->mTimestamp = $request->getText( 'timestamp' );
+ $this->mAction = $request->getVal( 'action' );
+ $this->mTarget = $request->getVal( 'target' );
+ $time = $request->getVal( 'timestamp' );
+ $this->mTimestamp = $time ? wfTimestamp( TS_MW, $time ) : '';
$this->mFile = $request->getVal( 'file' );
$posted = $request->wasPosted() &&
$wgOut->addWikiText( wfMsg( "undeletepagetext" ) );
$sk = $wgUser->getSkin();
- $undelete =& Title::makeTitle( NS_SPECIAL, 'Undelete' );
+ $undelete =& SpecialPage::getTitleFor( 'Undelete' );
$wgOut->addHTML( "<ul>\n" );
while( $row = $result->fetchObject() ) {
$title = Title::makeTitleSafe( $row->ar_namespace, $row->ar_title );
if(!preg_match("/[0-9]{14}/",$timestamp)) return 0;
$archive = new PageArchive( $this->mTargetObj );
- $text = $archive->getRevisionText( $timestamp );
-
+ $rev = $archive->getRevision( $timestamp );
+
$wgOut->setPagetitle( wfMsg( "undeletepage" ) );
$wgOut->addWikiText( "(" . wfMsg( "undeleterevision",
$wgLang->date( $timestamp ) ) . ")\n" );
+ if( !$rev ) {
+ $wgOut->addWikiText( wfMsg( 'undeleterevision-missing' ) );
+ return;
+ }
+
+ wfRunHooks( 'UndeleteShowRevision', array( $this->mTargetObj, $rev ) );
+
if( $this->mPreview ) {
$wgOut->addHtml( "<hr />\n" );
- $wgOut->addWikiText( $text );
+ $wgOut->addWikiText( $rev->getText() );
}
- $self = Title::makeTitle( NS_SPECIAL, "Undelete" );
+ $self = SpecialPage::getTitleFor( "Undelete" );
$wgOut->addHtml(
wfElement( 'textarea', array(
'readonly' => true,
'cols' => intval( $wgUser->getOption( 'cols' ) ),
'rows' => intval( $wgUser->getOption( 'rows' ) ) ),
- $text . "\n" ) .
+ $rev->getText() . "\n" ) .
wfOpenElement( 'div' ) .
wfOpenElement( 'form', array(
'method' => 'post',
}
if ( $this->mAllowed ) {
- $titleObj = Title::makeTitle( NS_SPECIAL, "Undelete" );
+ $titleObj = SpecialPage::getTitleFor( "Undelete" );
$action = $titleObj->getLocalURL( "action=submit" );
# Start the form here
$top = wfOpenElement( 'form', array( 'method' => 'post', 'action' => $action, 'id' => 'undelete' ) );