/**
* @todo document
*/
-class RCCacheEntry extends RecentChange
-{
+class RCCacheEntry extends RecentChange {
var $secureName, $link;
- var $curlink , $difflink, $lastlink , $usertalklink , $versionlink ;
+ var $curlink , $difflink, $lastlink, $usertalklink, $versionlink;
var $userlink, $timestamp, $watched;
static function newFromParent( $rc ) {
$rc2->mExtra = $rc->mExtra;
return $rc2;
}
-} ;
+}
/**
* Class to show various lists of changes:
*/
class ChangesList {
# Called by history lists and recent changes
- #
/**
* Changeslist contructor
* @param Skin $skin
*/
- function __construct( &$skin ) {
+ public function __construct( &$skin ) {
$this->skin =& $skin;
$this->preCacheMessages();
}
* they are called often, we call them once and save them in $this->message
*/
private function preCacheMessages() {
- // Precache various messages
if( !isset( $this->message ) ) {
foreach( explode(' ', 'cur diff hist minoreditletter newpageletter last '.
'blocklink history boteditletter semicolon-separator' ) as $msg ) {
* @return string
*/
protected function recentChangesFlags( $new, $minor, $patrolled, $nothing = ' ', $bot = false ) {
- $f = $new ? '<span class="newpage">' . $this->message['newpageletter'] . '</span>'
- : $nothing;
- $f .= $minor ? '<span class="minor">' . $this->message['minoreditletter'] . '</span>'
- : $nothing;
+ $f = $new ?
+ '<span class="newpage">' . $this->message['newpageletter'] . '</span>' : $nothing;
+ $f .= $minor ?
+ '<span class="minor">' . $this->message['minoreditletter'] . '</span>' : $nothing;
$f .= $bot ? '<span class="bot">' . $this->message['boteditletter'] . '</span>' : $nothing;
$f .= $patrolled ? '<span class="unpatrolled">!</span>' : $nothing;
return $f;
# Hist
$s .= $this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), $this->message['hist'], 'action=history' ) .
') . . ';
-
# "[[x]] moved to [[y]]"
$msg = ( $rc->mAttribs['rc_type'] == RC_MOVE ) ? '1movedto2' : '1movedto2_redir';
$s .= wfMsg( $msg, $this->skin->makeKnownLinkObj( $rc->getTitle(), '', 'redirect=no' ),
$this->skin->makeKnownLinkObj( $rc->getMovedToTitle(), '' ) );
}
- protected function insertDateHeader(&$s, $rc_timestamp) {
+ protected function insertDateHeader( &$s, $rc_timestamp ) {
global $wgLang;
# Make date header if necessary
}
}
- protected function insertLog(&$s, $title, $logtype) {
+ protected function insertLog( &$s, $title, $logtype ) {
$logname = LogPage::logName( $logtype );
$s .= '(' . $this->skin->makeKnownLinkObj($title, $logname ) . ')';
}
- protected function insertDiffHist(&$s, &$rc, $unpatrolled) {
+ protected function insertDiffHist( &$s, &$rc, $unpatrolled ) {
# Diff link
if( !$this->userCan($rc,Revision::DELETED_TEXT) ) {
$diffLink = $this->message['diff'];
} else if( $rc->mAttribs['rc_type'] == RC_NEW || $rc->mAttribs['rc_type'] == RC_LOG ) {
$diffLink = $this->message['diff'];
} else {
- $rcidparam = $unpatrolled
- ? array( 'rcid' => $rc->mAttribs['rc_id'] )
- : array();
+ $rcidparam = $unpatrolled ?
+ array( 'rcid' => $rc->mAttribs['rc_id'] ) : array();
$diffLink = $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['diff'],
wfArrayToCGI( array(
'curid' => $rc->mAttribs['rc_cur_id'],
'', '', ' tabindex="'.$rc->counter.'"');
}
$s .= '('.$diffLink.') (';
-
# History link
$s .= $this->skin->makeKnownLinkObj( $rc->getTitle(), $this->message['hist'],
wfArrayToCGI( array(
$s .= ') . . ';
}
- protected function insertArticleLink(&$s, &$rc, $unpatrolled, $watched) {
- # Article link
+ protected function insertArticleLink( &$s, &$rc, $unpatrolled, $watched ) {
+ global $wgContLang;
# If it's a new article, there is no diff link, but if it hasn't been
# patrolled yet, we need to give users a way to do so
- $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW )
- ? 'rcid='.$rc->mAttribs['rc_id']
- : '';
+ $params = ( $unpatrolled && $rc->mAttribs['rc_type'] == RC_NEW ) ?
+ 'rcid='.$rc->mAttribs['rc_id'] : '';
if( $this->isDeleted($rc,Revision::DELETED_TEXT) ) {
$articlelink = $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
$articlelink = '<span class="history-deleted">'.$articlelink.'</span>';
} else {
$articlelink = ' '. $this->skin->makeKnownLinkObj( $rc->getTitle(), '', $params );
}
- if( $watched )
+ # Bolden pages watched by this user
+ if( $watched ) {
$articlelink = "<strong class=\"mw-watched\">{$articlelink}</strong>";
- global $wgContLang;
+ }
+ # RTL/LTR marker
$articlelink .= $wgContLang->getDirMark();
wfRunHooks('ChangesListInsertArticleLink',
array(&$this, &$articlelink, &$s, &$rc, $unpatrolled, $watched));
- $s .= ' '.$articlelink;
+ $s .= " $articlelink";
}
- protected function insertTimestamp(&$s, $rc) {
+ protected function insertTimestamp( &$s, $rc ) {
global $wgLang;
# Timestamp
$s .= $this->message['semicolon-separator'] . $wgLang->time( $rc->mAttribs['rc_timestamp'], true, true ) . ' . . ';
$opts->fetchValuesFromRequest( $wgRequest );
// Give precedence to subpage syntax
- if ( $parameters !== null ) {
+ if( $parameters !== null ) {
$this->parseParameters( $parameters, $opts );
}
}
foreach( $rows as $row ) {
- if ( !$feedFormat ) {
+ if( !$feedFormat ) {
// User page and talk links
$batch->add( NS_USER, $row->rc_user_text );
$batch->add( NS_USER_TALK, $row->rc_user_text );
}
}
- if ( $feedFormat ) {
+ if( $feedFormat ) {
list( $feed, $feedObj ) = $this->getFeedObject( $feedFormat );
$feed->execute( $feedObj, $rows, $opts['limit'], $opts['hideminor'], $lastmod );
} else {
*/
public function parseParameters( $par, FormOptions $opts ) {
$bits = preg_split( '/\s*,\s*/', trim( $par ) );
- foreach ( $bits as $bit ) {
- if ( 'hidebots' === $bit ) $opts['hidebots'] = true;
- if ( 'bots' === $bit ) $opts['hidebots'] = false;
- if ( 'hideminor' === $bit ) $opts['hideminor'] = true;
- if ( 'minor' === $bit ) $opts['hideminor'] = false;
- if ( 'hideliu' === $bit ) $opts['hideliu'] = true;
- if ( 'hidepatrolled' === $bit ) $opts['hidepatrolled'] = true;
- if ( 'hideanons' === $bit ) $opts['hideanons'] = true;
- if ( 'hidemyself' === $bit ) $opts['hidemyself'] = true;
-
- if ( is_numeric( $bit ) ) $opts['limit'] = $bit;
+ foreach( $bits as $bit ) {
+ if( 'hidebots' === $bit ) $opts['hidebots'] = true;
+ if( 'bots' === $bit ) $opts['hidebots'] = false;
+ if( 'hideminor' === $bit ) $opts['hideminor'] = true;
+ if( 'minor' === $bit ) $opts['hideminor'] = false;
+ if( 'hideliu' === $bit ) $opts['hideliu'] = true;
+ if( 'hidepatrolled' === $bit ) $opts['hidepatrolled'] = true;
+ if( 'hideanons' === $bit ) $opts['hideanons'] = true;
+ if( 'hidemyself' === $bit ) $opts['hidemyself'] = true;
+
+ if( is_numeric( $bit ) ) $opts['limit'] = $bit;
$m = array();
- if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) $opts['limit'] = $m[1];
- if ( preg_match( '/^days=(\d+)$/', $bit, $m ) ) $opts['days'] = $m[1];
+ if( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) $opts['limit'] = $m[1];
+ if( preg_match( '/^days=(\d+)$/', $bit, $m ) ) $opts['days'] = $m[1];
}
}
global $wgUseRCPatrol, $wgOut;
$dbr = wfGetDB( DB_SLAVE );
$lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __FUNCTION__ );
- if ( $feedFormat || !$wgUseRCPatrol ) {
+ if( $feedFormat || !$wgUseRCPatrol ) {
if( $lastmod && $wgOut->checkLastModified( $lastmod ) ){
# Client cache fresh and headers sent, nothing more to do.
return false;
$hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
$hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
- if ( $opts['hideminor'] ) $conds['rc_minor'] = 0;
- if ( $opts['hidebots'] ) $conds['rc_bot'] = 0;
- if ( $hidePatrol ) $conds['rc_patrolled'] = 0;
- if ( $forcebot ) $conds['rc_bot'] = 1;
- if ( $hideLoggedInUsers ) $conds[] = 'rc_user = 0';
- if ( $hideAnonymousUsers ) $conds[] = 'rc_user != 0';
+ if( $opts['hideminor'] ) $conds['rc_minor'] = 0;
+ if( $opts['hidebots'] ) $conds['rc_bot'] = 0;
+ if( $hidePatrol ) $conds['rc_patrolled'] = 0;
+ if( $forcebot ) $conds['rc_bot'] = 1;
+ if( $hideLoggedInUsers ) $conds[] = 'rc_user = 0';
+ if( $hideAnonymousUsers ) $conds[] = 'rc_user != 0';
if( $opts['hidemyself'] ) {
if( $wgUser->getId() ) {
}
# Namespace filtering
- if ( $opts['namespace'] !== '' ) {
- if ( !$opts['invert'] ) {
+ if( $opts['namespace'] !== '' ) {
+ if( !$opts['invert'] ) {
$conds[] = 'rc_namespace = ' . $dbr->addQuotes( $opts['namespace'] );
} else {
$conds[] = 'rc_namespace != ' . $dbr->addQuotes( $opts['namespace'] );
// JOIN on watchlist for users
if( $uid ) {
$tables[] = 'watchlist';
- $join_conds = array( 'watchlist' => array('LEFT JOIN',"wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace") );
+ $join_conds = array( 'watchlist' => array('LEFT JOIN',
+ "wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace") );
}
wfRunHooks('SpecialRecentChangesQuery', array( &$conds, &$tables, &$join_conds, $opts ) );
$limit = $opts['limit'];
- if ( !$this->including() ) {
+ if( !$this->including() ) {
// Output options box
$this->doHeader( $opts );
}
// And now for the content
$wgOut->setSyndicated( true );
- $list = ChangesList::newFromUser( $wgUser );
-
- if ( $wgAllowCategorizedRecentChanges ) {
+ if( $wgAllowCategorizedRecentChanges ) {
$this->filterByCategories( $rows, $opts );
}
- $s = $list->beginRecentChangesList();
- $counter = 1;
-
$showWatcherCount = $wgRCShowWatchingUsers && $wgUser->getOption( 'shownumberswatching' );
$watcherCache = array();
$dbr = wfGetDB( DB_SLAVE );
- foreach( $rows as $obj ){
- if( $limit == 0) {
+ $counter = 1;
+ $list = ChangesList::newFromUser( $wgUser );
+
+ $s = $list->beginRecentChangesList();
+ foreach( $rows as $obj ) {
+ if( $limit == 0 ) {
break;
}
+ $rc = RecentChange::newFromRow( $obj );
+ $rc->counter = $counter++;
- if ( ! ( $opts['hideminor'] && $obj->rc_minor ) &&
- ! ( $opts['hidepatrolled'] && $obj->rc_patrolled ) ) {
- $rc = RecentChange::newFromRow( $obj );
- $rc->counter = $counter++;
-
- if ($wgShowUpdatedMarker
- && !empty( $obj->wl_notificationtimestamp )
- && ($obj->rc_timestamp >= $obj->wl_notificationtimestamp)) {
- $rc->notificationtimestamp = true;
- } else {
- $rc->notificationtimestamp = false;
- }
+ $rc->notificationtimestamp = false; // Default
+ if( $wgShowUpdatedMarker && !empty($obj->wl_notificationtimestamp) ) {
+ $rc->notificationtimestamp = ($obj->rc_timestamp >= $obj->wl_notificationtimestamp);
+ }
- $rc->numberofWatchingusers = 0; // Default
- if ($showWatcherCount && $obj->rc_namespace >= 0) {
- if (!isset($watcherCache[$obj->rc_namespace][$obj->rc_title])) {
- $watcherCache[$obj->rc_namespace][$obj->rc_title] =
- $dbr->selectField( 'watchlist',
- 'COUNT(*)',
- array(
- 'wl_namespace' => $obj->rc_namespace,
- 'wl_title' => $obj->rc_title,
- ),
- __METHOD__ . '-watchers' );
- }
- $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
+ $rc->numberofWatchingusers = 0; // Default
+ if( $showWatcherCount && $obj->rc_namespace >= 0 ) {
+ if( !isset($watcherCache[$obj->rc_namespace][$obj->rc_title]) ) {
+ $watcherCache[$obj->rc_namespace][$obj->rc_title] =
+ $dbr->selectField( 'watchlist',
+ 'COUNT(*)',
+ array(
+ 'wl_namespace' => $obj->rc_namespace,
+ 'wl_title' => $obj->rc_title,
+ ),
+ __METHOD__ . '-watchers' );
}
- $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ) );
- --$limit;
+ $rc->numberofWatchingusers = $watcherCache[$obj->rc_namespace][$obj->rc_title];
}
+ $s .= $list->recentChangesLine( $rc, !empty( $obj->wl_user ) );
+ --$limit;
}
$s .= $list->endRecentChangesList();
$wgOut->addHTML( $s );
$submit = ' ' . Xml::submitbutton( wfMsg( 'allpagessubmit' ) );
$out = Xml::openElement( 'table', array( 'class' => 'mw-recentchanges-table' ) );
- foreach ( $extraOpts as $optionRow ) {
+ foreach( $extraOpts as $optionRow ) {
# Add submit button to the last row only
++$count;
$addSubmit = $count === $extraOptsCount ? $submit : '';
$out .= Xml::openElement( 'tr' );
- if ( is_array( $optionRow ) ) {
+ if( is_array( $optionRow ) ) {
$out .= Xml::tags( 'td', array( 'class' => 'mw-label' ), $optionRow[0] );
$out .= Xml::tags( 'td', array( 'class' => 'mw-input' ), $optionRow[1] . $addSubmit );
} else {
$out .= Xml::closeElement( 'table' );
$unconsumed = $opts->getUnconsumedValues();
- foreach ( $unconsumed as $key => $value ) {
+ foreach( $unconsumed as $key => $value ) {
$out .= Xml::hidden( $key, $value );
}
$extraOpts['namespace'] = $this->namespaceFilterForm( $opts );
global $wgAllowCategorizedRecentChanges;
- if ( $wgAllowCategorizedRecentChanges ) {
+ if( $wgAllowCategorizedRecentChanges ) {
$extraOpts['category'] = $this->categoryFilterForm( $opts );
}
# Filter categories
$cats = array();
- foreach ( $categories as $cat ) {
+ foreach( $categories as $cat ) {
$cat = trim( $cat );
- if ( $cat == "" ) continue;
+ if( $cat == "" ) continue;
$cats[] = $cat;
}
# Filter articles
$articles = array();
$a2r = array();
- foreach ( $rows AS $k => $r ) {
+ foreach( $rows AS $k => $r ) {
$nt = Title::makeTitle( $r->rc_namespace, $r->rc_title );
$id = $nt->getArticleID();
- if ( $id == 0 ) continue; # Page might have been deleted...
- if ( !in_array($id, $articles) ) {
+ if( $id == 0 ) continue; # Page might have been deleted...
+ if( !in_array($id, $articles) ) {
$articles[] = $id;
}
- if ( !isset($a2r[$id]) ) {
+ if( !isset($a2r[$id]) ) {
$a2r[$id] = array();
}
$a2r[$id][] = $k;
}
# Shortcut?
- if ( !count($articles) || !count($cats) )
+ if( !count($articles) || !count($cats) )
return ;
# Look up
# Filter
$newrows = array();
- foreach ( $match AS $id ) {
- foreach ( $a2r[$id] AS $rev ) {
+ foreach( $match AS $id ) {
+ foreach( $a2r[$id] AS $rev ) {
$k = $rev;
$newrows[$k] = $rows[$k];
}