2003-12-21 12:01:29 +00:00
|
|
|
<?php
|
2004-09-02 23:28:24 +00:00
|
|
|
/**
|
|
|
|
|
* Page history
|
2005-06-29 03:37:57 +00:00
|
|
|
*
|
2004-09-02 23:28:24 +00:00
|
|
|
* Split off from Article.php and Skin.php, 2003-12-22
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
/**
|
2005-06-29 03:37:57 +00:00
|
|
|
* This class handles printing the history page for an article. In order to
|
|
|
|
|
* be efficient, it uses timestamps rather than offsets for paging, to avoid
|
|
|
|
|
* costly LIMIT,offset queries.
|
|
|
|
|
*
|
|
|
|
|
* Construct it by passing in an Article, and call $h->history() to print the
|
|
|
|
|
* history.
|
|
|
|
|
*
|
2004-09-03 23:00:01 +00:00
|
|
|
* @package MediaWiki
|
2004-09-02 23:28:24 +00:00
|
|
|
*/
|
2005-03-31 09:52:06 +00:00
|
|
|
|
2003-12-21 12:01:29 +00:00
|
|
|
class PageHistory {
|
2006-06-06 12:28:44 +00:00
|
|
|
const DIR_PREV = 0;
|
|
|
|
|
const DIR_NEXT = 1;
|
|
|
|
|
|
2006-05-11 22:40:38 +00:00
|
|
|
var $mArticle, $mTitle, $mSkin;
|
|
|
|
|
var $lastdate;
|
|
|
|
|
var $linesonpage;
|
|
|
|
|
var $mNotificationTimestamp;
|
|
|
|
|
var $mLatestId = null;
|
2005-06-29 03:37:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Construct a new PageHistory.
|
|
|
|
|
*
|
|
|
|
|
* @param Article $article
|
|
|
|
|
* @returns nothing
|
|
|
|
|
*/
|
|
|
|
|
function PageHistory($article) {
|
|
|
|
|
global $wgUser;
|
|
|
|
|
|
2003-12-21 12:01:29 +00:00
|
|
|
$this->mArticle =& $article;
|
|
|
|
|
$this->mTitle =& $article->mTitle;
|
2005-06-29 03:37:57 +00:00
|
|
|
$this->mNotificationTimestamp = NULL;
|
|
|
|
|
$this->mSkin = $wgUser->getSkin();
|
2003-12-21 12:01:29 +00:00
|
|
|
}
|
2004-08-28 18:54:23 +00:00
|
|
|
|
2005-06-29 03:37:57 +00:00
|
|
|
/**
|
|
|
|
|
* Print the history page for an article.
|
|
|
|
|
*
|
|
|
|
|
* @returns nothing
|
|
|
|
|
*/
|
2004-09-02 23:28:24 +00:00
|
|
|
function history() {
|
2006-03-07 01:10:39 +00:00
|
|
|
global $wgOut, $wgRequest, $wgTitle;
|
2003-12-21 12:01:29 +00:00
|
|
|
|
2005-06-29 03:37:57 +00:00
|
|
|
/*
|
|
|
|
|
* Allow client caching.
|
|
|
|
|
*/
|
2004-08-28 18:54:23 +00:00
|
|
|
|
2005-06-29 03:37:57 +00:00
|
|
|
if( $wgOut->checkLastModified( $this->mArticle->getTimestamp() ) )
|
|
|
|
|
/* Client cache fresh and headers sent, nothing more to do. */
|
2003-12-21 12:01:29 +00:00
|
|
|
return;
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$fname = 'PageHistory::history';
|
2003-12-21 12:01:29 +00:00
|
|
|
wfProfileIn( $fname );
|
|
|
|
|
|
2005-06-29 03:37:57 +00:00
|
|
|
/*
|
|
|
|
|
* Setup page variables.
|
|
|
|
|
*/
|
2005-06-29 00:23:42 +00:00
|
|
|
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
2003-12-21 12:01:29 +00:00
|
|
|
$wgOut->setArticleFlag( false );
|
2004-01-17 09:49:43 +00:00
|
|
|
$wgOut->setArticleRelated( true );
|
2004-08-22 17:24:50 +00:00
|
|
|
$wgOut->setRobotpolicy( 'noindex,nofollow' );
|
2006-05-28 03:47:28 +00:00
|
|
|
$wgOut->setSyndicated( true );
|
|
|
|
|
|
2006-07-04 04:08:35 +00:00
|
|
|
$logPage = Title::makeTitle( NS_SPECIAL, 'Log' );
|
|
|
|
|
$logLink = $this->mSkin->makeKnownLinkObj( $logPage, wfMsgHtml( 'viewpagelogs' ), 'page=' . $this->mTitle->getPrefixedUrl() );
|
|
|
|
|
|
|
|
|
|
$subtitle = wfMsgHtml( 'revhistory' ) . '<br />' . $logLink;
|
|
|
|
|
$wgOut->setSubtitle( $subtitle );
|
|
|
|
|
|
2006-05-28 03:47:28 +00:00
|
|
|
$feedType = $wgRequest->getVal( 'feed' );
|
|
|
|
|
if( $feedType ) {
|
|
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return $this->feed( $feedType );
|
|
|
|
|
}
|
2003-12-21 12:01:29 +00:00
|
|
|
|
2005-06-29 03:37:57 +00:00
|
|
|
/*
|
|
|
|
|
* Fail if article doesn't exist.
|
|
|
|
|
*/
|
2005-08-12 16:14:20 +00:00
|
|
|
if( !$this->mTitle->exists() ) {
|
2005-07-10 00:24:23 +00:00
|
|
|
$wgOut->addWikiText( wfMsg( 'nohistory' ) );
|
2003-12-21 12:01:29 +00:00
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
return;
|
|
|
|
|
}
|
2004-08-28 18:54:23 +00:00
|
|
|
|
2006-07-07 03:28:48 +00:00
|
|
|
|
2005-06-29 03:37:57 +00:00
|
|
|
/*
|
2006-07-07 03:28:48 +00:00
|
|
|
* "go=first" means to jump to the last (earliest) history page.
|
|
|
|
|
* This is deprecated, it no longer appears in the user interface
|
2005-06-29 03:37:57 +00:00
|
|
|
*/
|
2006-07-07 03:28:48 +00:00
|
|
|
if ( $wgRequest->getText("go") == 'first' ) {
|
|
|
|
|
$limit = $wgRequest->getInt( 'limit', 50 );
|
|
|
|
|
$wgOut->redirect( $wgTitle->getLocalURL( "action=history&limit={$limit}&dir=prev" ) );
|
|
|
|
|
return;
|
2005-06-29 00:23:42 +00:00
|
|
|
}
|
|
|
|
|
|
2006-07-07 03:28:48 +00:00
|
|
|
/**
|
|
|
|
|
* Do the list
|
2005-06-29 03:37:57 +00:00
|
|
|
*/
|
2006-07-07 03:28:48 +00:00
|
|
|
$pager = new PageHistoryPager( $this );
|
|
|
|
|
$navbar = $pager->getNavigationBar();
|
2006-07-07 15:20:44 +00:00
|
|
|
$this->linesonpage = $pager->getNumRows();
|
2006-07-07 03:28:48 +00:00
|
|
|
$wgOut->addHTML(
|
|
|
|
|
$pager->getNavigationBar() .
|
|
|
|
|
$this->beginHistoryList() .
|
|
|
|
|
$pager->getBody() .
|
2006-07-07 17:11:47 +00:00
|
|
|
$this->endHistoryList() .
|
|
|
|
|
$pager->getNavigationBar()
|
2006-07-07 03:28:48 +00:00
|
|
|
);
|
2003-12-21 12:01:29 +00:00
|
|
|
wfProfileOut( $fname );
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2004-09-02 23:28:24 +00:00
|
|
|
function beginHistoryList() {
|
2004-01-31 04:10:53 +00:00
|
|
|
global $wgTitle;
|
2005-03-31 11:40:05 +00:00
|
|
|
$this->lastdate = '';
|
2006-04-27 14:50:45 +00:00
|
|
|
$s = wfMsgExt( 'histlegend', array( 'parse') );
|
2004-08-28 17:34:54 +00:00
|
|
|
$s .= '<form action="' . $wgTitle->escapeLocalURL( '-' ) . '" method="get">';
|
2004-08-28 18:54:23 +00:00
|
|
|
$prefixedkey = htmlspecialchars($wgTitle->getPrefixedDbKey());
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-08-22 06:25:13 +00:00
|
|
|
// The following line is SUPPOSED to have double-quotes around the
|
|
|
|
|
// $prefixedkey variable, because htmlspecialchars() doesn't escape
|
|
|
|
|
// single-quotes.
|
|
|
|
|
//
|
|
|
|
|
// On at least two occasions people have changed it to single-quotes,
|
|
|
|
|
// which creates invalid HTML and incorrect display of the resulting
|
|
|
|
|
// link.
|
|
|
|
|
//
|
|
|
|
|
// Please do not break this a third time. Thank you for your kind
|
|
|
|
|
// consideration and cooperation.
|
|
|
|
|
//
|
2005-08-22 06:09:25 +00:00
|
|
|
$s .= "<input type='hidden' name='title' value=\"{$prefixedkey}\" />\n";
|
2006-01-07 13:31:29 +00:00
|
|
|
|
2005-03-31 11:40:05 +00:00
|
|
|
$s .= $this->submitButton();
|
2005-08-12 16:14:20 +00:00
|
|
|
$s .= '<ul id="pagehistory">' . "\n";
|
2003-12-21 12:01:29 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2005-03-31 11:40:05 +00:00
|
|
|
function endHistoryList() {
|
|
|
|
|
$s = '</ul>';
|
|
|
|
|
$s .= $this->submitButton( array( 'id' => 'historysubmit' ) );
|
2004-08-28 17:34:54 +00:00
|
|
|
$s .= '</form>';
|
2003-12-21 12:01:29 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2005-03-31 11:40:05 +00:00
|
|
|
function submitButton( $bits = array() ) {
|
|
|
|
|
return ( $this->linesonpage > 0 )
|
|
|
|
|
? wfElement( 'input', array_merge( $bits,
|
|
|
|
|
array(
|
|
|
|
|
'class' => 'historysubmit',
|
|
|
|
|
'type' => 'submit',
|
2006-04-27 14:50:45 +00:00
|
|
|
'accesskey' => wfMsg( 'accesskey-compareselectedversions' ),
|
2006-10-30 04:33:40 +00:00
|
|
|
'title' => wfMsg( 'tooltip-compareselectedversions' ).' ['.wfMsg( 'accesskey-compareselectedversions' ).']',
|
2006-04-27 14:50:45 +00:00
|
|
|
'value' => wfMsg( 'compareselectedversions' ),
|
2005-03-31 11:40:05 +00:00
|
|
|
) ) )
|
|
|
|
|
: '';
|
|
|
|
|
}
|
2003-12-21 12:01:29 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2005-08-12 16:14:20 +00:00
|
|
|
function historyLine( $row, $next, $counter = '', $notificationtimestamp = false, $latest = false, $firstInList = false ) {
|
2006-03-16 19:04:25 +00:00
|
|
|
global $wgUser;
|
|
|
|
|
$rev = new Revision( $row );
|
2006-06-11 04:48:27 +00:00
|
|
|
$rev->setTitle( $this->mTitle );
|
2003-12-21 12:01:29 +00:00
|
|
|
|
2004-08-22 17:24:50 +00:00
|
|
|
$s = '<li>';
|
2006-03-16 19:04:25 +00:00
|
|
|
$curlink = $this->curLink( $rev, $latest );
|
|
|
|
|
$lastlink = $this->lastLink( $rev, $next, $counter );
|
|
|
|
|
$arbitrary = $this->diffButtons( $rev, $firstInList, $counter );
|
|
|
|
|
$link = $this->revLink( $rev );
|
2006-06-25 02:46:24 +00:00
|
|
|
|
|
|
|
|
$user = $this->mSkin->userLink( $rev->getUser(), $rev->getUserText() )
|
|
|
|
|
. $this->mSkin->userToolLinks( $rev->getUser(), $rev->getUserText() );
|
|
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
$s .= "($curlink) ($lastlink) $arbitrary";
|
|
|
|
|
|
|
|
|
|
if( $wgUser->isAllowed( 'deleterevision' ) ) {
|
|
|
|
|
$revdel = Title::makeTitle( NS_SPECIAL, 'Revisiondelete' );
|
|
|
|
|
if( $firstInList ) {
|
|
|
|
|
// We don't currently handle well changing the top revision's settings
|
|
|
|
|
$del = wfMsgHtml( 'rev-delundel' );
|
|
|
|
|
} else {
|
|
|
|
|
$del = $this->mSkin->makeKnownLinkObj( $revdel,
|
|
|
|
|
wfMsg( 'rev-delundel' ),
|
|
|
|
|
'target=' . urlencode( $this->mTitle->getPrefixedDbkey() ) .
|
|
|
|
|
'&oldid=' . urlencode( $rev->getId() ) );
|
|
|
|
|
}
|
|
|
|
|
$s .= "(<small>$del</small>) ";
|
2003-12-21 12:01:29 +00:00
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
|
|
|
|
|
$s .= " $link <span class='history-user'>$user</span>";
|
2005-03-31 11:40:05 +00:00
|
|
|
|
|
|
|
|
if( $row->rev_minor_edit ) {
|
2006-04-27 14:50:45 +00:00
|
|
|
$s .= ' ' . wfElement( 'span', array( 'class' => 'minor' ), wfMsg( 'minoreditletter') );
|
2004-05-18 12:36:13 +00:00
|
|
|
}
|
2004-08-28 18:54:23 +00:00
|
|
|
|
2006-03-16 19:04:25 +00:00
|
|
|
$s .= $this->mSkin->revComment( $rev );
|
2005-08-12 16:14:20 +00:00
|
|
|
if ($notificationtimestamp && ($row->rev_timestamp >= $notificationtimestamp)) {
|
|
|
|
|
$s .= ' <span class="updatedmarker">' . wfMsgHtml( 'updatedmarker' ) . '</span>';
|
2004-12-18 03:47:11 +00:00
|
|
|
}
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $row->rev_deleted & Revision::DELETED_TEXT ) {
|
2006-03-16 19:04:25 +00:00
|
|
|
$s .= ' ' . wfMsgHtml( 'deletedrev' );
|
2005-03-31 11:40:05 +00:00
|
|
|
}
|
2005-08-12 16:14:20 +00:00
|
|
|
$s .= "</li>\n";
|
2003-12-21 12:01:29 +00:00
|
|
|
|
2005-03-31 11:40:05 +00:00
|
|
|
return $s;
|
2003-12-21 12:01:29 +00:00
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2006-03-16 19:04:25 +00:00
|
|
|
function revLink( $rev ) {
|
2006-03-18 01:06:57 +00:00
|
|
|
global $wgLang;
|
2006-03-16 19:04:25 +00:00
|
|
|
$date = $wgLang->timeanddate( wfTimestamp(TS_MW, $rev->getTimestamp()), true );
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $rev->userCan( Revision::DELETED_TEXT ) ) {
|
2006-03-16 19:04:25 +00:00
|
|
|
$link = $this->mSkin->makeKnownLinkObj(
|
|
|
|
|
$this->mTitle, $date, "oldid=" . $rev->getId() );
|
2005-03-31 11:40:05 +00:00
|
|
|
} else {
|
2006-03-16 19:04:25 +00:00
|
|
|
$link = $date;
|
|
|
|
|
}
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $rev->isDeleted( Revision::DELETED_TEXT ) ) {
|
2006-03-16 19:04:25 +00:00
|
|
|
return '<span class="history-deleted">' . $link . '</span>';
|
2005-03-31 11:40:05 +00:00
|
|
|
}
|
2006-03-16 19:04:25 +00:00
|
|
|
return $link;
|
2005-03-31 11:40:05 +00:00
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2006-03-16 19:04:25 +00:00
|
|
|
function curLink( $rev, $latest ) {
|
2006-04-27 14:50:45 +00:00
|
|
|
$cur = wfMsgExt( 'cur', array( 'escape') );
|
2006-06-23 06:31:46 +00:00
|
|
|
if( $latest || !$rev->userCan( Revision::DELETED_TEXT ) ) {
|
2005-03-31 11:40:05 +00:00
|
|
|
return $cur;
|
|
|
|
|
} else {
|
|
|
|
|
return $this->mSkin->makeKnownLinkObj(
|
2005-08-12 16:14:20 +00:00
|
|
|
$this->mTitle, $cur,
|
|
|
|
|
'diff=' . $this->getLatestID() .
|
2006-03-16 19:04:25 +00:00
|
|
|
"&oldid=" . $rev->getId() );
|
2005-03-31 11:40:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2006-03-16 19:04:25 +00:00
|
|
|
function lastLink( $rev, $next, $counter ) {
|
2006-04-27 14:50:45 +00:00
|
|
|
$last = wfMsgExt( 'last', array( 'escape' ) );
|
2006-07-07 03:28:48 +00:00
|
|
|
if ( is_null( $next ) ) {
|
|
|
|
|
# Probably no next row
|
|
|
|
|
return $last;
|
|
|
|
|
} elseif ( $next === 'unknown' ) {
|
|
|
|
|
# Next row probably exists but is unknown, use an oldid=prev link
|
|
|
|
|
return $this->mSkin->makeKnownLinkObj(
|
|
|
|
|
$this->mTitle,
|
|
|
|
|
$last,
|
|
|
|
|
"diff=" . $rev->getId() . "&oldid=prev" );
|
2006-06-23 06:31:46 +00:00
|
|
|
} elseif( !$rev->userCan( Revision::DELETED_TEXT ) ) {
|
2005-03-31 11:40:05 +00:00
|
|
|
return $last;
|
|
|
|
|
} else {
|
|
|
|
|
return $this->mSkin->makeKnownLinkObj(
|
2005-08-12 16:14:20 +00:00
|
|
|
$this->mTitle,
|
|
|
|
|
$last,
|
2006-03-16 19:04:25 +00:00
|
|
|
"diff=" . $rev->getId() . "&oldid={$next->rev_id}"
|
2005-08-12 16:14:20 +00:00
|
|
|
/*,
|
|
|
|
|
'',
|
|
|
|
|
'',
|
|
|
|
|
"tabindex={$counter}"*/ );
|
2005-03-31 11:40:05 +00:00
|
|
|
}
|
|
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2006-03-16 19:04:25 +00:00
|
|
|
function diffButtons( $rev, $firstInList, $counter ) {
|
2005-03-31 11:40:05 +00:00
|
|
|
if( $this->linesonpage > 1) {
|
|
|
|
|
$radio = array(
|
|
|
|
|
'type' => 'radio',
|
2006-03-16 19:04:25 +00:00
|
|
|
'value' => $rev->getId(),
|
2005-08-12 16:14:20 +00:00
|
|
|
# do we really need to flood this on every item?
|
|
|
|
|
# 'title' => wfMsgHtml( 'selectolderversionfordiff' )
|
2005-03-31 11:40:05 +00:00
|
|
|
);
|
2005-08-12 16:14:20 +00:00
|
|
|
|
2006-06-23 06:31:46 +00:00
|
|
|
if( !$rev->userCan( Revision::DELETED_TEXT ) ) {
|
2005-03-31 11:40:05 +00:00
|
|
|
$radio['disabled'] = 'disabled';
|
|
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
/** @todo: move title texts to javascript */
|
|
|
|
|
if ( $firstInList ) {
|
2005-03-31 11:40:05 +00:00
|
|
|
$first = wfElement( 'input', array_merge(
|
|
|
|
|
$radio,
|
|
|
|
|
array(
|
|
|
|
|
'style' => 'visibility:hidden',
|
|
|
|
|
'name' => 'oldid' ) ) );
|
|
|
|
|
$checkmark = array( 'checked' => 'checked' );
|
|
|
|
|
} else {
|
|
|
|
|
if( $counter == 2 ) {
|
|
|
|
|
$checkmark = array( 'checked' => 'checked' );
|
|
|
|
|
} else {
|
|
|
|
|
$checkmark = array();
|
|
|
|
|
}
|
|
|
|
|
$first = wfElement( 'input', array_merge(
|
|
|
|
|
$radio,
|
|
|
|
|
$checkmark,
|
|
|
|
|
array( 'name' => 'oldid' ) ) );
|
|
|
|
|
$checkmark = array();
|
|
|
|
|
}
|
|
|
|
|
$second = wfElement( 'input', array_merge(
|
|
|
|
|
$radio,
|
|
|
|
|
$checkmark,
|
|
|
|
|
array( 'name' => 'diff' ) ) );
|
|
|
|
|
return $first . $second;
|
|
|
|
|
} else {
|
|
|
|
|
return '';
|
|
|
|
|
}
|
|
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2005-10-28 11:05:32 +00:00
|
|
|
function getLatestId() {
|
|
|
|
|
if( is_null( $this->mLatestId ) ) {
|
|
|
|
|
$id = $this->mTitle->getArticleID();
|
|
|
|
|
$db =& wfGetDB(DB_SLAVE);
|
2006-07-07 03:28:48 +00:00
|
|
|
$this->mLatestId = $db->selectField( 'page',
|
|
|
|
|
"page_latest",
|
|
|
|
|
array( 'page_id' => $id ),
|
2005-10-28 11:05:32 +00:00
|
|
|
'PageHistory::getLatestID' );
|
|
|
|
|
}
|
|
|
|
|
return $this->mLatestId;
|
2005-07-01 09:42:56 +00:00
|
|
|
}
|
|
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
/**
|
2006-07-07 03:28:48 +00:00
|
|
|
* Fetch an array of revisions, specified by a given limit, offset and
|
|
|
|
|
* direction. This is now only used by the feeds. It was previously
|
|
|
|
|
* used by the main UI but that's now handled by the pager.
|
2005-08-12 16:14:20 +00:00
|
|
|
*/
|
2005-06-29 03:37:57 +00:00
|
|
|
function fetchRevisions($limit, $offset, $direction) {
|
2005-08-12 16:14:20 +00:00
|
|
|
$fname = 'PageHistory::fetchRevisions';
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
$dbr =& wfGetDB( DB_SLAVE );
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2006-06-06 12:28:44 +00:00
|
|
|
if ($direction == PageHistory::DIR_PREV)
|
2005-06-29 03:37:57 +00:00
|
|
|
list($dirs, $oper) = array("ASC", ">=");
|
2006-06-06 12:28:44 +00:00
|
|
|
else /* $direction == PageHistory::DIR_NEXT */
|
2005-06-29 03:37:57 +00:00
|
|
|
list($dirs, $oper) = array("DESC", "<=");
|
|
|
|
|
|
|
|
|
|
if ($offset)
|
2005-08-12 16:14:20 +00:00
|
|
|
$offsets = array("rev_timestamp $oper '$offset'");
|
|
|
|
|
else
|
|
|
|
|
$offsets = array();
|
2005-06-29 03:37:57 +00:00
|
|
|
|
|
|
|
|
$page_id = $this->mTitle->getArticleID();
|
|
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
$res = $dbr->select(
|
|
|
|
|
'revision',
|
2006-03-16 19:04:25 +00:00
|
|
|
array('rev_id', 'rev_page', 'rev_text_id', 'rev_user', 'rev_comment', 'rev_user_text',
|
2005-08-12 16:14:20 +00:00
|
|
|
'rev_timestamp', 'rev_minor_edit', 'rev_deleted'),
|
|
|
|
|
array_merge(array("rev_page=$page_id"), $offsets),
|
|
|
|
|
$fname,
|
|
|
|
|
array('ORDER BY' => "rev_timestamp $dirs",
|
|
|
|
|
'USE INDEX' => 'page_timestamp', 'LIMIT' => $limit)
|
|
|
|
|
);
|
2005-06-29 03:37:57 +00:00
|
|
|
|
|
|
|
|
$result = array();
|
2005-08-12 16:14:20 +00:00
|
|
|
while (($obj = $dbr->fetchObject($res)) != NULL)
|
2005-06-29 03:37:57 +00:00
|
|
|
$result[] = $obj;
|
|
|
|
|
|
|
|
|
|
return $result;
|
|
|
|
|
}
|
|
|
|
|
|
2005-07-05 21:22:25 +00:00
|
|
|
/** @todo document */
|
2005-06-29 03:37:57 +00:00
|
|
|
function getNotificationTimestamp() {
|
|
|
|
|
global $wgUser, $wgShowUpdatedMarker;
|
2005-08-12 16:14:20 +00:00
|
|
|
$fname = 'PageHistory::getNotficationTimestamp';
|
2005-06-29 03:37:57 +00:00
|
|
|
|
|
|
|
|
if ($this->mNotificationTimestamp !== NULL)
|
|
|
|
|
return $this->mNotificationTimestamp;
|
|
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
if ($wgUser->isAnon() || !$wgShowUpdatedMarker)
|
2005-06-29 03:37:57 +00:00
|
|
|
return $this->mNotificationTimestamp = false;
|
|
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
$dbr =& wfGetDB(DB_SLAVE);
|
2005-06-29 03:37:57 +00:00
|
|
|
|
2005-08-12 16:14:20 +00:00
|
|
|
$this->mNotificationTimestamp = $dbr->selectField(
|
2005-06-29 03:37:57 +00:00
|
|
|
'watchlist',
|
|
|
|
|
'wl_notificationtimestamp',
|
|
|
|
|
array( 'wl_namespace' => $this->mTitle->getNamespace(),
|
|
|
|
|
'wl_title' => $this->mTitle->getDBkey(),
|
|
|
|
|
'wl_user' => $wgUser->getID()
|
|
|
|
|
),
|
2005-08-12 16:14:20 +00:00
|
|
|
$fname);
|
2006-06-11 04:48:27 +00:00
|
|
|
|
|
|
|
|
// Don't use the special value reserved for telling whether the field is filled
|
|
|
|
|
if ( is_null( $this->mNotificationTimestamp ) ) {
|
|
|
|
|
$this->mNotificationTimestamp = false;
|
|
|
|
|
}
|
2005-06-29 03:37:57 +00:00
|
|
|
|
|
|
|
|
return $this->mNotificationTimestamp;
|
|
|
|
|
}
|
2006-05-28 03:47:28 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Output a subscription feed listing recent edits to this page.
|
|
|
|
|
* @param string $type
|
|
|
|
|
*/
|
|
|
|
|
function feed( $type ) {
|
2006-06-01 08:19:02 +00:00
|
|
|
require_once 'SpecialRecentchanges.php';
|
|
|
|
|
|
2006-05-28 03:47:28 +00:00
|
|
|
global $wgFeedClasses;
|
|
|
|
|
if( !isset( $wgFeedClasses[$type] ) ) {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
$wgOut->addWikiText( wfMsg( 'feed-invalid' ) );
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$feed = new $wgFeedClasses[$type](
|
2006-05-28 10:08:05 +00:00
|
|
|
$this->mTitle->getPrefixedText() . ' - ' .
|
|
|
|
|
wfMsgForContent( 'history-feed-title' ),
|
|
|
|
|
wfMsgForContent( 'history-feed-description' ),
|
2006-05-28 03:47:28 +00:00
|
|
|
$this->mTitle->getFullUrl( 'action=history' ) );
|
|
|
|
|
|
2006-06-06 12:28:44 +00:00
|
|
|
$items = $this->fetchRevisions(10, 0, PageHistory::DIR_NEXT);
|
2006-05-28 03:47:28 +00:00
|
|
|
$feed->outHeader();
|
|
|
|
|
if( $items ) {
|
|
|
|
|
foreach( $items as $row ) {
|
|
|
|
|
$feed->outItem( $this->feedItem( $row ) );
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
$feed->outItem( $this->feedEmpty() );
|
|
|
|
|
}
|
|
|
|
|
$feed->outFooter();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function feedEmpty() {
|
|
|
|
|
global $wgOut;
|
|
|
|
|
return new FeedItem(
|
|
|
|
|
wfMsgForContent( 'nohistory' ),
|
|
|
|
|
$wgOut->parse( wfMsgForContent( 'history-feed-empty' ) ),
|
|
|
|
|
$this->mTitle->getFullUrl(),
|
|
|
|
|
wfTimestamp( TS_MW ),
|
|
|
|
|
'',
|
|
|
|
|
$this->mTitle->getTalkPage()->getFullUrl() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Generate a FeedItem object from a given revision table row
|
|
|
|
|
* Borrows Recent Changes' feed generation functions for formatting;
|
|
|
|
|
* includes a diff to the previous revision (if any).
|
|
|
|
|
*
|
|
|
|
|
* @param $row
|
|
|
|
|
* @return FeedItem
|
|
|
|
|
*/
|
|
|
|
|
function feedItem( $row ) {
|
|
|
|
|
$rev = new Revision( $row );
|
2006-06-11 04:48:27 +00:00
|
|
|
$rev->setTitle( $this->mTitle );
|
2006-05-28 03:47:28 +00:00
|
|
|
$text = rcFormatDiffRow( $this->mTitle,
|
|
|
|
|
$this->mTitle->getPreviousRevisionID( $rev->getId() ),
|
|
|
|
|
$rev->getId(),
|
|
|
|
|
$rev->getTimestamp(),
|
|
|
|
|
$rev->getComment() );
|
|
|
|
|
|
|
|
|
|
if( $rev->getComment() == '' ) {
|
|
|
|
|
global $wgContLang;
|
|
|
|
|
$title = wfMsgForContent( 'history-feed-item-nocomment',
|
|
|
|
|
$rev->getUserText(),
|
|
|
|
|
$wgContLang->timeanddate( $rev->getTimestamp() ) );
|
|
|
|
|
} else {
|
|
|
|
|
$title = $rev->getUserText() . ": " . $this->stripComment( $rev->getComment() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return new FeedItem(
|
|
|
|
|
$title,
|
|
|
|
|
$text,
|
|
|
|
|
$this->mTitle->getFullUrl( 'diff=' . $rev->getId() . '&oldid=prev' ),
|
|
|
|
|
$rev->getTimestamp(),
|
|
|
|
|
$rev->getUserText(),
|
|
|
|
|
$this->mTitle->getTalkPage()->getFullUrl() );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Quickie hack... strip out wikilinks to more legible form from the comment.
|
|
|
|
|
*/
|
|
|
|
|
function stripComment( $text ) {
|
|
|
|
|
return preg_replace( '/\[\[([^]]*\|)?([^]]+)\]\]/', '\2', $text );
|
|
|
|
|
}
|
2006-07-07 03:28:48 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PageHistoryPager extends ReverseChronologicalPager {
|
|
|
|
|
public $mLastRow = false, $mPageHistory;
|
|
|
|
|
|
|
|
|
|
function __construct( $pageHistory ) {
|
|
|
|
|
parent::__construct();
|
|
|
|
|
$this->mPageHistory = $pageHistory;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getQueryInfo() {
|
|
|
|
|
return array(
|
|
|
|
|
'tables' => 'revision',
|
|
|
|
|
'fields' => array('rev_id', 'rev_page', 'rev_text_id', 'rev_user', 'rev_comment', 'rev_user_text',
|
|
|
|
|
'rev_timestamp', 'rev_minor_edit', 'rev_deleted'),
|
|
|
|
|
'conds' => array('rev_page' => $this->mPageHistory->mTitle->getArticleID() ),
|
|
|
|
|
'options' => array( 'USE INDEX' => 'page_timestamp' )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getIndexField() {
|
|
|
|
|
return 'rev_timestamp';
|
|
|
|
|
}
|
2005-08-12 16:14:20 +00:00
|
|
|
|
2006-07-07 03:28:48 +00:00
|
|
|
function formatRow( $row ) {
|
|
|
|
|
if ( $this->mLastRow ) {
|
|
|
|
|
$latest = $this->mCounter == 1 && $this->mOffset == '';
|
|
|
|
|
$firstInList = $this->mCounter == 1;
|
|
|
|
|
$s = $this->mPageHistory->historyLine( $this->mLastRow, $row, $this->mCounter++,
|
|
|
|
|
$this->mPageHistory->getNotificationTimestamp(), $latest, $firstInList );
|
|
|
|
|
} else {
|
|
|
|
|
$s = '';
|
|
|
|
|
}
|
|
|
|
|
$this->mLastRow = $row;
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
function getStartBody() {
|
|
|
|
|
$this->mLastRow = false;
|
|
|
|
|
$this->mCounter = 1;
|
|
|
|
|
return '';
|
|
|
|
|
}
|
2005-08-12 16:14:20 +00:00
|
|
|
|
2006-07-07 03:28:48 +00:00
|
|
|
function getEndBody() {
|
|
|
|
|
if ( $this->mLastRow ) {
|
|
|
|
|
$latest = $this->mCounter == 1 && $this->mOffset == 0;
|
|
|
|
|
$firstInList = $this->mCounter == 1;
|
|
|
|
|
if ( $this->mIsBackwards ) {
|
|
|
|
|
# Next row is unknown, but for UI reasons, probably exists if an offset has been specified
|
|
|
|
|
if ( $this->mOffset == '' ) {
|
|
|
|
|
$next = null;
|
|
|
|
|
} else {
|
|
|
|
|
$next = 'unknown';
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
# The next row is the past-the-end row
|
|
|
|
|
$next = $this->mPastTheEndRow;
|
|
|
|
|
}
|
|
|
|
|
$s = $this->mPageHistory->historyLine( $this->mLastRow, $next, $this->mCounter++,
|
|
|
|
|
$this->mPageHistory->getNotificationTimestamp(), $latest, $firstInList );
|
|
|
|
|
} else {
|
|
|
|
|
$s = '';
|
|
|
|
|
}
|
|
|
|
|
return $s;
|
|
|
|
|
}
|
2003-12-21 12:01:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|