* @ingroup SpecialPage
*/
class SpecialRecentChanges extends ChangesListSpecialPage {
- /**
- * The feed format to output as (either 'rss' or 'atom'), or null if no
- * feed output was requested
- *
- * @var string $feedFormat
- */
- protected $feedFormat;
public function __construct( $name = 'Recentchanges', $restriction = '' ) {
parent::__construct( $name, $restriction );
}
- public function isIncludable() {
- return true;
+ /**
+ * Main execution point
+ *
+ * @param string $subpage
+ */
+ public function execute( $subpage ) {
+ // 10 seconds server-side caching max
+ $this->getOutput()->setSquidMaxage( 10 );
+ // Check if the client has a cached version
+ $lastmod = $this->checkLastModified( $this->feedFormat );
+ if ( $lastmod === false ) {
+ return;
+ }
+
+ parent::execute( $subpage );
}
/**
return $opts;
}
- public function validateOptions( FormOptions $opts ) {
- global $wgFeedLimit;
- $opts->validateIntBounds( 'limit', 0, $this->feedFormat ? $wgFeedLimit : 5000 );
- }
-
/**
* Get custom show/hide filters
*
return $this->customFilters;
}
- /**
- * Main execution point
- *
- * @param string $subpage
- */
- public function execute( $subpage ) {
- $this->rcSubpage = $subpage;
- $this->feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
-
- # 10 seconds server-side caching max
- $this->getOutput()->setSquidMaxage( 10 );
- # Check if the client has a cached version
- $lastmod = $this->checkLastModified( $this->feedFormat );
- if ( $lastmod === false ) {
- return;
- }
-
- $opts = $this->getOptions();
- $this->setHeaders();
- $this->outputHeader();
- $this->addModules();
-
- // Fetch results, prepare a batch link existence check query
- $conds = $this->buildMainQueryConds( $opts );
- $rows = $this->doMainQuery( $conds, $opts );
- if ( $rows === false ) {
- if ( !$this->including() ) {
- $this->doHeader( $opts );
- }
-
- return;
- }
-
- if ( !$this->feedFormat ) {
- $batch = new LinkBatch;
- foreach ( $rows as $row ) {
- $batch->add( NS_USER, $row->rc_user_text );
- $batch->add( NS_USER_TALK, $row->rc_user_text );
- $batch->add( $row->rc_namespace, $row->rc_title );
- }
- $batch->execute();
- }
- if ( $this->feedFormat ) {
- list( $changesFeed, $formatter ) = $this->getFeedObject( $this->feedFormat );
- /** @var ChangesFeed $changesFeed */
- $changesFeed->execute( $formatter, $rows, $lastmod, $opts );
- } else {
- $this->webOutput( $rows, $opts );
- }
-
- $rows->free();
- }
-
- /**
- * Return an array with a ChangesFeed object and ChannelFeed object
- *
- * @param string $feedFormat Feed's format (either 'rss' or 'atom')
- * @return array
- */
- public function getFeedObject( $feedFormat ) {
- $changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' );
- $formatter = $changesFeed->getFeedObject(
- $this->msg( 'recentchanges' )->inContentLanguage()->text(),
- $this->msg( 'recentchanges-feed-description' )->inContentLanguage()->text(),
- $this->getPageTitle()->getFullURL()
- );
-
- return array( $changesFeed, $formatter );
- }
-
/**
* Process $par and put options found in $opts. Used when including the page.
*
}
}
- /**
- * Get last modified date, for client caching
- * Don't use this if we are using the patrol feature, patrol changes don't
- * update the timestamp
- *
- * @param string $feedFormat
- * @return string|bool
- */
- public function checkLastModified( $feedFormat ) {
- $dbr = wfGetDB( DB_SLAVE );
- $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
- if ( $feedFormat || !$this->getUser()->useRCPatrol() ) {
- if ( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
- # Client cache fresh and headers sent, nothing more to do.
- return false;
- }
- }
-
- return $lastmod;
+ public function validateOptions( FormOptions $opts ) {
+ global $wgFeedLimit;
+ $opts->validateIntBounds( 'limit', 0, $this->feedFormat ? $wgFeedLimit : 5000 );
}
/**
}
}
- /**
- * Get the query string to append to feed link URLs.
- *
- * @return string
- */
- public function getFeedQuery() {
- global $wgFeedLimit;
-
- $this->getOptions()->validateIntBounds( 'limit', 0, $wgFeedLimit );
- $options = $this->getOptions()->getChangedValues();
-
- // wfArrayToCgi() omits options set to null or false
- foreach ( $options as &$value ) {
- if ( $value === false ) {
- $value = '0';
- }
- }
- unset( $value );
-
- return wfArrayToCgi( $options );
- }
-
/**
* Return the text to be displayed above the changes
*
$this->setBottomText( $opts );
}
+ /**
+ * Send the text to be displayed above the options
+ *
+ * @param FormOptions $opts Unused
+ */
+ function setTopText( FormOptions $opts ) {
+ global $wgContLang;
+
+ $message = $this->msg( 'recentchangestext' )->inContentLanguage();
+ if ( !$message->isDisabled() ) {
+ $this->getOutput()->addWikiText(
+ Html::rawElement( 'p',
+ array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
+ "\n" . $message->plain() . "\n"
+ ),
+ /* $lineStart */ false,
+ /* $interface */ false
+ );
+ }
+ }
+
/**
* Get options to be displayed in a form
*
}
/**
- * Send the text to be displayed above the options
+ * Add page-specific modules.
+ */
+ protected function addModules() {
+ parent::addModules();
+ $out = $this->getOutput();
+ $out->addModules( 'mediawiki.special.recentchanges' );
+ }
+
+ /**
+ * Get last modified date, for client caching
+ * Don't use this if we are using the patrol feature, patrol changes don't
+ * update the timestamp
*
- * @param FormOptions $opts Unused
+ * @param string $feedFormat
+ * @return string|bool
*/
- function setTopText( FormOptions $opts ) {
- global $wgContLang;
+ public function checkLastModified( $feedFormat ) {
+ $dbr = wfGetDB( DB_SLAVE );
+ $lastmod = $dbr->selectField( 'recentchanges', 'MAX(rc_timestamp)', false, __METHOD__ );
+ if ( $feedFormat || !$this->getUser()->useRCPatrol() ) {
+ if ( $lastmod && $this->getOutput()->checkLastModified( $lastmod ) ) {
+ # Client cache fresh and headers sent, nothing more to do.
+ return false;
+ }
+ }
- $message = $this->msg( 'recentchangestext' )->inContentLanguage();
- if ( !$message->isDisabled() ) {
- $this->getOutput()->addWikiText(
- Html::rawElement( 'p',
- array( 'lang' => $wgContLang->getCode(), 'dir' => $wgContLang->getDir() ),
- "\n" . $message->plain() . "\n"
- ),
- /* $lineStart */ false,
- /* $interface */ false
- );
+ return $lastmod;
+ }
+
+ /**
+ * Return an array with a ChangesFeed object and ChannelFeed object.
+ *
+ * @param string $feedFormat Feed's format (either 'rss' or 'atom')
+ * @return array
+ */
+ public function getFeedObject( $feedFormat ) {
+ $changesFeed = new ChangesFeed( $feedFormat, 'rcfeed' );
+ $formatter = $changesFeed->getFeedObject(
+ $this->msg( 'recentchanges' )->inContentLanguage()->text(),
+ $this->msg( 'recentchanges-feed-description' )->inContentLanguage()->text(),
+ $this->getPageTitle()->getFullURL()
+ );
+
+ return array( $changesFeed, $formatter );
+ }
+
+ /**
+ * Get the query string to append to feed link URLs.
+ *
+ * @return string
+ */
+ public function getFeedQuery() {
+ global $wgFeedLimit;
+
+ $this->getOptions()->validateIntBounds( 'limit', 0, $wgFeedLimit );
+ $options = $this->getOptions()->getChangedValues();
+
+ // wfArrayToCgi() omits options set to null or false
+ foreach ( $options as &$value ) {
+ if ( $value === false ) {
+ $value = '0';
+ }
}
+ unset( $value );
+
+ return wfArrayToCgi( $options );
}
/**
/**
* Filter $rows by categories set in $opts
*
- * @param array $rows Database rows
+ * @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
function filterByCategories( &$rows, FormOptions $opts ) {
return "{$note}$rclinks<br />$rclistfrom";
}
- /**
- * Add page-specific modules.
- */
- protected function addModules() {
- parent::addModules();
- $out = $this->getOutput();
- $out->addModules( 'mediawiki.special.recentchanges' );
+ public function isIncludable() {
+ return true;
}
}