var $rcSubpage, $rcOptions; // @todo Rename these, make protected
protected $customFilters;
+ /**
+ * The feed format to output as (either 'rss' or 'atom'), or null if no
+ * feed output was requested
+ *
+ * @var string $feedFormat
+ */
+ protected $feedFormat;
+
/**
* Main execution point
- * @todo This should totally do things
*
* @param string $subpage
*/
public function execute( $subpage ) {
$this->rcSubpage = $subpage;
- throw new MWException( "Not implemented" );
+ $this->feedFormat = $this->including() ? null : $this->getRequest()->getVal( 'feed' );
+ if ( $this->feedFormat !== 'atom' && $this->feedFormat !== 'rss' ) {
+ $this->feedFormat = null;
+ }
+
+ $this->setHeaders();
+ $this->outputHeader();
+ $this->addModules();
+
+ $opts = $this->getOptions();
+ // 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, $this->checkLastModified( $this->feedFormat ), $opts );
+ } else {
+ $this->webOutput( $rows, $opts );
+ }
+
+ $rows->free();
}
/**
* Get the current FormOptions for this request
- * @todo Not called by anything, should be called by execute()
*
* @return FormOptions
*/
/**
* Return an array of conditions depending of options set in $opts
* @todo This should build some basic conditions here…
- * @todo Not called by anything, should be called by execute()
*
* @param FormOptions $opts
* @return array
/**
* Process the query
* @todo This should build some basic processing here…
- * @todo Not called by anything, should be called by execute()
*
* @param array $conds
* @param FormOptions $opts
/**
* Send output to the OutputPage object, only called if not used feeds
* @todo This should do most, if not all, of the outputting now done by subclasses
- * @todo Not called by anything, should be called by execute()
*
- * @param array $rows Database rows
+ * @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
abstract public function webOutput( $rows, $opts );
/**
* Add page-specific modules.
- * @todo Not called by anything, should be called by execute()
*/
protected function addModules() {
$out = $this->getOutput();
$out->addModules( 'mediawiki.special.changeslist.legend.js' );
}
+ /**
+ * Return an array with a ChangesFeed object and ChannelFeed object.
+ *
+ * This is intentionally not abstract not to require subclasses which don't
+ * use feeds functionality to implement it.
+ *
+ * @param string $feedFormat Feed's format (either 'rss' or 'atom')
+ * @return array
+ */
+ public function getFeedObject( $feedFormat ) {
+ throw new MWException( "Not implemented" );
+ }
+
+ /**
+ * Get last-modified date, for client caching. Not implemented by default
+ * (returns current time).
+ *
+ * @param string $feedFormat
+ * @return string|bool
+ */
+ public function checkLastModified( $feedFormat ) {
+ return wfTimestampNow();
+ }
+
protected function getGroupName() {
return 'changes';
}
* @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 );
* @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
+ // 10 seconds server-side caching max
$this->getOutput()->setSquidMaxage( 10 );
- # Check if the client has a cached version
+ // 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();
+ parent::execute( $subpage );
}
/**
}
/**
- * Return an array with a ChangesFeed object and ChannelFeed object
+ * Return an array with a ChangesFeed object and ChannelFeed object.
*
* @param string $feedFormat Feed's format (either 'rss' or 'atom')
* @return array
/**
* 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 ) {
* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup SpecialPage Watchlist
+ * @ingroup SpecialPage
+ */
+
+/**
+ * A special page that lists last changes made to the wiki,
+ * limited to user-defined list of titles.
+ *
+ * @ingroup SpecialPage
*/
class SpecialWatchlist extends ChangesListSpecialPage {
/**
}
/**
- * Execute
- * @param $par Parameter passed to the page
+ * Main execution point
+ *
+ * @param string $subpage
*/
- function execute( $par ) {
+ function execute( $subpage ) {
global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
- $user = $this->getUser();
- $output = $this->getOutput();
-
- # Anons don't get a watchlist
+ // Anons don't get a watchlist
$this->requireLogin( 'watchlistanontext' );
- // Check permissions
- $this->checkPermissions();
-
+ $output = $this->getOutput();
$request = $this->getRequest();
- $opts = $this->getOptions();
- $mode = SpecialEditWatchlist::getMode( $request, $par );
+ $mode = SpecialEditWatchlist::getMode( $request, $subpage );
if ( $mode !== false ) {
if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
$title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
return;
}
+ $this->checkPermissions();
+
+ $user = $this->getUser();
+ $opts = $this->getOptions();
+
if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
$request->wasPosted() )
{
return;
}
- $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 ) {
- $this->doHeader( $opts );
-
- return;
- }
-
- $feedFormat = $this->getRequest()->getVal( 'feed' );
- if ( !$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 ( $feedFormat ) {
- list( $changesFeed, $formatter ) = $this->getFeedObject( $feedFormat );
- /** @var ChangesFeed $changesFeed */
- $changesFeed->execute( $formatter, $rows, $lastmod, $opts );
- } else {
- $this->webOutput( $rows, $opts );
- }
-
- $rows->free();
+ parent::execute( $subpage );
}
/**
/**
* Send output to the OutputPage object, only called if not used feeds
*
- * @param array $rows Database rows
+ * @param ResultWrapper $rows Database rows
* @param FormOptions $opts
*/
public function webOutput( $rows, $opts ) {