Moved some of the functionality from mediawiki.legacy.prefs into mediawiki.specials...
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index b109b72..5dc17ee 100644 (file)
@@ -1,5 +1,22 @@
 <?php
 /**
+ * Implements Special:Watchlist
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
  * @file
  * @ingroup SpecialPage Watchlist
  */
@@ -21,7 +38,7 @@ function wfSpecialWatchlist( $par ) {
                $wgUser->saveSettings();
        }
        
-       global $wgServer, $wgScriptPath, $wgFeedClasses;
+       global $wgFeedClasses;
        $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev',
                                                'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken );
        $feedTemplate = wfScript('api').'?';
@@ -51,8 +68,7 @@ function wfSpecialWatchlist( $par ) {
 
        $wgOut->setPageTitle( wfMsg( 'watchlist' ) );
 
-       $sub  = wfMsgExt( 'watchlistfor', 'parseinline', $wgUser->getName() );
-       $sub .= '<br />' . WatchlistEditor::buildTools( $wgUser->getSkin() );
+       $sub  = wfMsgExt( 'watchlistfor2', array( 'parseinline', 'replaceafter' ), $wgUser->getName(), WatchlistEditor::buildTools( $wgUser->getSkin() ) );
        $wgOut->setSubtitle( $sub );
 
        if( ( $mode = WatchlistEditor::getMode( $wgRequest, $par ) ) !== false ) {
@@ -191,6 +207,9 @@ function wfSpecialWatchlist( $par ) {
        if ( $wgUser->useRCPatrol() && $hidePatrolled ) {
                $conds[] = 'rc_patrolled != 1';
        }
+       if( $nameSpaceClause ) {
+               $conds[] = $nameSpaceClause;
+       }
 
        # Toggle watchlist content (all recent edits or just the latest)
        if( $wgUser->getOption( 'extendwatchlist' )) {
@@ -293,9 +312,9 @@ function wfSpecialWatchlist( $par ) {
        $form .= $wgLang->pipeList( $links );
        $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $thisTitle->getLocalUrl(), 'id' => 'mw-watchlist-form-namespaceselector' ) );
        $form .= '<hr /><p>';
-       $form .= Xml::label( wfMsg( 'namespace' ), 'namespace' ) . '&nbsp;';
-       $form .= Xml::namespaceSelector( $nameSpace, '' ) . '&nbsp;';
-       $form .= Xml::checkLabel( wfMsg('invert'), 'invert', 'nsinvert', $invert ) . '&nbsp;';
+       $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 .= Xml::hidden( 'days', $days );
        if( $hideMinor )
@@ -312,8 +331,6 @@ function wfSpecialWatchlist( $par ) {
        $form .= Xml::closeElement( 'fieldset' );
        $wgOut->addHTML( $form );
 
-       $wgOut->addHTML( ChangesList::flagLegend() );
-
        # If there's nothing to show, stop here
        if( $numRows == 0 ) {
                $wgOut->addWikiMsg( 'watchnochange' );
@@ -368,7 +385,6 @@ function wfSpecialWatchlist( $par ) {
        }
        $s .= $list->endRecentChangesList();
 
-       $dbr->freeResult( $res );
        $wgOut->addHTML( $s );
 }
 
@@ -448,8 +464,9 @@ function wlCutoffLinks( $days, $page = 'Watchlist', $options = array() ) {
 /**
  * Count the number of items on a user's watchlist
  *
- * @param $talk Include talk pages
- * @return integer
+ * @param $user User object
+ * @param $talk Boolean: include talk pages
+ * @return Integer
  */
 function wlCountItems( &$user, $talk = true ) {
        $dbr = wfGetDB( DB_SLAVE, 'watchlist' );
@@ -459,7 +476,6 @@ function wlCountItems( &$user, $talk = true ) {
                array( 'wl_user' => $user->mId ), 'wlCountItems' );
        $row = $dbr->fetchObject( $res );
        $count = $row->count;
-       $dbr->freeResult( $res );
 
        # Halve to remove talk pages if needed
        if( !$talk )