diff options
author | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
---|---|---|
committer | Pierre Schmitz <pierre@archlinux.de> | 2013-01-18 16:46:04 +0100 |
commit | 63601400e476c6cf43d985f3e7b9864681695ed4 (patch) | |
tree | f7846203a952e38aaf66989d0a4702779f549962 /includes/specials/SpecialWatchlist.php | |
parent | 8ff01378c9e0207f9169b81966a51def645b6a51 (diff) |
Update to MediaWiki 1.20.2
this update includes:
* adjusted Arch Linux skin
* updated FluxBBAuthPlugin
* patch for https://bugzilla.wikimedia.org/show_bug.cgi?id=44024
Diffstat (limited to 'includes/specials/SpecialWatchlist.php')
-rw-r--r-- | includes/specials/SpecialWatchlist.php | 81 |
1 files changed, 61 insertions, 20 deletions
diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index fef54911..5dfc1133 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -91,14 +91,6 @@ class SpecialWatchlist extends SpecialPage { return; } - if( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) && - $request->wasPosted() ) - { - $user->clearAllNotifications(); - $output->redirect( $this->getTitle()->getFullUrl() ); - return; - } - $nitems = $this->countItems(); if ( $nitems == 0 ) { $output->addWikiMsg( 'nowatchlist' ); @@ -116,6 +108,7 @@ class SpecialWatchlist extends SpecialPage { /* bool */ 'hideOwn' => (int)$user->getBoolOption( 'watchlisthideown' ), /* ? */ 'namespace' => 'all', /* ? */ 'invert' => false, + /* bool */ 'associated' => false, ); $this->customFilters = array(); wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) ); @@ -148,13 +141,20 @@ class SpecialWatchlist extends SpecialPage { # Get namespace value, if supplied, and prepare a WHERE fragment $nameSpace = $request->getIntOrNull( 'namespace' ); - $invert = $request->getIntOrNull( 'invert' ); + $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 ( $invert ) { - $nameSpaceClause = "rc_namespace != $nameSpace"; + if ( !$associated ) { + $nameSpaceClause = "rc_namespace $eq_op $nameSpace"; } else { - $nameSpaceClause = "rc_namespace = $nameSpace"; + $associatedNS = MWNamespace::getAssociated( $nameSpace ); + $nameSpaceClause = + "rc_namespace $eq_op $nameSpace " . + $bool_op . + " rc_namespace $eq_op $associatedNS"; } } else { $nameSpace = ''; @@ -162,6 +162,7 @@ class SpecialWatchlist extends SpecialPage { } $values['namespace'] = $nameSpace; $values['invert'] = $invert; + $values['associated'] = $associated; if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) { $big = 1000; /* The magical big */ @@ -181,6 +182,14 @@ class SpecialWatchlist extends SpecialPage { 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 @@ -254,15 +263,25 @@ class SpecialWatchlist extends SpecialPage { 'id' => 'mw-watchlist-resetbutton' ) ) . $this->msg( 'wlheader-showupdated' )->parse() . ' ' . Xml::submitButton( $this->msg( 'enotif_reset' )->text(), array( 'name' => 'dummy' ) ) . - Html::hidden( 'reset', 'all' ) . - Xml::closeElement( 'form' ); + 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 = array( $dbr->tableName( 'recentchanges' ) . '.*' ); $join_conds = array( - 'watchlist' => array('INNER JOIN',"wl_user='{$user->getId()}' AND wl_namespace=rc_namespace AND wl_title=rc_title"), + '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 ) { @@ -285,7 +304,7 @@ class SpecialWatchlist extends SpecialPage { wfRunHooks('SpecialWatchlistQuery', array(&$conds,&$tables,&$join_conds,&$fields) ); $res = $dbr->select( $tables, $fields, $conds, __METHOD__, $options, $join_conds ); - $numRows = $dbr->numRows( $res ); + $numRows = $res->numRows(); /* Start bottom header */ @@ -327,9 +346,31 @@ class SpecialWatchlist extends SpecialPage { $form .= $lang->pipeList( $links ); $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getTitle()->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector' ) ); $form .= '<hr /><p>'; - $form .= Xml::label( $this->msg( 'namespace' )->text(), 'namespace' ) . ' '; - $form .= Xml::namespaceSelector( $nameSpace, '' ) . ' '; - $form .= Xml::checkLabel( $this->msg( 'invert' )->text(), 'invert', 'nsinvert', $invert ) . ' '; + $form .= Html::namespaceSelector( + array( + 'selected' => $nameSpace, + 'all' => '', + 'label' => $this->msg( 'namespace' )->text() + ), array( + 'name' => 'namespace', + 'id' => 'namespace', + 'class' => 'namespaceselector', + ) + ) . ' '; + $form .= Xml::checkLabel( + $this->msg( 'invert' )->text(), + 'invert', + 'nsinvert', + $invert, + array( 'title' => $this->msg( 'tooltip-invert' )->text() ) + ) . ' '; + $form .= Xml::checkLabel( + $this->msg( 'namespace_association' )->text(), + 'associated', + 'associated', + $associated, + array( 'title' => $this->msg( 'tooltip-namespace_association' )->text() ) + ) . ' '; $form .= Xml::submitButton( $this->msg( 'allpagessubmit' )->text() ) . '</p>'; $form .= Html::hidden( 'days', $values['days'] ); foreach ( $filters as $key => $msg ) { @@ -459,7 +500,7 @@ class SpecialWatchlist extends SpecialPage { $dbr = wfGetDB( DB_SLAVE, 'watchlist' ); # Fetch the raw count - $res = $dbr->select( 'watchlist', 'COUNT(*) AS count', + $res = $dbr->select( 'watchlist', array( 'count' => 'COUNT(*)' ), array( 'wl_user' => $this->getUser()->getId() ), __METHOD__ ); $row = $dbr->fetchObject( $res ); $count = $row->count; |