' );
$out->addHTML( $revisions->getNavigationBar() );
} else {
$out->addWikiMsg( 'mergehistory-empty' );
}
# Show relevant lines from the merge log:
$mergeLogPage = new LogPage( 'merge' );
$out->addHTML( '
' . $mergeLogPage->getName()->escaped() . "
\n" );
LogEventsList::showLogExtract( $out, 'merge', $this->mTargetObj );
# When we submit, go by page ID to avoid some nasty but unlikely collisions.
# Such would happen if a page was renamed after the form loaded, but before submit
$misc = Html::hidden( 'targetID', $this->mTargetObj->getArticleID() );
$misc .= Html::hidden( 'destID', $this->mDestObj->getArticleID() );
$misc .= Html::hidden( 'target', $this->mTarget );
$misc .= Html::hidden( 'dest', $this->mDest );
$misc .= Html::hidden( 'wpEditToken', $this->getUser()->getEditToken() );
$misc .= Xml::closeElement( 'form' );
$out->addHTML( $misc );
return true;
}
public function formatRevisionRow( $row ) {
$revRecord = MediaWikiServices::getInstance()
->getRevisionFactory()
->newRevisionFromRow( $row );
$linkRenderer = $this->getLinkRenderer();
$stxt = '';
$last = $this->msg( 'last' )->escaped();
$ts = wfTimestamp( TS_MW, $row->rev_timestamp );
$checkBox = Xml::radio( 'mergepoint', $ts, ( $this->mTimestamp === $ts ) );
$user = $this->getUser();
$pageLink = $linkRenderer->makeKnownLink(
$revRecord->getPageAsLinkTarget(),
$this->getLanguage()->userTimeAndDate( $ts, $user ),
[],
[ 'oldid' => $revRecord->getId() ]
);
if ( $revRecord->isDeleted( RevisionRecord::DELETED_TEXT ) ) {
$pageLink = '' . $pageLink . '';
}
# Last link
if ( !RevisionRecord::userCanBitfield(
$revRecord->getVisibility(),
RevisionRecord::DELETED_TEXT,
$user
) ) {
$last = $this->msg( 'last' )->escaped();
} elseif ( isset( $this->prevId[$row->rev_id] ) ) {
$last = $linkRenderer->makeKnownLink(
$revRecord->getPageAsLinkTarget(),
$this->msg( 'last' )->text(),
[],
[
'diff' => $row->rev_id,
'oldid' => $this->prevId[$row->rev_id]
]
);
}
$userLink = Linker::revUserTools( $revRecord );
$size = $row->rev_len;
if ( $size !== null ) {
$stxt = Linker::formatRevisionSize( $size );
}
$comment = Linker::revComment( $revRecord );
return Html::rawElement( 'li', [],
$this->msg( 'mergehistory-revisionrow' )
->rawParams( $checkBox, $last, $pageLink, $userLink, $stxt, $comment )->escaped() );
}
/**
* Actually attempt the history move
*
* @todo if all versions of page A are moved to B and then a user
* tries to do a reverse-merge via the "unmerge" log link, then page
* A will still be a redirect (as it was after the original merge),
* though it will have the old revisions back from before (as expected).
* The user may have to "undo" the redirect manually to finish the "unmerge".
* Maybe this should delete redirects at the target page of merges?
*
* @return bool Success
*/
private function merge() {
# Get the titles directly from the IDs, in case the target page params
# were spoofed. The queries are done based on the IDs, so it's best to
# keep it consistent...
$targetTitle = Title::newFromID( $this->mTargetID );
$destTitle = Title::newFromID( $this->mDestID );
if ( $targetTitle === null || $destTitle === null ) {
return false; // validate these
}
if ( $targetTitle->getArticleID() == $destTitle->getArticleID() ) {
return false;
}
// MergeHistory object
$factory = MediaWikiServices::getInstance()->getMergeHistoryFactory();
$mh = $factory->newMergeHistory( $targetTitle, $destTitle, $this->mTimestamp );
// Merge!
$mergeStatus = $mh->merge( $this->getUser(), $this->mComment );
if ( !$mergeStatus->isOK() ) {
// Failed merge
$this->getOutput()->addWikiMsg( $mergeStatus->getMessage() );
return false;
}
$linkRenderer = $this->getLinkRenderer();
$targetLink = $linkRenderer->makeLink(
$targetTitle,
null,
[],
[ 'redirect' => 'no' ]
);
$this->getOutput()->addWikiMsg( $this->msg( 'mergehistory-done' )
->rawParams( $targetLink )
->params( $destTitle->getPrefixedText() )
->numParams( $mh->getMergedRevisionCount() )
);
return true;
}
protected function getGroupName() {
return 'pagetools';
}
}