RecentChanges, RecentChangesLinked, Watchlist: message when no items
[lhc/web/wiklou.git] / includes / specials / SpecialWatchlist.php
index 543c91e..2a28a11 100644 (file)
@@ -41,7 +41,7 @@ class SpecialWatchlist extends SpecialPage {
                $output = $this->getOutput();
 
                # Anons don't get a watchlist
-               if( $user->isAnon() ) {
+               if ( $user->isAnon() ) {
                        $output->setPageTitle( $this->msg( 'watchnologin' ) );
                        $output->setRobotPolicy( 'noindex,nofollow' );
                        $llink = Linker::linkKnown(
@@ -74,9 +74,9 @@ class SpecialWatchlist extends SpecialPage {
                $request = $this->getRequest();
 
                $mode = SpecialEditWatchlist::getMode( $request, $par );
-               if( $mode !== false ) {
+               if ( $mode !== false ) {
                        # TODO: localise?
-                       switch( $mode ) {
+                       switch ( $mode ) {
                                case SpecialEditWatchlist::EDIT_CLEAR:
                                        $mode = 'clear';
                                        break;
@@ -99,23 +99,23 @@ class SpecialWatchlist extends SpecialPage {
                        return;
                }
 
-               // @TODO: use FormOptions!
+               // @todo use FormOptions!
                $defaults = array(
-               /* float */ 'days'      => floatval( $user->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
+               /* float */ 'days' => floatval( $user->getOption( 'watchlistdays' ) ), /* 3.0 or 0.5, watch further below */
                /* bool  */ 'hideMinor' => (int)$user->getBoolOption( 'watchlisthideminor' ),
-               /* bool  */ 'hideBots'  => (int)$user->getBoolOption( 'watchlisthidebots' ),
+               /* bool  */ 'hideBots' => (int)$user->getBoolOption( 'watchlisthidebots' ),
                /* bool  */ 'hideAnons' => (int)$user->getBoolOption( 'watchlisthideanons' ),
-               /* bool  */ 'hideLiu'   => (int)$user->getBoolOption( 'watchlisthideliu' ),
+               /* bool  */ 'hideLiu' => (int)$user->getBoolOption( 'watchlisthideliu' ),
                /* bool  */ 'hidePatrolled' => (int)$user->getBoolOption( 'watchlisthidepatrolled' ),
-               /* bool  */ 'hideOwn'   => (int)$user->getBoolOption( 'watchlisthideown' ),
-               /* bool  */ 'extended'   => (int)$user->getBoolOption( 'extendwatchlist' ),
+               /* bool  */ 'hideOwn' => (int)$user->getBoolOption( 'watchlisthideown' ),
+               /* bool  */ 'extended' => (int)$user->getBoolOption( 'extendwatchlist' ),
                /* ?     */ 'namespace' => '', //means all
-               /* ?     */ 'invert'    => false,
+               /* ?     */ 'invert' => false,
                /* bool  */ 'associated' => false,
                );
                $this->customFilters = array();
                wfRunHooks( 'SpecialWatchlistFilters', array( $this, &$this->customFilters ) );
-               foreach( $this->customFilters as $key => $params ) {
+               foreach ( $this->customFilters as $key => $params ) {
                        $defaults[$key] = $params['default'];
                }
 
@@ -130,7 +130,7 @@ class SpecialWatchlist extends SpecialPage {
                $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 ) {
+               foreach ( $this->customFilters as $key => $params ) {
                        $values[$key] = (int)$request->getBool( $key, $defaults[$key] );
                }
 
@@ -159,11 +159,11 @@ class SpecialWatchlist extends SpecialPage {
                $values['invert'] = $invert;
                $values['associated'] = $associated;
 
-               if( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
+               if ( is_null( $values['days'] ) || !is_numeric( $values['days'] ) ) {
                        $big = 1000; /* The magical big */
-                       if( $nitems > $big ) {
+                       if ( $nitems > $big ) {
                                # Set default cutoff shorter
-                               $values['days'] = $defaults['days'] = (12.0 / 24.0); # 12 hours...
+                               $values['days'] = $defaults['days'] = ( 12.0 / 24.0 ); # 12 hours...
                        } else {
                                $values['days'] = $defaults['days']; # default cutoff for shortlisters
                        }
@@ -177,7 +177,7 @@ class SpecialWatchlist extends SpecialPage {
                        wfAppendToArrayIfNotDefault( $name, $values[$name], $defaults, $nondefaults );
                }
 
-               if( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
+               if ( ( $wgEnotifWatchlist || $wgShowUpdatedMarker ) && $request->getVal( 'reset' ) &&
                        $request->wasPosted() )
                {
                        $user->clearAllNotifications();
@@ -188,7 +188,7 @@ class SpecialWatchlist extends SpecialPage {
                # Possible where conditions
                $conds = array();
 
-               if( $values['days'] > 0 ) {
+               if ( $values['days'] > 0 ) {
                        $conds[] = 'rc_timestamp > ' . $dbr->addQuotes( $dbr->timestamp( time() - intval( $values['days'] * 86400 ) ) );
                }
 
@@ -201,19 +201,19 @@ class SpecialWatchlist extends SpecialPage {
                # Up estimate of watched items by 15% to compensate for talk pages...
 
                # Toggles
-               if( $values['hideOwn'] ) {
+               if ( $values['hideOwn'] ) {
                        $conds[] = 'rc_user != ' . $user->getId();
                }
-               if( $values['hideBots'] ) {
+               if ( $values['hideBots'] ) {
                        $conds[] = 'rc_bot = 0';
                }
-               if( $values['hideMinor'] ) {
+               if ( $values['hideMinor'] ) {
                        $conds[] = 'rc_minor = 0';
                }
-               if( $values['hideLiu'] ) {
+               if ( $values['hideLiu'] ) {
                        $conds[] = 'rc_user = 0';
                }
-               if( $values['hideAnons'] ) {
+               if ( $values['hideAnons'] ) {
                        $conds[] = 'rc_user != 0';
                }
                if ( $user->useRCPatrol() && $values['hidePatrolled'] ) {
@@ -224,7 +224,7 @@ class SpecialWatchlist extends SpecialPage {
                }
 
                # Toggle watchlist content (all recent edits or just the latest)
-               if( $values['extended'] ) {
+               if ( $values['extended'] ) {
                        $limitWatchlist = $user->getIntOption( 'wllimit' );
                        $usePage = false;
                } else {
@@ -236,31 +236,40 @@ class SpecialWatchlist extends SpecialPage {
 
                # Show a message about slave lag, if applicable
                $lag = wfGetLB()->safeGetLag( $dbr );
-               if( $lag > 0 ) {
+               if ( $lag > 0 ) {
                        $output->showLagWarning( $lag );
                }
 
                # Create output form
-               $form = Xml::fieldset( $this->msg( 'watchlist-options' )->text(), false, array( 'id' => 'mw-watchlist-options' ) );
+               $form = Xml::fieldset(
+                       $this->msg( 'watchlist-options' )->text(),
+                       false,
+                       array( 'id' => 'mw-watchlist-options' )
+               );
 
                # Show watchlist header
+               $form .= "<p>";
                $form .= $this->msg( 'watchlist-details' )->numParams( $nitems )->parse() . "\n";
-
-               if( $user->getOption( 'enotifwatchlistpages' ) && $wgEnotifWatchlist ) {
-                       $form .= $this->msg( 'wlheader-enotif' )->parseAsBlock() . "\n";
+               if ( $wgEnotifWatchlist && $user->getOption( 'enotifwatchlistpages' ) ) {
+                       $form .= $this->msg( 'wlheader-enotif' )->parse() . "\n";
+               }
+               if ( $wgShowUpdatedMarker ) {
+                       $form .= $this->msg( 'wlheader-showupdated' )->parse() . "\n";
                }
-               if( $wgShowUpdatedMarker ) {
+               $form .= "</p>";
+
+               if ( $wgShowUpdatedMarker ) {
                        $form .= Xml::openElement( 'form', array( 'method' => 'post',
-                                               'action' => $this->getTitle()->getLocalURL(),
-                                               'id' => 'mw-watchlist-resetbutton' ) ) . "\n" .
-                                       $this->msg( 'wlheader-showupdated' )->parse() .
-                                       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";
+                               '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 .= "<hr />\n";
 
                $tables = array( 'recentchanges', 'watchlist' );
@@ -276,10 +285,10 @@ class SpecialWatchlist extends SpecialPage {
                        ),
                );
                $options = array( 'ORDER BY' => 'rc_timestamp DESC' );
-               if( $wgShowUpdatedMarker ) {
+               if ( $wgShowUpdatedMarker ) {
                        $fields[] = 'wl_notificationtimestamp';
                }
-               if( $limitWatchlist ) {
+               if ( $limitWatchlist ) {
                        $options['LIMIT'] = $limitWatchlist;
                }
 
@@ -302,7 +311,7 @@ class SpecialWatchlist extends SpecialPage {
 
                $lang = $this->getLanguage();
                $wlInfo = '';
-               if( $values['days'] > 0 ) {
+               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";
@@ -312,11 +321,11 @@ class SpecialWatchlist extends SpecialPage {
 
                # Spit out some control panel links
                $filters = array(
-                       'hideMinor'     => 'rcshowhideminor',
-                       'hideBots'              => 'rcshowhidebots',
-                       'hideAnons'     => 'rcshowhideanons',
-                       'hideLiu'               => 'rcshowhideliu',
-                       'hideOwn'               => 'rcshowhidemine',
+                       'hideMinor' => 'rcshowhideminor',
+                       'hideBots' => 'rcshowhidebots',
+                       'hideAnons' => 'rcshowhideanons',
+                       'hideLiu' => 'rcshowhideliu',
+                       'hideOwn' => 'rcshowhidemine',
                        'hidePatrolled' => 'rcshowhidepatr'
                );
                foreach ( $this->customFilters as $key => $params ) {
@@ -328,7 +337,7 @@ class SpecialWatchlist extends SpecialPage {
                }
 
                $links = array();
-               foreach( $filters as $name => $msg ) {
+               foreach ( $filters as $name => $msg ) {
                        $links[] = $this->showHideLink( $nondefaults, $msg, $name, $values[$name] );
                }
 
@@ -349,8 +358,8 @@ class SpecialWatchlist extends SpecialPage {
                                'all' => '',
                                'label' => $this->msg( 'namespace' )->text()
                        ), array(
-                               'name'  => 'namespace',
-                               'id'    => 'namespace',
+                               'name' => 'namespace',
+                               'id' => 'namespace',
                                'class' => 'namespaceselector',
                        )
                ) . '&#160;';
@@ -377,8 +386,10 @@ class SpecialWatchlist extends SpecialPage {
                $output->addHTML( $form );
 
                # If there's nothing to show, stop here
-               if( $numRows == 0 ) {
-                       $output->addWikiMsg( 'watchnochange' );
+               if ( $numRows == 0 ) {
+                       $output->wrapWikiMsg(
+                               "<div class='mw-changeslist-empty'>\n$1\n</div>", 'recentchanges-noresult'
+                       );
                        return;
                }
 
@@ -469,17 +480,19 @@ class SpecialWatchlist extends SpecialPage {
        /**
         * Returns html
         *
+        * @param int $days This gets overwritten, so is not used
+        * @param array $options Query parameters for URL
         * @return string
         */
        protected function cutoffLinks( $days, $options = array() ) {
                $hours = array( 1, 2, 6, 12 );
                $days = array( 1, 3, 7 );
                $i = 0;
-               foreach( $hours as $h ) {
+               foreach ( $hours as $h ) {
                        $hours[$i++] = $this->hoursLink( $h, $options );
                }
                $i = 0;
-               foreach( $days as $d ) {
+               foreach ( $days as $d ) {
                        $days[$i++] = $this->daysLink( $d, $options );
                }
                return $this->msg( 'wlshowlast' )->rawParams(