* @return FormOptions
*/
public function setup( $parameters ) {
- global $wgRequest;
-
$opts = $this->getDefaultOptions();
$this->customFilters = array();
$opts->add( $key, $params['default'] );
}
- $opts->fetchValuesFromRequest( $wgRequest );
+ $opts->fetchValuesFromRequest( $this->getRequest() );
// Give precedence to subpage syntax
if( $parameters !== null ) {
* @return FormOptions
*/
public function feedSetup() {
- global $wgFeedLimit, $wgRequest;
+ global $wgFeedLimit;
$opts = $this->getDefaultOptions();
# Feed is cached on limit,hideminor,namespace; other params would randomly not work
- $opts->fetchValuesFromRequest( $wgRequest, array( 'limit', 'hideminor', 'namespace' ) );
+ $opts->fetchValuesFromRequest( $this->getRequest(), array( 'limit', 'hideminor', 'namespace' ) );
$opts->validateIntBounds( 'limit', 0, $wgFeedLimit );
return $opts;
}
*/
public function getOptions() {
if ( $this->rcOptions === null ) {
- global $wgRequest;
- $feedFormat = $wgRequest->getVal( 'feed' );
- $this->rcOptions = $feedFormat ? $this->feedSetup() : $this->setup( $this->rcSubpage );
+ if ( $this->including() ) {
+ $isFeed = false;
+ } else {
+ $isFeed = (bool)$this->getRequest()->getVal( 'feed' );
+ }
+ $this->rcOptions = $isFeed ? $this->feedSetup() : $this->setup( $this->rcSubpage );
}
return $this->rcOptions;
}
* @param $subpage String
*/
public function execute( $subpage ) {
- global $wgRequest, $wgOut;
$this->rcSubpage = $subpage;
- $feedFormat = $wgRequest->getVal( 'feed' );
+ $feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
# 10 seconds server-side caching max
- $wgOut->setSquidMaxage( 10 );
+ $this->getOutput()->setSquidMaxage( 10 );
# Check if the client has a cached version
$lastmod = $this->checkLastModified( $feedFormat );
if( $lastmod === false ) {
$opts = $this->getOptions();
$this->setHeaders();
$this->outputHeader();
+ $this->addRecentChangesJS();
// Fetch results, prepare a batch link existence check query
$conds = $this->buildMainQueryConds( $opts );
if( preg_match( '/^days=(\d+)$/', $bit, $m ) ) {
$opts['days'] = $m[1];
}
+ if( preg_match( '/^namespace=(\d+)$/', $bit, $m ) ) {
+ $opts['namespace'] = $m[1];
+ }
}
}
$conds[] = 'rc_timestamp >= ' . $dbr->addQuotes( $cutoff );
-
$hidePatrol = $this->getUser()->useRCPatrol() && $opts['hidepatrolled'];
$hideLoggedInUsers = $opts['hideliu'] && !$forcebot;
$hideAnonymousUsers = $opts['hideanons'] && !$forcebot;
# Namespace filtering
if( $opts['namespace'] !== '' ) {
- $namespaces[] = $opts['namespace'];
+ $selectedNS = $dbr->addQuotes( $opts['namespace'] );
+ $operator = $opts['invert'] ? '!=' : '=';
+ $boolean = $opts['invert'] ? 'AND' : 'OR';
- $inversionSuffix = $opts['invert'] ? '!' : '';
-
- if( $opts['associated'] ) {
- # namespace association (bug 2429)
- $namespaces[] = MWNamespace::getAssociated( $opts['namespace'] );
+ # namespace association (bug 2429)
+ if( !$opts['associated'] ) {
+ $condition = "rc_namespace $operator $selectedNS";
+ } else {
+ # Also add the associated namespace
+ $associatedNS = $dbr->addQuotes(
+ MWNamespace::getAssociated( $opts['namespace'] )
+ );
+ $condition = "(rc_namespace $operator $selectedNS "
+ . $boolean
+ . " rc_namespace $operator $associatedNS)";
}
- $condition = $dbr->makeList(
- array( 'rc_namespace' . $inversionSuffix
- => $namespaces ),
- LIST_AND
- );
-
$conds[] = $condition;
}
-
return $conds;
}
}
/**
- * Send output to $wgOut, only called if not used feeds
+ * Send output to the OutputPage object, only called if not used feeds
*
* @param $rows Array of database rows
* @param $opts FormOptions
*/
public function webOutput( $rows, $opts ) {
- global $wgOut, $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
- global $wgAllowCategorizedRecentChanges;
+ global $wgRCShowWatchingUsers, $wgShowUpdatedMarker, $wgAllowCategorizedRecentChanges;
$limit = $opts['limit'];
}
// And now for the content
- $wgOut->setFeedAppendQuery( $this->getFeedQuery() );
+ $this->getOutput()->setFeedAppendQuery( $this->getFeedQuery() );
if( $wgAllowCategorizedRecentChanges ) {
$this->filterByCategories( $rows, $opts );
$dbr = wfGetDB( DB_SLAVE );
$counter = 1;
- $list = ChangesList::newFromUser( $this->getUser() );
+ $list = ChangesList::newFromContext( $this->getContext() );
$s = $list->beginRecentChangesList();
foreach( $rows as $obj ) {
--$limit;
}
$s .= $list->endRecentChangesList();
- $wgOut->addHTML( $s );
+ $this->getOutput()->addHTML( $s );
}
/**
* @return String: XHTML
*/
public function doHeader( $opts ) {
- global $wgScript, $wgOut;
+ global $wgScript;
- $this->setTopText( $wgOut, $opts );
+ $this->setTopText( $opts );
$defaults = $opts->getAllValues();
$nondefaults = $opts->getChangedValues();
$panel[] = $form;
$panelString = implode( "\n", $panel );
- $wgOut->addHTML(
+ $this->getOutput()->addHTML(
Xml::fieldset( wfMsg( 'recentchanges-legend' ), $panelString, array( 'class' => 'rcoptions' ) )
);
- $this->setBottomText( $wgOut, $opts );
+ $this->setBottomText( $opts );
}
/**
/**
* Send the text to be displayed above the options
*
- * @param $out OutputPage
* @param $opts FormOptions
*/
- function setTopText( OutputPage $out, FormOptions $opts ) {
- $out->addWikiText( wfMsgForContentNoTrans( 'recentchangestext' ) );
+ function setTopText( FormOptions $opts ) {
+ global $wgContLang;
+ $this->getOutput()->addWikiText(
+ Html::rawElement( 'p',
+ array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
+ wfMsgForContentNoTrans( 'recentchangestext' )
+ ), false );
}
/**
* Send the text to be displayed after the options, for use in
* Recentchangeslinked
*
- * @param $out OutputPage
* @param $opts FormOptions
*/
- function setBottomText( OutputPage $out, FormOptions $opts ) {}
+ function setBottomText( FormOptions $opts ) {}
/**
* Creates the choose namespace selection
*/
function makeOptionsLink( $title, $override, $options, $active = false ) {
$params = $override + $options;
+ $text = htmlspecialchars( $title );
if ( $active ) {
- return $this->getSkin()->link(
- $this->getTitle(),
- '<strong>' . htmlspecialchars( $title ) . '</strong>',
- array(), $params, array( 'known' ) );
- } else {
- return $this->getSkin()->link(
- $this->getTitle(), htmlspecialchars( $title ), array(),
- $params, array( 'known' ) );
+ $text = '<strong>' . $text . '</strong>';
}
+ return Linker::linkKnown( $this->getTitle(), $text, array(), $params );
}
/**
* @param $nondefaults Array
*/
function optionsPanel( $defaults, $nondefaults ) {
- global $wgLang, $wgRCLinkLimits, $wgRCLinkDays;
+ global $wgRCLinkLimits, $wgRCLinkDays;
$options = $nondefaults + $defaults;
}
if( $options['from'] ) {
$note .= wfMsgExt( 'rcnotefrom', array( 'parseinline' ),
- $wgLang->formatNum( $options['limit'] ),
- $wgLang->timeanddate( $options['from'], true ),
- $wgLang->date( $options['from'], true ),
- $wgLang->time( $options['from'], true ) ) . '<br />';
+ $this->getLanguage()->formatNum( $options['limit'] ),
+ $this->getLanguage()->timeanddate( $options['from'], true ),
+ $this->getLanguage()->date( $options['from'], true ),
+ $this->getLanguage()->time( $options['from'], true ) ) . '<br />';
}
# Sort data for display and make sure it's unique after we've added user data.
// limit links
foreach( $wgRCLinkLimits as $value ) {
- $cl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
+ $cl[] = $this->makeOptionsLink( $this->getLanguage()->formatNum( $value ),
array( 'limit' => $value ), $nondefaults, $value == $options['limit'] );
}
- $cl = $wgLang->pipeList( $cl );
+ $cl = $this->getLanguage()->pipeList( $cl );
// day links, reset 'from' to none
foreach( $wgRCLinkDays as $value ) {
- $dl[] = $this->makeOptionsLink( $wgLang->formatNum( $value ),
+ $dl[] = $this->makeOptionsLink( $this->getLanguage()->formatNum( $value ),
array( 'days' => $value, 'from' => '' ), $nondefaults, $value == $options['days'] );
}
- $dl = $wgLang->pipeList( $dl );
+ $dl = $this->getLanguage()->pipeList( $dl );
// show/hide links
// show from this onward link
$timestamp = wfTimestampNow();
- $now = $wgLang->timeanddate( $timestamp, true );
+ $now = $this->getLanguage()->timeanddate( $timestamp, true );
$tl = $this->makeOptionsLink(
$now, array( 'from' => $timestamp ), $nondefaults
);
$rclinks = wfMsgExt( 'rclinks', array( 'parseinline', 'replaceafter' ),
- $cl, $dl, $wgLang->pipeList( $links ) );
+ $cl, $dl, $this->getLanguage()->pipeList( $links ) );
$rclistfrom = wfMsgExt( 'rclistfrom', array( 'parseinline', 'replaceafter' ), $tl );
return "{$note}$rclinks<br />$rclistfrom";
}
+
+ /**
+ * add javascript specific to the [[Special:RecentChanges]] page
+ */
+ function addRecentChangesJS() {
+ $this->getOutput()->addModules( array(
+ 'mediawiki.special.recentchanges',
+ ) );
+ }
}