Bug 32673: Keep the username in the input field if not existing
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index bf69607..cde2ca3 100644 (file)
@@ -47,19 +47,12 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        return;
                }
 
-               if ( wfReadOnly() ) {
-                       throw new ReadOnlyError;
-               }
+               $this->checkPermissions();
 
                $this->outputHeader();
 
-               $sub  = wfMsgExt(
-                       'watchlistfor2',
-                       array( 'parseinline', 'replaceafter' ),
-                       $this->getUser()->getName(),
-                       SpecialEditWatchlist::buildTools( null )
-               );
-               $out->setSubtitle( $sub );
+               $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
@@ -142,26 +135,33 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                        }
 
                        if( count( $toWatch ) > 0 ) {
-                               $this->successMessage .= wfMessage(
+                               $this->successMessage .= ' ' . wfMessage(
                                        'watchlistedit-raw-added',
-                                       $this->getLang()->formatNum( count( $toWatch ) )
+                                       $this->getLanguage()->formatNum( count( $toWatch ) )
                                );
                                $this->showTitles( $toWatch, $this->successMessage );
                        }
 
                        if( count( $toUnwatch ) > 0 ) {
-                               $this->successMessage .= wfMessage(
+                               $this->successMessage .= ' ' . wfMessage(
                                        'watchlistedit-raw-removed',
-                                       $this->getLang()->formatNum( count( $toUnwatch ) )
+                                       $this->getLanguage()->formatNum( count( $toUnwatch ) )
                                );
                                $this->showTitles( $toUnwatch, $this->successMessage );
                        }
                } else {
                        $this->clearWatchlist();
                        $this->getUser()->invalidateCache();
-                       $this->successMessage .= wfMessage(
+
+                       if( count( $current ) > 0 ){
+                               $this->successMessage = wfMessage( 'watchlistedit-raw-done' )->parse();
+                       } else {
+                               return false;
+                       }
+
+                       $this->successMessage .= ' ' . wfMessage(
                                'watchlistedit-raw-removed',
-                               $this->getLang()->formatNum( count( $current ) )
+                               $this->getLanguage()->formatNum( count( $current ) )
                        );
                        $this->showTitles( $current, $this->successMessage );
                }
@@ -237,8 +237,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
        /**
         * Get a list of titles on a user's watchlist, excluding talk pages,
-        * and return as a two-dimensional array with namespace, title and
-        * redirect status
+        * and return as a two-dimensional array with namespace and title.
         *
         * @return array
         */
@@ -258,7 +257,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                foreach ( $res as $row ) {
                        $lb->add( $row->wl_namespace, $row->wl_title );
                        if ( !MWNamespace::isTalk( $row->wl_namespace ) ) {
-                               $titles[$row->wl_namespace][$row->wl_title] = false;
+                               $titles[$row->wl_namespace][$row->wl_title] = 1;
                        }
                }
 
@@ -361,7 +360,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                if( count( $removed ) > 0 ) {
                        $this->successMessage = wfMessage(
                                'watchlistedit-normal-done',
-                               $this->getLang()->formatNum( count( $removed ) )
+                               $this->getLanguage()->formatNum( count( $removed ) )
                        );
                        $this->showTitles( $removed, $this->successMessage );
                        return true;
@@ -417,7 +416,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                                $nsText = ($ns == NS_MAIN)
                                        ? wfMsgHtml( 'blanknamespace' )
                                        : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
-                               $this->toc .= Linker::tocLine( "mw-htmlform-{$data['section']}", $nsText, ++$tocLength, 1 ) . Linker::tocLineEnd();
+                               $this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
+                                       $this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
                        }
                        $this->toc = Linker::tocList( $this->toc );
                } else {
@@ -463,7 +463,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                wfRunHooks( 'WatchlistEditorBuildRemoveLine', array( &$tools, $title, $title->isRedirect(), $this->getSkin() ) );
 
-               return $link . " (" . $this->getLang()->pipeList( $tools ) . ")";
+               return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
        }
 
        /**
@@ -557,7 +557,10 @@ class EditWatchlistNormalHTMLForm extends HTMLForm {
                $namespace = substr( $namespace, 2 );
                return $namespace == NS_MAIN
                        ? wfMsgHtml( 'blanknamespace' )
-                       : htmlspecialchars( $this->getContext()->getLang()->getFormattedNsText( $namespace ) );
+                       : htmlspecialchars( $this->getContext()->getLanguage()->getFormattedNsText( $namespace ) );
+       }
+       public function getBody() {
+               return $this->displaySection( $this->mFieldTree, '', 'editwatchlist-' );
        }
 }