/**
  * The main entry point for the page.
  *
  * @param int $mode Whether the user is viewing, editing, or clearing their
  *  watchlist
  */
 public function execute($mode)
 {
     // Anons don't get a watchlist edit
     $this->requireLogin('mobile-frontend-watchlist-purpose');
     $out = $this->getOutput();
     // turn off #bodyContent element
     $out->setProperty('unstyledContent', true);
     parent::execute($mode);
     $out->setPageTitle($this->msg('watchlist'));
 }
 /**
  * Main execution point
  *
  * @param $mode int
  */
 public function execute($mode)
 {
     $this->setHeaders();
     $out = $this->getOutput();
     # Anons don't get a watchlist
     if ($this->getUser()->isAnon()) {
         $out->setPageTitle($this->msg('watchnologin'));
         $llink = Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), $this->msg('loginreqlink')->escaped(), array(), array('returnto' => $this->getTitle()->getPrefixedText()));
         $out->addHTML($this->msg('watchlistanontext')->rawParams($llink)->parse());
         return;
     }
     $this->checkPermissions();
     $this->checkReadOnly();
     $this->outputHeader();
     $out->addSubtitle($this->msg('watchlistfor2', $this->getUser()->getName())->rawParams(SpecialEditWatchlist::buildTools(null)));
     # B/C: $mode used to be waaay down the parameter list, and the first parameter
     # was $wgUser
     if ($mode instanceof User) {
         $args = func_get_args();
         if (count($args) >= 4) {
             $mode = $args[3];
         }
     }
     $mode = self::getMode($this->getRequest(), $mode);
     switch ($mode) {
         case self::EDIT_CLEAR:
             // The "Clear" link scared people too much.
             // Pass on to the raw editor, from which it's very easy to clear.
         // The "Clear" link scared people too much.
         // Pass on to the raw editor, from which it's very easy to clear.
         case self::EDIT_RAW:
             $out->setPageTitle($this->msg('watchlistedit-raw-title'));
             $form = $this->getRawForm();
             if ($form->show()) {
                 $out->addHTML($this->successMessage);
                 $out->addReturnTo(SpecialPage::getTitleFor('Watchlist'));
             }
             break;
         case self::EDIT_NORMAL:
         default:
             $out->setPageTitle($this->msg('watchlistedit-normal-title'));
             $form = $this->getNormalForm();
             if ($form->show()) {
                 $out->addHTML($this->successMessage);
                 $out->addReturnTo(SpecialPage::getTitleFor('Watchlist'));
             } elseif ($this->toc !== false) {
                 $out->prependHTML($this->toc);
             }
             break;
     }
 }
 /**
  * Main execution point
  *
  * @param $mode int
  */
 public function execute($mode)
 {
     $this->setHeaders();
     # Anons don't get a watchlist
     $this->requireLogin('watchlistanontext');
     $out = $this->getOutput();
     $this->checkPermissions();
     $this->checkReadOnly();
     $this->outputHeader();
     $out->addSubtitle($this->msg('watchlistfor2', $this->getUser()->getName())->rawParams(SpecialEditWatchlist::buildTools(null)));
     # B/C: $mode used to be waaay down the parameter list, and the first parameter
     # was $wgUser
     if ($mode instanceof User) {
         $args = func_get_args();
         if (count($args) >= 4) {
             $mode = $args[3];
         }
     }
     $mode = self::getMode($this->getRequest(), $mode);
     switch ($mode) {
         case self::EDIT_RAW:
             $out->setPageTitle($this->msg('watchlistedit-raw-title'));
             $form = $this->getRawForm();
             if ($form->show()) {
                 $out->addHTML($this->successMessage);
                 $out->addReturnTo(SpecialPage::getTitleFor('Watchlist'));
             }
             break;
         case self::EDIT_CLEAR:
             $out->setPageTitle($this->msg('watchlistedit-clear-title'));
             $form = $this->getClearForm();
             if ($form->show()) {
                 $out->addHTML($this->successMessage);
                 $out->addReturnTo(SpecialPage::getTitleFor('Watchlist'));
             }
             break;
         case self::EDIT_NORMAL:
         default:
             $out->setPageTitle($this->msg('watchlistedit-normal-title'));
             $form = $this->getNormalForm();
             if ($form->show()) {
                 $out->addHTML($this->successMessage);
                 $out->addReturnTo(SpecialPage::getTitleFor('Watchlist'));
             } elseif ($this->toc !== false) {
                 $out->prependHTML($this->toc);
             }
             break;
     }
 }
Example #4
0
 /**
  * Set the text to be displayed above the changes
  *
  * @param FormOptions $opts
  * @param int $numRows Number of rows in the result to show after this header
  */
 public function doHeader($opts, $numRows)
 {
     $user = $this->getUser();
     $out = $this->getOutput();
     // if the user wishes, that the watchlist is reloaded, whenever a filter changes,
     // add the module for that
     if ($user->getBoolOption('watchlistreloadautomatically')) {
         $out->addModules(array('mediawiki.special.watchlist'));
     }
     $out->addSubtitle($this->msg('watchlistfor2', $user->getName())->rawParams(SpecialEditWatchlist::buildTools(null)));
     $this->setTopText($opts);
     $lang = $this->getLanguage();
     if ($opts['days'] > 0) {
         $days = $opts['days'];
     } else {
         $days = $this->getConfig()->get('RCMaxAge') / (3600 * 24);
     }
     $timestamp = wfTimestampNow();
     $wlInfo = $this->msg('wlnote')->numParams($numRows, round($days * 24))->params($lang->userDate($timestamp, $user), $lang->userTime($timestamp, $user))->parse() . "<br />\n";
     $nondefaults = $opts->getChangedValues();
     $cutofflinks = $this->msg('wlshowtime') . ' ' . $this->cutoffselector($opts);
     # Spit out some control panel links
     $filters = array('hideminor' => 'wlshowhideminor', 'hidebots' => 'wlshowhidebots', 'hideanons' => 'wlshowhideanons', 'hideliu' => 'wlshowhideliu', 'hidemyself' => 'wlshowhidemine', 'hidepatrolled' => 'wlshowhidepatr');
     if ($this->getConfig()->get('RCWatchCategoryMembership')) {
         $filters['hidecategorization'] = 'wlshowhidecategorization';
     }
     foreach ($this->getCustomFilters() as $key => $params) {
         $filters[$key] = $params['msg'];
     }
     // Disable some if needed
     if (!$user->useRCPatrol()) {
         unset($filters['hidepatrolled']);
     }
     $links = array();
     foreach ($filters as $name => $msg) {
         $links[] = $this->showHideCheck($nondefaults, $msg, $name, $opts[$name]);
     }
     $hiddenFields = $nondefaults;
     $hiddenFields['action'] = 'submit';
     unset($hiddenFields['namespace']);
     unset($hiddenFields['invert']);
     unset($hiddenFields['associated']);
     unset($hiddenFields['days']);
     foreach ($filters as $key => $value) {
         unset($hiddenFields[$key]);
     }
     # Create output
     $form = '';
     # Namespace filter and put the whole form together.
     $form .= $wlInfo;
     $form .= $cutofflinks;
     $form .= $this->msg('watchlist-hide') . $this->msg('colon-separator')->escaped() . implode(' ', $links);
     $form .= "\n<br />\n";
     $form .= Html::namespaceSelector(array('selected' => $opts['namespace'], 'all' => '', 'label' => $this->msg('namespace')->text()), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . "\n";
     $form .= '<span class="mw-input-with-label">' . Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $opts['invert'], array('title' => $this->msg('tooltip-invert')->text())) . "</span>\n";
     $form .= '<span class="mw-input-with-label">' . Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'nsassociated', $opts['associated'], array('title' => $this->msg('tooltip-namespace_association')->text())) . "</span>\n";
     $form .= Xml::submitButton($this->msg('watchlist-submit')->text()) . "\n";
     foreach ($hiddenFields as $key => $value) {
         $form .= Html::hidden($key, $value) . "\n";
     }
     $form .= Xml::closeElement('fieldset') . "\n";
     $form .= Xml::closeElement('form') . "\n";
     $this->getOutput()->addHTML($form);
     $this->setBottomText($opts);
 }
 /**
  * Renders a subheader on the watchlist page.
  */
 protected function outputSubtitle()
 {
     $out = $this->getOutput();
     $out->addSubtitle($this->msg('watchlistfor2', $this->getUser()->getName())->rawParams(SpecialEditWatchlist::buildTools(null)));
 }
Example #6
0
 /**
  * Set the text to be displayed above the changes
  *
  * @param FormOptions $opts
  * @param int $numRows Number of rows in the result to show after this header
  */
 public function doHeader($opts, $numRows)
 {
     $user = $this->getUser();
     $this->getOutput()->addSubtitle($this->msg('watchlistfor2', $user->getName())->rawParams(SpecialEditWatchlist::buildTools(null)));
     $this->setTopText($opts);
     $lang = $this->getLanguage();
     $wlInfo = '';
     if ($opts['days'] > 0) {
         $timestamp = wfTimestampNow();
         $wlInfo = $this->msg('wlnote')->numParams($numRows, round($opts['days'] * 24))->params($lang->userDate($timestamp, $user), $lang->userTime($timestamp, $user))->parse() . "<br />\n";
     }
     $nondefaults = $opts->getChangedValues();
     $cutofflinks = $this->cutoffLinks($opts['days'], $nondefaults) . "<br />\n";
     # Spit out some control panel links
     $filters = array('hideminor' => 'rcshowhideminor', 'hidebots' => 'rcshowhidebots', 'hideanons' => 'rcshowhideanons', 'hideliu' => 'rcshowhideliu', 'hidemyself' => 'rcshowhidemine', 'hidepatrolled' => 'rcshowhidepatr');
     foreach ($this->getCustomFilters() as $key => $params) {
         $filters[$key] = $params['msg'];
     }
     // Disable some if needed
     if (!$user->useNPPatrol()) {
         unset($filters['hidepatrolled']);
     }
     $links = array();
     foreach ($filters as $name => $msg) {
         $links[] = $this->showHideLink($nondefaults, $msg, $name, $opts[$name]);
     }
     $hiddenFields = $nondefaults;
     unset($hiddenFields['namespace']);
     unset($hiddenFields['invert']);
     unset($hiddenFields['associated']);
     # Create output
     $form = '';
     # Namespace filter and put the whole form together.
     $form .= $wlInfo;
     $form .= $cutofflinks;
     $form .= $lang->pipeList($links) . "\n";
     $form .= "<hr />\n<p>";
     $form .= Html::namespaceSelector(array('selected' => $opts['namespace'], 'all' => '', 'label' => $this->msg('namespace')->text()), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . '&#160;';
     $form .= Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $opts['invert'], array('title' => $this->msg('tooltip-invert')->text())) . '&#160;';
     $form .= Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'nsassociated', $opts['associated'], array('title' => $this->msg('tooltip-namespace_association')->text())) . '&#160;';
     $form .= Xml::submitButton($this->msg('allpagessubmit')->text()) . "</p>\n";
     foreach ($hiddenFields as $key => $value) {
         $form .= Html::hidden($key, $value) . "\n";
     }
     $form .= Xml::closeElement('fieldset') . "\n";
     $form .= Xml::closeElement('form') . "\n";
     $this->getOutput()->addHTML($form);
     $this->setBottomText($opts);
 }
Example #7
0
	/**
	 * 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
		if ( $user->isAnon() ) {
			$output->setPageTitle( $this->msg( 'watchnologin' ) );
			$output->setRobotPolicy( 'noindex,nofollow' );
			$llink = Linker::linkKnown(
				SpecialPage::getTitleFor( 'Userlogin' ),
				$this->msg( 'loginreqlink' )->escaped(),
				array(),
				array( 'returnto' => $this->getTitle()->getPrefixedText() )
			);
			$output->addHTML( $this->msg( 'watchlistanontext' )->rawParams( $llink )->parse() );
			return;
		}

		// Check permissions
		$this->checkPermissions();

		// Add feed links
		$wlToken = $user->getTokenFromOption( 'watchlisttoken' );
		if ( $wlToken ) {
			$this->addFeedLinks( array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
								'wlowner' => $user->getName(), 'wltoken' => $wlToken ) );
		}

		$this->setHeaders();
		$this->outputHeader();

		$output->addSubtitle( $this->msg( 'watchlistfor2', $user->getName()
			)->rawParams( SpecialEditWatchlist::buildTools( null ) ) );

		$request = $this->getRequest();

		$mode = SpecialEditWatchlist::getMode( $request, $par );
		if ( $mode !== false ) {
			# TODO: localise?
			switch ( $mode ) {
				case SpecialEditWatchlist::EDIT_CLEAR:
					$mode = 'clear';
					break;
				case SpecialEditWatchlist::EDIT_RAW:
					$mode = 'raw';
					break;
				default:
					$mode = null;
			}
			$title = SpecialPage::getTitleFor( 'EditWatchlist', $mode );
			$output->redirect( $title->getLocalURL() );
			return;
		}

		$dbr = wfGetDB( DB_SLAVE, 'watchlist' );

		$nitems = $this->countItems( $dbr );
		if ( $nitems == 0 ) {
			$output->addWikiMsg( 'nowatchlist' );
			return;
		}

		// @todo use FormOptions!
		$defaults = array(
		/* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ),
		/* bool  */ 'hideMinor' => (int)$user->getBoolOption( 'watchlisthideminor' ),
		/* bool  */ 'hideBots' => (int)$user->getBoolOption( 'watchlisthidebots' ),
		/* bool  */ 'hideAnons' => (int)$user->getBoolOption( 'watchlisthideanons' ),
		/* bool  */ 'hideLiu' => (int)$user->getBoolOption( 'watchlisthideliu' ),
		/* bool  */ 'hidePatrolled' => (int)$user->getBoolOption( 'watchlisthidepatrolled' ),
		/* bool  */ 'hideOwn' => (int)$user->getBoolOption( 'watchlisthideown' ),
		/* bool  */ 'extended' => (int)$user->getBoolOption( 'extendwatchlist' ),
		/* ?     */ 'namespace' => '', //means all
		/* ?     */ 'invert' => false,
		/* bool  */ 'associated' => false,
		);
		$this->customFilters = array();
		wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
		foreach ( $this->customFilters as $key => $params ) {
			$defaults[$key] = $params['default'];
		}

		# Extract variables from the request, falling back to user preferences or
		# other default values if these don't exist
		$values = array();
		$values['days'] = floatval( $request->getVal( 'days', $defaults['days'] ) );
		$values['hideMinor'] = (int)$request->getBool( 'hideMinor', $defaults['hideMinor'] );
		$values['hideBots'] = (int)$request->getBool( 'hideBots', $defaults['hideBots'] );
		$values['hideAnons'] = (int)$request->getBool( 'hideAnons', $defaults['hideAnons'] );
		$values['hideLiu'] = (int)$request->getBool( 'hideLiu', $defaults['hideLiu'] );
		$values['hideOwn'] = (int)$request->getBool( 'hideOwn', $defaults['hideOwn'] );
		$values['hidePatrolled'] = (int)$request->getBool( 'hidePatrolled', $defaults['hidePatrolled'] );
		$values['extended'] = (int)$request->getBool( 'extended', $defaults['extended'] );
		foreach ( $this->customFilters as $key => $params ) {
			$values[$key] = (int)$request->getBool( $key, $defaults[$key] );
		}

		# Get namespace value, if supplied, and prepare a WHERE fragment
		$nameSpace = $request->getIntOrNull( 'namespace' );
		$invert = $request->getBool( 'invert' );
		$associated = $request->getBool( 'associated' );
		if ( !is_null( $nameSpace ) ) {
			$eq_op = $invert ? '!=' : '=';
			$bool_op = $invert ? 'AND' : 'OR';
			$nameSpace = intval( $nameSpace ); // paranioa
			if ( !$associated ) {
				$nameSpaceClause = "rc_namespace $eq_op $nameSpace";
			} else {
				$associatedNS = MWNamespace::getAssociated( $nameSpace );
				$nameSpaceClause =
					"rc_namespace $eq_op $nameSpace " .
					$bool_op .
					" rc_namespace $eq_op $associatedNS";
			}
		} else {
			$nameSpace = '';
			$nameSpaceClause = '';
		}
		$values['namespace'] = $nameSpace;
		$values['invert'] = $invert;
		$values['associated'] = $associated;

		// Dump everything here
		$nondefaults = array();
		foreach ( $defaults as $name => $defValue ) {
			wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults );
		}

		if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
			$request->wasPosted() )
		{
			$user->clearAllNotifications();
			$output->redirect( $this->getTitle()->getFullURL( $nondefaults ) );
			return;
		}

		# Possible where conditions
		$conds = array();

		if ( $values['days'] > 0 ) {
			$conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $values['days'] * 86400 ) ) );
		}

		# Toggles
		if ( $values['hideOwn'] ) {
			$conds[] = 'rc_user != ' . $user->getId();
		}
		if ( $values['hideBots'] ) {
			$conds[] = 'rc_bot = 0';
		}
		if ( $values['hideMinor'] ) {
			$conds[] = 'rc_minor = 0';
		}
		if ( $values['hideLiu'] ) {
			$conds[] = 'rc_user = 0';
		}
		if ( $values['hideAnons'] ) {
			$conds[] = 'rc_user != 0';
		}
		if ( $user->useRCPatrol() && $values['hidePatrolled'] ) {
			$conds[] = 'rc_patrolled != 1';
		}
		if ( $nameSpaceClause ) {
			$conds[] = $nameSpaceClause;
		}

		# Toggle watchlist content (all recent edits or just the latest)
		if ( $values['extended'] ) {
			$limitWatchlist = $user->getIntOption( 'wllimit' );
			$usePage = false;
		} else {
			# Top log Ids for a page are not stored
			$nonRevisionTypes = array( RC_LOG );
			wfRunHooks( 'SpecialWatchlistGetNonRevisionTypes', array( &$nonRevisionTypes ) );
			if ( $nonRevisionTypes ) {
				if ( count( $nonRevisionTypes ) === 1 ) {
					// if only one use an equality instead of IN condition
					$nonRevisionTypes = reset( $nonRevisionTypes );
				}
				$conds[] = $dbr->makeList(
					array(
						'rc_this_oldid=page_latest',
						'rc_type' => $nonRevisionTypes,
					),
					LIST_OR
				);
			}
			$limitWatchlist = 0;
			$usePage = true;
		}

		# Show a message about slave lag, if applicable
		$lag = wfGetLB()->safeGetLag( $dbr );
		if ( $lag > 0 ) {
			$output->showLagWarning( $lag );
		}

		# Create output
		$form = '';

		# Show watchlist header
		$form .= "<p>";
		$form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->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->getTitle()->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->getTitle()->getLocalURL(),
			'id' => 'mw-watchlist-form'
		) );
		$form .= Xml::fieldset(
			$this->msg( 'watchlist-options' )->text(),
			false,
			array( 'id' => 'mw-watchlist-options' )
		);

		$tables = array( 'recentchanges', 'watchlist' );
		$fields = RecentChange::selectFields();
		$join_conds = array(
			'watchlist' => array(
				'INNER JOIN',
				array(
					'wl_user' => $user->getId(),
					'wl_namespace=rc_namespace',
					'wl_title=rc_title'
				),
			),
		);
		$options = array( 'ORDER BY' => 'rc_timestamp DESC' );
		if ( $wgShowUpdatedMarker ) {
			$fields[] = 'wl_notificationtimestamp';
		}
		if ( $limitWatchlist ) {
			$options['LIMIT'] = $limitWatchlist;
		}

		$rollbacker = $user->isAllowed( 'rollback' );
		if ( $usePage || $rollbacker ) {
			$tables[] = 'page';
			$join_conds['page'] = array( 'LEFT JOIN', 'rc_cur_id=page_id' );
			if ( $rollbacker ) {
				$fields[] = 'page_latest';
			}
		}

		// Log entries with DELETED_ACTION must not show up unless the user has
		// the necessary rights.
		if ( !$user->isAllowed( 'deletedhistory' ) ) {
			$bitmask = LogPage::DELETED_ACTION;
		} elseif ( !$user->isAllowed( 'suppressrevision' ) ) {
			$bitmask = LogPage::DELETED_ACTION | LogPage::DELETED_RESTRICTED;
		} else {
			$bitmask = 0;
		}
		if ( $bitmask ) {
			$conds[] = $dbr->makeList( array(
				'rc_type != ' . RC_LOG,
				$dbr->bitAnd( 'rc_deleted', $bitmask ) . " != $bitmask",
			), LIST_OR );
		}

		ChangeTags::modifyDisplayQuery( $tables, $fields, $conds, $join_conds, $options, '' );
		wfRunHooks( 'SpecialWatchlistQuery', array( &$conds, &$tables, &$join_conds, &$fields, $values ) );

		$res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds );
		$numRows = $res->numRows();

		/* Start bottom header */

		$lang = $this->getLanguage();
		$wlInfo = '';
		if ( $values['days'] > 0 ) {
			$timestamp = wfTimestampNow();
			$wlInfo = $this->msg( 'wlnote' )->numParams( $numRows, round( $values['days'] * 24 ) )->params(
				$lang->userDate( $timestamp, $user ), $lang->userTime( $timestamp, $user ) )->parse() . "<br />\n";
		}

		$cutofflinks = $this->cutoffLinks( $values['days'], $nondefaults ) . "<br />\n";

		# Spit out some control panel links
		$filters = array(
			'hideMinor' => 'rcshowhideminor',
			'hideBots' => 'rcshowhidebots',
			'hideAnons' => 'rcshowhideanons',
			'hideLiu' => 'rcshowhideliu',
			'hideOwn' => 'rcshowhidemine',
			'hidePatrolled' => 'rcshowhidepatr'
		);
		foreach ( $this->customFilters as $key => $params ) {
			$filters[$key] = $params['msg'];
		}
		// Disable some if needed
		if ( !$user->useNPPatrol() ) {
			unset( $filters['hidePatrolled'] );
		}

		$links = array();
		foreach ( $filters as $name => $msg ) {
			$links[] = $this->showHideLink( $nondefaults, $msg, $name, $values[$name] );
		}

		$hiddenFields = $nondefaults;
		unset( $hiddenFields['namespace'] );
		unset( $hiddenFields['invert'] );
		unset( $hiddenFields['associated'] );

		# Namespace filter and put the whole form together.
		$form .= $wlInfo;
		$form .= $cutofflinks;
		$form .= $lang->pipeList( $links ) . "\n";
		$form .= "<hr />\n<p>";
		$form .= Html::namespaceSelector(
			array(
				'selected' => $nameSpace,
				'all' => '',
				'label' => $this->msg( 'namespace' )->text()
			), array(
				'name' => 'namespace',
				'id' => 'namespace',
				'class' => 'namespaceselector',
			)
		) . '&#160;';
		$form .= Xml::checkLabel(
			$this->msg( 'invert' )->text(),
			'invert',
			'nsinvert',
			$invert,
			array( 'title' => $this->msg( 'tooltip-invert' )->text() )
		) . '&#160;';
		$form .= Xml::checkLabel(
			$this->msg( 'namespace_association' )->text(),
			'associated',
			'associated',
			$associated,
			array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() )
		) . '&#160;';
		$form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . "</p>\n";
		foreach ( $hiddenFields as $key => $value ) {
			$form .= Html::hidden( $key, $value ) . "\n";
		}
		$form .= Xml::closeElement( 'fieldset' ) . "\n";
		$form .= Xml::closeElement( 'form' ) . "\n";
		$output->addHTML( $form );

		# If there's nothing to show, stop here
		if ( $numRows == 0 ) {
			$output->wrapWikiMsg(
				"<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
			);
			return;
		}

		/* End bottom header */

		/* Do link batch query */
		$linkBatch = new LinkBatch;
		foreach ( $res as $row ) {
			$userNameUnderscored = str_replace( ' ', '_', $row->rc_user_text );
			if ( $row->rc_user != 0 ) {
				$linkBatch->add( NS_USER, $userNameUnderscored );
			}
			$linkBatch->add( NS_USER_TALK, $userNameUnderscored );

			$linkBatch->add( $row->rc_namespace, $row->rc_title );
		}
		$linkBatch->execute();
		$dbr->dataSeek( $res, 0 );

		$list = ChangesList::newFromContext( $this->getContext() );
		$list->setWatchlistDivs();

		$s = $list->beginRecentChangesList();
		$counter = 1;
		foreach ( $res as $obj ) {
			# Make RC entry
			$rc = RecentChange::newFromRow( $obj );
			$rc->counter = $counter++;

			if ( $wgShowUpdatedMarker ) {
				$updated = $obj->wl_notificationtimestamp;
			} else {
				$updated = false;
			}

			if ( $wgRCShowWatchingUsers && $user->getOption( 'shownumberswatching' ) ) {
				$rc->numberofWatchingusers = $dbr->selectField( 'watchlist',
					'COUNT(*)',
					array(
						'wl_namespace' => $obj->rc_namespace,
						'wl_title' => $obj->rc_title,
					),
					__METHOD__ );
			} else {
				$rc->numberofWatchingusers = 0;
			}

			$changeLine = $list->recentChangesLine( $rc, $updated, $counter );
			if ( $changeLine !== false ) {
				$s .= $changeLine;
			}
		}
		$s .= $list->endRecentChangesList();

		$output->addHTML( $s );
	}
 /**
  * Display the interwiki watchlist
  */
 function execute($par)
 {
     global $wgUser, $wgOut, $wgLang, $wgRequest;
     global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker;
     // Add feed links
     $wlToken = $wgUser->getOption('watchlisttoken');
     if (!$wlToken) {
         $wlToken = sha1(mt_rand() . microtime(true));
         $wgUser->setOption('watchlisttoken', $wlToken);
         $wgUser->saveSettings();
     }
     global $wgServer, $wgScriptPath, $wgFeedClasses;
     $apiParams = array('action' => 'feedwatchlist', 'allrev' => 'allrev', 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken);
     $feedTemplate = wfScript('api') . '?';
     foreach ($wgFeedClasses as $format => $class) {
         $theseParams = $apiParams + array('feedformat' => $format);
         $url = $feedTemplate . wfArrayToCGI($theseParams);
         $wgOut->addFeedLink($format, $url);
     }
     $skin = $wgUser->getSkin();
     $specialTitle = SpecialPage::getTitleFor('InterwikiWatchlist');
     $wgOut->setRobotPolicy('noindex,nofollow');
     # Anons don't get a watchlist
     if ($wgUser->isAnon()) {
         $wgOut->setPageTitle(wfMsg('watchnologin'));
         $llink = $skin->linkKnown(SpecialPage::getTitleFor('Userlogin'), wfMsgHtml('loginreqlink'), array(), array('returnto' => $specialTitle->getPrefixedText()));
         $wgOut->addHTML(wfMsgWikiHtml('watchlistanontext', $llink));
         return;
     }
     $wgOut->setPageTitle(wfMsg('interwikiwatchlist'));
     $sub = wfMsgExt('watchlistfor', 'parseinline', $wgUser->getName());
     $sub .= '<br />' . SpecialEditWatchlist::buildTools($wgUser->getSkin());
     $wgOut->setSubtitle($sub);
     $mode = SpecialEditWatchlist::getMode($this->getRequest(), $par);
     if ($mode !== false) {
         # TODO: localise?
         switch ($mode) {
             case SpecialEditWatchlist::EDIT_CLEAR:
                 $mode = 'clear';
                 break;
             case SpecialEditWatchlist::EDIT_RAW:
                 $mode = 'raw';
                 break;
             default:
                 $mode = null;
         }
         $title = SpecialPage::getTitleFor('EditWatchlist', $mode);
         $wgOut->redirect($title->getLocalUrl());
         return;
     }
     $uid = $wgUser->getId();
     if (($wgEnotifWatchlist || $wgShowUpdatedMarker) && $wgRequest->getVal('reset') && $wgRequest->wasPosted()) {
         $wgUser->clearAllNotifications();
         $wgOut->redirect($specialTitle->getFullUrl());
         return;
     }
     $defaults = array('days' => floatval($wgUser->getOption('watchlistdays')), 'hideMinor' => (int) $wgUser->getBoolOption('watchlisthideminor'), 'hideBots' => (int) $wgUser->getBoolOption('watchlisthidebots'), 'hideAnons' => (int) $wgUser->getBoolOption('watchlisthideanons'), 'hideLiu' => (int) $wgUser->getBoolOption('watchlisthideliu'), 'hidePatrolled' => (int) $wgUser->getBoolOption('watchlisthidepatrolled'), 'hideOwn' => (int) $wgUser->getBoolOption('watchlisthideown'), 'namespace' => 'all', 'invert' => false);
     extract($defaults);
     # Extract variables from the request, falling back to user preferences or
     # other default values if these don't exist
     $prefs['days'] = floatval($wgUser->getOption('watchlistdays'));
     $prefs['hideminor'] = $wgUser->getBoolOption('watchlisthideminor');
     $prefs['hidebots'] = $wgUser->getBoolOption('watchlisthidebots');
     $prefs['hideanons'] = $wgUser->getBoolOption('watchlisthideanon');
     $prefs['hideliu'] = $wgUser->getBoolOption('watchlisthideliu');
     $prefs['hideown'] = $wgUser->getBoolOption('watchlisthideown');
     $prefs['hidepatrolled'] = $wgUser->getBoolOption('watchlisthidepatrolled');
     # Get query variables
     $days = $wgRequest->getVal('days', $prefs['days']);
     $hideMinor = $wgRequest->getBool('hideMinor', $prefs['hideminor']);
     $hideBots = $wgRequest->getBool('hideBots', $prefs['hidebots']);
     $hideAnons = $wgRequest->getBool('hideAnons', $prefs['hideanons']);
     $hideLiu = $wgRequest->getBool('hideLiu', $prefs['hideliu']);
     $hideOwn = $wgRequest->getBool('hideOwn', $prefs['hideown']);
     $hidePatrolled = $wgRequest->getBool('hidePatrolled', $prefs['hidepatrolled']);
     # Get namespace value, if supplied, and prepare a WHERE fragment
     $nameSpace = $wgRequest->getIntOrNull('namespace');
     $invert = $wgRequest->getIntOrNull('invert');
     if (!is_null($nameSpace)) {
         $nameSpace = intval($nameSpace);
         if ($invert && $nameSpace !== 'all') {
             $nameSpaceClause = "integration_rc_namespace != {$nameSpace}";
         } else {
             $nameSpaceClause = "integration_rc_namespace = {$nameSpace}";
         }
     } else {
         $nameSpace = '';
         $nameSpaceClause = '';
     }
     $dbr = wfGetDB(DB_SLAVE, 'integration_watchlist');
     $recentchanges = $dbr->tableName('integration_recentchanges');
     $nitems = $this->countItems();
     if (is_null($days) || !is_numeric($days)) {
         $big = 1000;
         /* The magical big */
         if ($nitems > $big) {
             # Set default cutoff shorter
             $days = $defaults['days'] = 12.0 / 24.0;
             # 12 hours...
         } else {
             $days = $defaults['days'];
             # default cutoff for shortlisters
         }
     } else {
         $days = floatval($days);
     }
     // Dump everything here
     $nondefaults = array();
     wfAppendToArrayIfNotDefault('days', $days, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideMinor', (int) $hideMinor, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideBots', (int) $hideBots, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideAnons', (int) $hideAnons, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideLiu', (int) $hideLiu, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hideOwn', (int) $hideOwn, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('namespace', $nameSpace, $defaults, $nondefaults);
     wfAppendToArrayIfNotDefault('hidePatrolled', (int) $hidePatrolled, $defaults, $nondefaults);
     if ($nitems == 0) {
         $wgOut->addWikiMsg('nowatchlist');
         return;
     }
     # Possible where conditions
     $conds = array();
     if ($days <= 0) {
         $andcutoff = '';
     } else {
         $conds[] = "integration_rc_timestamp > '" . $dbr->timestamp(time() - intval($days * 86400)) . "'";
     }
     # If the watchlist is relatively short, it's simplest to zip
     # down its entirety and then sort the results.
     # If it's relatively long, it may be worth our while to zip
     # through the time-sorted page list checking for watched items.
     # Up estimate of watched items by 15% to compensate for talk pages...
     # Toggles
     if ($hideOwn) {
         $conds[] = "integration_rc_user != {$uid}";
     }
     if ($hideBots) {
         $conds[] = 'integration_rc_bot = 0';
     }
     if ($hideMinor) {
         $conds[] = 'integration_rc_minor = 0';
     }
     if ($hideLiu) {
         $conds[] = 'integration_rc_user = 0';
     }
     if ($hideAnons) {
         $conds[] = 'integration_rc_user != 0';
     }
     if ($wgUser->useRCPatrol() && $hidePatrolled) {
         $conds[] = 'integration_rc_patrolled != 1';
     }
     if ($nameSpaceClause) {
         $conds[] = $nameSpaceClause;
     }
     # Toggle watchlist content (all recent edits or just the latest)
     if ($wgUser->getOption('extendwatchlist')) {
         $limitWatchlist = intval($wgUser->getOption('wllimit'));
         $usePage = false;
     } else {
         # Top log Ids for a page are not stored
         $conds[] = 'integration_rc_this_oldid=integration_page_latest OR integration_rc_type=' . RC_LOG;
         $limitWatchlist = 0;
         $usePage = true;
     }
     # Show a message about slave lag, if applicable
     $lag = wfGetLB()->safeGetLag($dbr);
     if ($lag > 0) {
         $wgOut->showLagWarning($lag);
     }
     # Create output form
     $form = Xml::fieldset(wfMsg('watchlist-options'), false, array('id' => 'mw-watchlist-options'));
     # Show watchlist header
     $form .= wfMsgExt('watchlist-details', array('parseinline'), $wgLang->formatNum($nitems));
     if ($wgUser->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
         $form .= wfMsgExt('wlheader-enotif', 'parse') . "\n";
     }
     if ($wgShowUpdatedMarker) {
         $form .= Xml::openElement('form', array('method' => 'post', 'action' => $specialTitle->getLocalUrl(), 'id' => 'mw-watchlist-resetbutton')) . wfMsgExt('wlheader-showupdated', array('parseinline')) . ' ' . Xml::submitButton(wfMsg('enotif_reset'), array('name' => 'dummy')) . Html::Hidden('reset', 'all') . Xml::closeElement('form');
     }
     $form .= '<hr />';
     $tables = array('integration_recentchanges', 'integration_watchlist');
     $fields = array("{$recentchanges}.*");
     $join_conds = array('integration_watchlist' => array('INNER JOIN', "integration_wl_user='******' AND integration_wl_namespace=integration_rc_namespace AND integration_wl_title=integration_rc_title AND integration_wl_db=integration_rc_db"));
     $options = array('ORDER BY' => 'integration_rc_timestamp DESC');
     if ($wgShowUpdatedMarker) {
         $fields[] = 'integration_wl_notificationtimestamp';
     }
     if ($limitWatchlist) {
         $options['LIMIT'] = $limitWatchlist;
     }
     $rollbacker = $wgUser->isAllowed('rollback');
     if ($usePage || $rollbacker) {
         $tables[] = 'integration_page';
         $join_conds['integration_page'] = array('LEFT JOIN', 'integration_rc_cur_id=integration_page_id', 'integration_rc_db=integration_page_db');
         if ($rollbacker) {
             $fields[] = 'integration_page_latest';
         }
     }
     InterwikiIntegrationFunctions::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
     wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields));
     $res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
     $numRows = $dbr->numRows($res);
     /* Start bottom header */
     $wlInfo = '';
     if ($days >= 1) {
         $wlInfo = wfMsgExt('rcnote', 'parseinline', $wgLang->formatNum($numRows), $wgLang->formatNum($days), $wgLang->timeAndDate(wfTimestampNow(), true), $wgLang->date(wfTimestampNow(), true), $wgLang->time(wfTimestampNow(), true)) . '<br />';
     } elseif ($days > 0) {
         $wlInfo = wfMsgExt('wlnote', 'parseinline', $wgLang->formatNum($numRows), $wgLang->formatNum(round($days * 24))) . '<br />';
     }
     $cutofflinks = "\n" . $this->cutoffLinks($days, $nondefaults) . "<br />\n";
     # Spit out some control panel links
     $links[] = $this->showHideLink($nondefaults, 'rcshowhideminor', 'hideMinor', $hideMinor);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhidebots', 'hideBots', $hideBots);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhideanons', 'hideAnons', $hideAnons);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhideliu', 'hideLiu', $hideLiu);
     $links[] = $this->showHideLink($nondefaults, 'rcshowhidemine', 'hideOwn', $hideOwn);
     if ($wgUser->useRCPatrol()) {
         $links[] = $this->showHideLink($nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled);
     }
     # Namespace filter and put the whole form together.
     $form .= $wlInfo;
     $form .= $cutofflinks;
     $form .= $wgLang->pipeList($links);
     $form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector'));
     $form .= '<hr /><p>';
     $form .= Xml::label(wfMsg('namespace'), 'namespace') . '&#160;';
     $form .= Xml::namespaceSelector($nameSpace, '') . '&#160;';
     $form .= Xml::checkLabel(wfMsg('invert'), 'invert', 'nsinvert', $invert) . '&#160;';
     $form .= Xml::submitButton(wfMsg('allpagessubmit')) . '</p>';
     $form .= Html::Hidden('days', $days);
     if ($hideMinor) {
         $form .= Html::Hidden('hideMinor', 1);
     }
     if ($hideBots) {
         $form .= Html::Hidden('hideBots', 1);
     }
     if ($hideAnons) {
         $form .= Html::Hidden('hideAnons', 1);
     }
     if ($hideLiu) {
         $form .= Html::Hidden('hideLiu', 1);
     }
     if ($hideOwn) {
         $form .= Html::Hidden('hideOwn', 1);
     }
     $form .= Xml::closeElement('form');
     $form .= Xml::closeElement('fieldset');
     $wgOut->addHTML($form);
     $wgOut->addHTML(InterwikiIntegrationChangesList::flagLegend());
     # If there's nothing to show, stop here
     if ($numRows == 0) {
         $wgOut->addWikiMsg('watchnochange');
         return;
     }
     /* End bottom header */
     /* Do link batch query */
     $linkBatch = new LinkBatch();
     while ($row = $dbr->fetchObject($res)) {
         $userNameUnderscored = str_replace(' ', '_', $row->integration_rc_user_text);
         if ($row->integration_rc_user != 0) {
             $linkBatch->add(NS_USER, $userNameUnderscored);
         }
         $linkBatch->add(NS_USER_TALK, $userNameUnderscored);
         $linkBatch->add($row->integration_rc_namespace, $row->integration_rc_title);
     }
     $linkBatch->execute();
     $dbr->dataSeek($res, 0);
     $list = InterwikiIntegrationChangesList::newFromUser($wgUser);
     $list->setWatchlistDivs();
     $s = $list->beginRecentInterwikiIntegrationChangesList();
     $counter = 1;
     while ($obj = $dbr->fetchObject($res)) {
         # Make RC entry
         $rc = InterwikiIntegrationRecentChange::newFromRow($obj);
         $rc->counter = $counter++;
         if ($wgShowUpdatedMarker) {
             $updated = $obj->integration_wl_notificationtimestamp;
         } else {
             $updated = false;
         }
         if ($wgRCShowWatchingUsers && $wgUser->getOption('shownumberswatching')) {
             $rc->numberofWatchingusers = $dbr->selectField('integration_watchlist', 'COUNT(*)', array('integration_wl_namespace' => $obj->integration_rc_namespace, 'integration_wl_title' => $obj->integration_rc_title), __METHOD__);
         } else {
             $rc->numberofWatchingusers = 0;
         }
         $s .= $list->recentChangesLine($rc, $updated, $counter);
     }
     $s .= $list->endRecentInterwikiIntegrationChangesList();
     $dbr->freeResult($res);
     $wgOut->addHTML($s);
 }
 /**
  * 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
     if ($user->isAnon()) {
         $output->setPageTitle($this->msg('watchnologin'));
         $output->setRobotPolicy('noindex,nofollow');
         $llink = Linker::linkKnown(SpecialPage::getTitleFor('Userlogin'), $this->msg('loginreqlink')->escaped(), array(), array('returnto' => $this->getTitle()->getPrefixedText()));
         $output->addHTML($this->msg('watchlistanontext')->rawParams($llink)->parse());
         return;
     }
     // Add feed links
     $wlToken = $user->getOption('watchlisttoken');
     if (!$wlToken) {
         $wlToken = MWCryptRand::generateHex(40);
         $user->setOption('watchlisttoken', $wlToken);
         $user->saveSettings();
     }
     $this->addFeedLinks(array('action' => 'feedwatchlist', 'allrev' => 'allrev', 'wlowner' => $user->getName(), 'wltoken' => $wlToken));
     $this->setHeaders();
     $this->outputHeader();
     $output->addSubtitle($this->msg('watchlistfor2', $user->getName())->rawParams(SpecialEditWatchlist::buildTools(null)));
     $request = $this->getRequest();
     $mode = SpecialEditWatchlist::getMode($request, $par);
     if ($mode !== false) {
         # TODO: localise?
         switch ($mode) {
             case SpecialEditWatchlist::EDIT_CLEAR:
                 $mode = 'clear';
                 break;
             case SpecialEditWatchlist::EDIT_RAW:
                 $mode = 'raw';
                 break;
             default:
                 $mode = null;
         }
         $title = SpecialPage::getTitleFor('EditWatchlist', $mode);
         $output->redirect($title->getLocalUrl());
         return;
     }
     $nitems = $this->countItems();
     if ($nitems == 0) {
         $output->addWikiMsg('nowatchlist');
         return;
     }
     // @TODO: use FormOptions!
     $defaults = array('days' => floatval($user->getOption('watchlistdays')), 'hideMinor' => (int) $user->getBoolOption('watchlisthideminor'), 'hideBots' => (int) $user->getBoolOption('watchlisthidebots'), 'hideAnons' => (int) $user->getBoolOption('watchlisthideanons'), 'hideLiu' => (int) $user->getBoolOption('watchlisthideliu'), 'hidePatrolled' => (int) $user->getBoolOption('watchlisthidepatrolled'), 'hideOwn' => (int) $user->getBoolOption('watchlisthideown'), 'namespace' => 'all', 'invert' => false, 'associated' => false);
     $this->customFilters = array();
     wfRunHooks('SpecialWatchlistFilters', array($this, &$this->customFilters));
     foreach ($this->customFilters as $key => $params) {
         $defaults[$key] = $params['msg'];
     }
     # Extract variables from the request, falling back to user preferences or
     # other default values if these don't exist
     $prefs['days'] = floatval($user->getOption('watchlistdays'));
     $prefs['hideminor'] = $user->getBoolOption('watchlisthideminor');
     $prefs['hidebots'] = $user->getBoolOption('watchlisthidebots');
     $prefs['hideanons'] = $user->getBoolOption('watchlisthideanons');
     $prefs['hideliu'] = $user->getBoolOption('watchlisthideliu');
     $prefs['hideown'] = $user->getBoolOption('watchlisthideown');
     $prefs['hidepatrolled'] = $user->getBoolOption('watchlisthidepatrolled');
     # Get query variables
     $values = array();
     $values['days'] = $request->getVal('days', $prefs['days']);
     $values['hideMinor'] = (int) $request->getBool('hideMinor', $prefs['hideminor']);
     $values['hideBots'] = (int) $request->getBool('hideBots', $prefs['hidebots']);
     $values['hideAnons'] = (int) $request->getBool('hideAnons', $prefs['hideanons']);
     $values['hideLiu'] = (int) $request->getBool('hideLiu', $prefs['hideliu']);
     $values['hideOwn'] = (int) $request->getBool('hideOwn', $prefs['hideown']);
     $values['hidePatrolled'] = (int) $request->getBool('hidePatrolled', $prefs['hidepatrolled']);
     foreach ($this->customFilters as $key => $params) {
         $values[$key] = (int) $request->getBool($key);
     }
     # Get namespace value, if supplied, and prepare a WHERE fragment
     $nameSpace = $request->getIntOrNull('namespace');
     $invert = $request->getBool('invert');
     $associated = $request->getBool('associated');
     if (!is_null($nameSpace)) {
         $eq_op = $invert ? '!=' : '=';
         $bool_op = $invert ? 'AND' : 'OR';
         $nameSpace = intval($nameSpace);
         // paranioa
         if (!$associated) {
             $nameSpaceClause = "rc_namespace {$eq_op} {$nameSpace}";
         } else {
             $associatedNS = MWNamespace::getAssociated($nameSpace);
             $nameSpaceClause = "rc_namespace {$eq_op} {$nameSpace} " . $bool_op . " rc_namespace {$eq_op} {$associatedNS}";
         }
     } else {
         $nameSpace = '';
         $nameSpaceClause = '';
     }
     $values['namespace'] = $nameSpace;
     $values['invert'] = $invert;
     $values['associated'] = $associated;
     if (is_null($values['days']) || !is_numeric($values['days'])) {
         $big = 1000;
         /* The magical big */
         if ($nitems > $big) {
             # Set default cutoff shorter
             $values['days'] = $defaults['days'] = 12.0 / 24.0;
             # 12 hours...
         } else {
             $values['days'] = $defaults['days'];
             # default cutoff for shortlisters
         }
     } else {
         $values['days'] = floatval($values['days']);
     }
     // Dump everything here
     $nondefaults = array();
     foreach ($defaults as $name => $defValue) {
         wfAppendToArrayIfNotDefault($name, $values[$name], $defaults, $nondefaults);
     }
     if (($wgEnotifWatchlist || $wgShowUpdatedMarker) && $request->getVal('reset') && $request->wasPosted()) {
         $user->clearAllNotifications();
         $output->redirect($this->getTitle()->getFullUrl($nondefaults));
         return;
     }
     $dbr = wfGetDB(DB_SLAVE, 'watchlist');
     # Possible where conditions
     $conds = array();
     if ($values['days'] > 0) {
         $conds[] = "rc_timestamp > '" . $dbr->timestamp(time() - intval($values['days'] * 86400)) . "'";
     }
     # If the watchlist is relatively short, it's simplest to zip
     # down its entirety and then sort the results.
     # If it's relatively long, it may be worth our while to zip
     # through the time-sorted page list checking for watched items.
     # Up estimate of watched items by 15% to compensate for talk pages...
     # Toggles
     if ($values['hideOwn']) {
         $conds[] = 'rc_user != ' . $user->getId();
     }
     if ($values['hideBots']) {
         $conds[] = 'rc_bot = 0';
     }
     if ($values['hideMinor']) {
         $conds[] = 'rc_minor = 0';
     }
     if ($values['hideLiu']) {
         $conds[] = 'rc_user = 0';
     }
     if ($values['hideAnons']) {
         $conds[] = 'rc_user != 0';
     }
     if ($user->useRCPatrol() && $values['hidePatrolled']) {
         $conds[] = 'rc_patrolled != 1';
     }
     if ($nameSpaceClause) {
         $conds[] = $nameSpaceClause;
     }
     # Toggle watchlist content (all recent edits or just the latest)
     if ($user->getOption('extendwatchlist')) {
         $limitWatchlist = intval($user->getOption('wllimit'));
         $usePage = false;
     } else {
         # Top log Ids for a page are not stored
         $conds[] = 'rc_this_oldid=page_latest OR rc_type=' . RC_LOG;
         $limitWatchlist = 0;
         $usePage = true;
     }
     # Show a message about slave lag, if applicable
     $lag = wfGetLB()->safeGetLag($dbr);
     if ($lag > 0) {
         $output->showLagWarning($lag);
     }
     # Create output form
     $form = Xml::fieldset($this->msg('watchlist-options')->text(), false, array('id' => 'mw-watchlist-options'));
     # Show watchlist header
     $form .= $this->msg('watchlist-details')->numParams($nitems)->parse();
     if ($user->getOption('enotifwatchlistpages') && $wgEnotifWatchlist) {
         $form .= $this->msg('wlheader-enotif')->parseAsBlock() . "\n";
     }
     if ($wgShowUpdatedMarker) {
         $form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-resetbutton')) . $this->msg('wlheader-showupdated')->parse() . ' ' . Xml::submitButton($this->msg('enotif_reset')->text(), array('name' => 'dummy')) . Html::hidden('reset', 'all');
         foreach ($nondefaults as $key => $value) {
             $form .= Html::hidden($key, $value);
         }
         $form .= Xml::closeElement('form');
     }
     $form .= '<hr />';
     $tables = array('recentchanges', 'watchlist');
     $fields = RecentChange::selectFields();
     $join_conds = array('watchlist' => array('INNER JOIN', array('wl_user' => $user->getId(), 'wl_namespace=rc_namespace', 'wl_title=rc_title')));
     $options = array('ORDER BY' => 'rc_timestamp DESC');
     if ($wgShowUpdatedMarker) {
         $fields[] = 'wl_notificationtimestamp';
     }
     if ($limitWatchlist) {
         $options['LIMIT'] = $limitWatchlist;
     }
     $rollbacker = $user->isAllowed('rollback');
     if ($usePage || $rollbacker) {
         $tables[] = 'page';
         $join_conds['page'] = array('LEFT JOIN', 'rc_cur_id=page_id');
         if ($rollbacker) {
             $fields[] = 'page_latest';
         }
     }
     ChangeTags::modifyDisplayQuery($tables, $fields, $conds, $join_conds, $options, '');
     wfRunHooks('SpecialWatchlistQuery', array(&$conds, &$tables, &$join_conds, &$fields));
     $res = $dbr->select($tables, $fields, $conds, __METHOD__, $options, $join_conds);
     $numRows = $res->numRows();
     /* Start bottom header */
     $lang = $this->getLanguage();
     $wlInfo = '';
     if ($values['days'] > 0) {
         $timestamp = wfTimestampNow();
         $wlInfo = $this->msg('wlnote')->numParams($numRows, round($values['days'] * 24))->params($lang->userDate($timestamp, $user), $lang->userTime($timestamp, $user))->parse() . '<br />';
     }
     $cutofflinks = "\n" . $this->cutoffLinks($values['days'], $nondefaults) . "<br />\n";
     # Spit out some control panel links
     $filters = array('hideMinor' => 'rcshowhideminor', 'hideBots' => 'rcshowhidebots', 'hideAnons' => 'rcshowhideanons', 'hideLiu' => 'rcshowhideliu', 'hideOwn' => 'rcshowhidemine', 'hidePatrolled' => 'rcshowhidepatr');
     foreach ($this->customFilters as $key => $params) {
         $filters[$key] = $params['msg'];
     }
     // Disable some if needed
     if (!$user->useNPPatrol()) {
         unset($filters['hidePatrolled']);
     }
     $links = array();
     foreach ($filters as $name => $msg) {
         $links[] = $this->showHideLink($nondefaults, $msg, $name, $values[$name]);
     }
     # Namespace filter and put the whole form together.
     $form .= $wlInfo;
     $form .= $cutofflinks;
     $form .= $lang->pipeList($links);
     $form .= Xml::openElement('form', array('method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector'));
     $form .= '<hr /><p>';
     $form .= Html::namespaceSelector(array('selected' => $nameSpace, 'all' => '', 'label' => $this->msg('namespace')->text()), array('name' => 'namespace', 'id' => 'namespace', 'class' => 'namespaceselector')) . '&#160;';
     $form .= Xml::checkLabel($this->msg('invert')->text(), 'invert', 'nsinvert', $invert, array('title' => $this->msg('tooltip-invert')->text())) . '&#160;';
     $form .= Xml::checkLabel($this->msg('namespace_association')->text(), 'associated', 'associated', $associated, array('title' => $this->msg('tooltip-namespace_association')->text())) . '&#160;';
     $form .= Xml::submitButton($this->msg('allpagessubmit')->text()) . '</p>';
     $form .= Html::hidden('days', $values['days']);
     foreach ($filters as $key => $msg) {
         if ($values[$key]) {
             $form .= Html::hidden($key, 1);
         }
     }
     $form .= Xml::closeElement('form');
     $form .= Xml::closeElement('fieldset');
     $output->addHTML($form);
     # If there's nothing to show, stop here
     if ($numRows == 0) {
         $output->addWikiMsg('watchnochange');
         return;
     }
     /* End bottom header */
     /* Do link batch query */
     $linkBatch = new LinkBatch();
     foreach ($res as $row) {
         $userNameUnderscored = str_replace(' ', '_', $row->rc_user_text);
         if ($row->rc_user != 0) {
             $linkBatch->add(NS_USER, $userNameUnderscored);
         }
         $linkBatch->add(NS_USER_TALK, $userNameUnderscored);
         $linkBatch->add($row->rc_namespace, $row->rc_title);
     }
     $linkBatch->execute();
     $dbr->dataSeek($res, 0);
     $list = ChangesList::newFromContext($this->getContext());
     $list->setWatchlistDivs();
     $s = $list->beginRecentChangesList();
     $counter = 1;
     foreach ($res as $obj) {
         # Make RC entry
         $rc = RecentChange::newFromRow($obj);
         $rc->counter = $counter++;
         if ($wgShowUpdatedMarker) {
             $updated = $obj->wl_notificationtimestamp;
         } else {
             $updated = false;
         }
         if ($wgRCShowWatchingUsers && $user->getOption('shownumberswatching')) {
             $rc->numberofWatchingusers = $dbr->selectField('watchlist', 'COUNT(*)', array('wl_namespace' => $obj->rc_namespace, 'wl_title' => $obj->rc_title), __METHOD__);
         } else {
             $rc->numberofWatchingusers = 0;
         }
         $s .= $list->recentChangesLine($rc, $updated, $counter);
     }
     $s .= $list->endRecentChangesList();
     $output->addHTML($s);
 }