* http://www.gnu.org/copyleft/gpl.html
*
* @file
- * @ingroup SpecialPage Watchlist
+ * @ingroup SpecialPage
*/
-class SpecialWatchlist extends SpecialRecentChanges {
- protected $customFilters;
+/**
+ * A special page that lists last changes made to the wiki,
+ * limited to user-defined list of titles.
+ *
+ * @ingroup SpecialPage
+ */
+class SpecialWatchlist extends ChangesListSpecialPage {
/**
* Constructor
*/
parent::__construct( $page, $restriction );
}
- public function isIncludable() {
- return false;
+ /**
+ * Main execution point
+ *
+ * @param string $subpage
+ */
+ function execute( $subpage ) {
+ global $wgEnotifWatchlist, $wgShowUpdatedMarker;
+
+ // Anons don't get a watchlist
+ $this->requireLogin( 'watchlistanontext' );
+
+ $output = $this->getOutput();
+ $request = $this->getRequest();
+
+ $mode = SpecialEditWatchlist::getMode( $request, $subpage );
+ if ( $mode !== false ) {
+ if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
+ $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
+ } else {
+ $title = SpecialPage::getTitleFor( 'EditWatchlist' );
+ }
+
+ $output->redirect( $title->getLocalURL() );
+ return;
+ }
+
+ $this->checkPermissions();
+
+ $user = $this->getUser();
+ $opts = $this->getOptions();
+
+ if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
+ $request->wasPosted() )
+ {
+ $user->clearAllNotifications();
+ $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
+ return;
+ }
+
+ parent::execute( $subpage );
}
/**
$opts = parent::getDefaultOptions();
$user = $this->getUser();
- // Overwrite RC options with Watchlist options
- // (calling #add() again is okay)
$opts->add( 'days', $user->getOption( 'watchlistdays' ), FormOptions::FLOAT );
+
$opts->add( 'hideminor', $user->getBoolOption( 'watchlisthideminor' ) );
$opts->add( 'hidebots', $user->getBoolOption( 'watchlisthidebots' ) );
$opts->add( 'hideanons', $user->getBoolOption( 'watchlisthideanons' ) );
$opts->add( 'hidepatrolled', $user->getBoolOption( 'watchlisthidepatrolled' ) );
$opts->add( 'hidemyself', $user->getBoolOption( 'watchlisthideown' ) );
- // Add new ones
$opts->add( 'extended', $user->getBoolOption( 'extendwatchlist' ) );
return $opts;
}
+ /**
+ * Get custom show/hide filters
+ *
+ * @return array Map of filter URL param names to properties (msg/default)
+ */
+ protected function getCustomFilters() {
+ if ( $this->customFilters === null ) {
+ $this->customFilters = array();
+ wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
+ }
+
+ return $this->customFilters;
+ }
+
/**
* Fetch values for a FormOptions object from the WebRequest associated with this instance.
*
return $opts;
}
- /**
- * Get custom show/hide filters
- *
- * @return array Map of filter URL param names to properties (msg/default)
- */
- protected function getCustomFilters() {
- if ( $this->customFilters === null ) {
- $this->customFilters = array();
- wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
- }
-
- return $this->customFilters;
- }
-
- /**
- * Process $par and put options found if $opts. Not used for Watchlist.
- *
- * @param string $par
- * @param FormOptions $opts
- */
- public function parseParameters( $par, FormOptions $opts ) {
- }
-
- /**
- * Get the current FormOptions for this request
- */
- public function getOptions() {
- if ( $this->rcOptions === null ) {
- $this->rcOptions = $this->setup( null );
- }
-
- return $this->rcOptions;
- }
-
- /**
- * Execute
- * @param $par Parameter passed to the page
- */
- function execute( $par ) {
- global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
-
- $user = $this->getUser();
- $output = $this->getOutput();
-
- # Anons don't get a watchlist
- $this->requireLogin( 'watchlistanontext' );
-
- // Check permissions
- $this->checkPermissions();
-
- $request = $this->getRequest();
- $opts = $this->getOptions();
-
- $mode = SpecialEditWatchlist::getMode( $request, $par );
- if ( $mode !== false ) {
- if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
- $title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
- } else {
- $title = SpecialPage::getTitleFor( 'EditWatchlist' );
- }
-
- $output->redirect( $title->getLocalURL() );
- return;
- }
-
- if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
- $request->wasPosted() )
- {
- $user->clearAllNotifications();
- $output->redirect( $this->getPageTitle()->getFullURL( $opts->getChangedValues() ) );
- return;
- }
-
- $this->setHeaders();
- $this->outputHeader();
- $this->addModules();
-
- $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
-
- $this->numItems = $this->countItems( $dbr ); // TODO kill me
- if ( $this->numItems == 0 ) {
- $output->addWikiMsg( 'nowatchlist' );
- return;
- }
-
- // Fetch results, prepare a batch link existence check query
- $conds = $this->buildMainQueryConds( $opts );
- $rows = $this->doMainQuery( $conds, $opts );
- $this->numRows = $rows->numRows(); // TODO kill me
- 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();
- }
-
/**
* Return an array of conditions depending of options set in $opts
*
/**
* 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 ) {
}
}
- function setTopText( FormOptions $opts ) {
- global $wgEnotifWatchlist, $wgShowUpdatedMarker;
-
- $nondefaults = $opts->getChangedValues();
- $form = "";
- $user = $this->getUser();
-
- # Show watchlist header
- $form .= "<p>";
- $form .= $this->msg( 'watchlist-details' )->numParams( $this->numItems )->parse() . "\n";
- if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) {
- $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
- }
- if ( $wgShowUpdatedMarker ) {
- $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
- }
- $form .= "</p>";
-
- if ( $wgShowUpdatedMarker ) {
- $form .= Xml::openElement( 'form', array( 'method' => 'post',
- 'action' => $this->getPageTitle()->getLocalURL(),
- 'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
- Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" .
- Html::hidden( 'reset', 'all' ) . "\n";
- foreach ( $nondefaults as $key => $value ) {
- $form .= Html::hidden( $key, $value ) . "\n";
- }
- $form .= Xml::closeElement( 'form' ) . "\n";
- }
-
- $form .= Xml::openElement( 'form', array(
- 'method' => 'post',
- 'action' => $this->getPageTitle()->getLocalURL(),
- 'id' => 'mw-watchlist-form'
- ) );
- $form .= Xml::fieldset(
- $this->msg( 'watchlist-options' )->text(),
- false,
- array( 'id' => 'mw-watchlist-options' )
- );
-
- $form .= SpecialRecentChanges::makeLegend( $this->getContext() );
-
- $this->getOutput()->addHTML( $form );
- }
-
/**
* Return the text to be displayed above the changes
*
* @return string XHTML
*/
public function doHeader( $opts ) {
- global $wgScript;
-
$user = $this->getUser();
$this->setTopText( $opts );
$wlInfo = '';
if ( $opts['days'] > 0 ) {
$timestamp = wfTimestampNow();
- $wlInfo = $this->msg( 'wlnote' )->numParams( $this->numRows, round( $opts['days'] * 24 ) )->params(
+ $wlInfo = $this->msg( 'wlnote2' )->numParams( round( $opts['days'] * 24 ) )->params(
$lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "<br />\n";
}
$this->setBottomText( $opts );
}
+ function setTopText( FormOptions $opts ) {
+ global $wgEnotifWatchlist, $wgShowUpdatedMarker;
+
+ $nondefaults = $opts->getChangedValues();
+ $form = "";
+ $user = $this->getUser();
+
+ $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
+ $numItems = $this->countItems( $dbr );
+
+ // Show watchlist header
+ $form .= "<p>";
+ if ( $numItems == 0 ) {
+ $form .= $this->msg( 'nowatchlist' )->parse() . "\n";
+ } else {
+ $form .= $this->msg( 'watchlist-details' )->numParams( $numItems )->parse() . "\n";
+ if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) {
+ $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
+ }
+ if ( $wgShowUpdatedMarker ) {
+ $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
+ }
+ }
+ $form .= "</p>";
+
+ if ( $numItems > 0 && $wgShowUpdatedMarker ) {
+ $form .= Xml::openElement( 'form', array( 'method' => 'post',
+ 'action' => $this->getPageTitle()->getLocalURL(),
+ 'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
+ Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . "\n" .
+ Html::hidden( 'reset', 'all' ) . "\n";
+ foreach ( $nondefaults as $key => $value ) {
+ $form .= Html::hidden( $key, $value ) . "\n";
+ }
+ $form .= Xml::closeElement( 'form' ) . "\n";
+ }
+
+ $form .= Xml::openElement( 'form', array(
+ 'method' => 'post',
+ 'action' => $this->getPageTitle()->getLocalURL(),
+ 'id' => 'mw-watchlist-form'
+ ) );
+ $form .= Xml::fieldset(
+ $this->msg( 'watchlist-options' )->text(),
+ false,
+ array( 'id' => 'mw-watchlist-options' )
+ );
+
+ $form .= SpecialRecentChanges::makeLegend( $this->getContext() );
+
+ $this->getOutput()->addHTML( $form );
+ }
+
protected function showHideLink( $options, $message, $name, $value ) {
$label = $this->msg( $value ? 'show' : 'hide' )->escaped();
$options[$name] = 1 - (int)$value;