(bug 26809) Uploading files with multiple extensions where one of the extensions...
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 72bc824..757671e 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 ) {
@@ -82,8 +98,6 @@ function wfSpecialWatchlist( $par ) {
        /* ?     */ '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' ) );
@@ -158,9 +172,7 @@ function wfSpecialWatchlist( $par ) {
        # Possible where conditions
        $conds = array();
 
-       if( $days <= 0 ) {
-               $andcutoff = '';
-       } else {
+       if( $days > 0 ) {
                $conds[] = "rc_timestamp > '".$dbr->timestamp( time() - intval( $days * 86400 ) )."'";
        }
 
@@ -191,6 +203,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' )) {
@@ -222,7 +237,7 @@ function wfSpecialWatchlist( $par ) {
                                        'id' => 'mw-watchlist-resetbutton' ) ) .
                                wfMsgExt( 'wlheader-showupdated', array( 'parseinline' ) ) . ' ' .
                                Xml::submitButton( wfMsg( 'enotif_reset' ), array( 'name' => 'dummy' ) ) .
-                               Xml::hidden( 'reset', 'all' ) .
+                               Html::hidden( 'reset', 'all' ) .
                                Xml::closeElement( 'form' );
        }
        $form .= '<hr />';
@@ -291,29 +306,27 @@ function wfSpecialWatchlist( $par ) {
        $form .= $wlInfo;
        $form .= $cutofflinks;
        $form .= $wgLang->pipeList( $links );
-       $form .= Xml::openElement( 'form', array( 'method' => 'post', 'action' => $thisTitle->getLocalUrl() ) );
+       $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 );
+       $form .= Html::hidden( 'days', $days );
        if( $hideMinor )
-               $form .= Xml::hidden( 'hideMinor', 1 );
+               $form .= Html::hidden( 'hideMinor', 1 );
        if( $hideBots )
-               $form .= Xml::hidden( 'hideBots', 1 );
+               $form .= Html::hidden( 'hideBots', 1 );
        if( $hideAnons )
-               $form .= Xml::hidden( 'hideAnons', 1 );
+               $form .= Html::hidden( 'hideAnons', 1 );
        if( $hideLiu )
-               $form .= Xml::hidden( 'hideLiu', 1 );
+               $form .= Html::hidden( 'hideLiu', 1 );
        if( $hideOwn )
-               $form .= Xml::hidden( 'hideOwn', 1 );
+               $form .= Html::hidden( 'hideOwn', 1 );
        $form .= Xml::closeElement( 'form' );
        $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' );
@@ -324,7 +337,7 @@ function wfSpecialWatchlist( $par ) {
 
        /* Do link batch query */
        $linkBatch = new LinkBatch;
-       while ( $row = $dbr->fetchObject( $res ) ) {
+       foreach ( $res as $row ) {
                $userNameUnderscored = str_replace( ' ', '_', $row->rc_user_text );
                if ( $row->rc_user != 0 ) {
                        $linkBatch->add( NS_USER, $userNameUnderscored );
@@ -341,7 +354,7 @@ function wfSpecialWatchlist( $par ) {
        
        $s = $list->beginRecentChangesList();
        $counter = 1;
-       while ( $obj = $dbr->fetchObject( $res ) ) {
+       foreach ( $res as $obj ) {
                # Make RC entry
                $rc = RecentChange::newFromRow( $obj );
                $rc->counter = $counter++;
@@ -368,7 +381,6 @@ function wfSpecialWatchlist( $par ) {
        }
        $s .= $list->endRecentChangesList();
 
-       $dbr->freeResult( $res );
        $wgOut->addHTML( $s );
 }
 
@@ -448,8 +460,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 +472,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 )