Merge "Language: s/error_log/wfWarn/"
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index 6c258e0..3656b9c 100644 (file)
@@ -70,9 +70,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $this->checkReadOnly();
 
                $this->outputHeader();
-
-               $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
-                       ->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
+               $this->outputSubtitle();
 
                # B/C: $mode used to be waaay down the parameter list, and the first parameter
                # was $wgUser
@@ -104,19 +102,37 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                        case self::EDIT_NORMAL:
                        default:
-                               $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
-                               $form = $this->getNormalForm();
-                               if ( $form->show() ) {
-                                       $out->addHTML( $this->successMessage );
-                                       $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
-                               } elseif ( $this->toc !== false ) {
-                                       $out->prependHTML( $this->toc );
-                                       $out->addModules( 'mediawiki.toc' );
-                               }
+                       $this->executeViewEditWatchlist();
                                break;
                }
        }
 
+       /**
+        * Renders a subheader on the watchlist page.
+        */
+       protected function outputSubtitle() {
+               $out = $this->getOutput();
+               $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
+                       ->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
+       }
+
+       /**
+        * Executes an edit mode for the watchlist view, from which you can manage your watchlist
+        *
+        */
+       protected function executeViewEditWatchlist() {
+               $out = $this->getOutput();
+               $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
+               $form = $this->getNormalForm();
+               if ( $form->show() ) {
+                       $out->addHTML( $this->successMessage );
+                       $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
+               } elseif ( $this->toc !== false ) {
+                       $out->prependHTML( $this->toc );
+                       $out->addModules( 'mediawiki.toc' );
+               }
+       }
+
        /**
         * Return an array of subpages beginning with $search that this special page will accept.
         *
@@ -331,7 +347,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
         *
         * @return array
         */
-       private function getWatchlistInfo() {
+       protected function getWatchlistInfo() {
                $titles = array();
                $dbr = wfGetDB( DB_MASTER );
 
@@ -537,7 +553,15 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $fields = array();
                $count = 0;
 
-               foreach ( $this->getWatchlistInfo() as $namespace => $pages ) {
+               // Allow subscribers to manipulate the list of watched pages (or use it
+               // to preload lots of details at once)
+               $watchlistInfo = $this->getWatchlistInfo();
+               wfRunHooks(
+                       'WatchlistEditorBeforeFormRender',
+                       array( &$watchlistInfo )
+               );
+
+               foreach ( $watchlistInfo as $namespace => $pages ) {
                        $options = array();
 
                        foreach ( array_keys( $pages ) as $dbkey ) {
@@ -604,15 +628,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
        private function buildRemoveLine( $title ) {
                $link = Linker::link( $title );
 
-               if ( $title->isRedirect() ) {
-                       // Linker already makes class mw-redirect, so this is redundant
-                       $link = '<span class="watchlistredir">' . $link . '</span>';
-               }
-
-               $tools[] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
+               $tools['talk'] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
 
                if ( $title->exists() ) {
-                       $tools[] = Linker::linkKnown(
+                       $tools['history'] = Linker::linkKnown(
                                $title,
                                $this->msg( 'history_short' )->escaped(),
                                array(),
@@ -621,7 +640,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                }
 
                if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
-                       $tools[] = Linker::linkKnown(
+                       $tools['contributions'] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
                                $this->msg( 'contributions' )->escaped()
                        );
@@ -629,9 +648,14 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                wfRunHooks(
                        'WatchlistEditorBuildRemoveLine',
-                       array( &$tools, $title, $title->isRedirect(), $this->getSkin() )
+                       array( &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link )
                );
 
+               if ( $title->isRedirect() ) {
+                       // Linker already makes class mw-redirect, so this is redundant
+                       $link = '<span class="watchlistredir">' . $link . '</span>';
+               }
+
                return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
        }