(bug 16635) Add TOC to Special:Watchlist/edit
authorIlmari Karonen <vyznev@users.mediawiki.org>
Sat, 13 Dec 2008 22:45:18 +0000 (22:45 +0000)
committerIlmari Karonen <vyznev@users.mediawiki.org>
Sat, 13 Dec 2008 22:45:18 +0000 (22:45 +0000)
RELEASE-NOTES
includes/WatchlistEditor.php

index 37a98d1..866e81f 100644 (file)
@@ -227,6 +227,8 @@ The following extensions are migrated into MediaWiki 1.14:
   as 1.3 (gfdl1_3).
 * (bug 16293) PD URL was changed to the CreativeCommons site on PD (which auto-detects 
   your language) instead of Wikipedia.
+* (bug 16635) The "view and edit watchlist" page (Special:Watchlist/edit) now
+  includes a table of contents
 
 === Bug fixes in 1.14 ===
 
index 82c524c..e49851b 100644 (file)
@@ -344,21 +344,47 @@ class WatchlistEditor {
                        $form .= Xml::hidden( 'token', $wgUser->editToken( 'watchlistedit' ) );
                        $form .= "<fieldset>\n<legend>" . wfMsgHtml( 'watchlistedit-normal-legend' ) . "</legend>";
                        $form .= wfMsgExt( 'watchlistedit-normal-explain', 'parse' );
-                       foreach( $this->getWatchlistInfo( $user ) as $namespace => $pages ) {
-                               $form .= "<h2>" . $this->getNamespaceHeading( $namespace ) . "</h2>\n";
-                               $form .= "<ul>\n";
-                               foreach( $pages as $dbkey => $redirect ) {
-                                       $title = Title::makeTitleSafe( $namespace, $dbkey );
-                                       $form .= $this->buildRemoveLine( $title, $redirect, $wgUser->getSkin() );
-                               }
-                               $form .= "</ul>\n";
-                       }
+                       $form .= $this->buildRemoveList( $user, $wgUser->getSkin() );
                        $form .= '<p>' . Xml::submitButton( wfMsg( 'watchlistedit-normal-submit' ) ) . '</p>';
                        $form .= '</fieldset></form>';
                        $output->addHTML( $form );
                }
        }
 
+       /**
+        * Build the part of the standard watchlist editing form with the actual
+        * title selection checkboxes and stuff.  Also generates a table of
+        * contents if there's more than one heading.
+        *
+        * @param $user User
+        * @param $skin Skin (really, Linker)
+        */
+       private function buildRemoveList( $user, $skin ) {
+               $list = "";
+               $toc = $skin->tocIndent();
+               $tocLength = 0;
+               foreach( $this->getWatchlistInfo( $user ) as $namespace => $pages ) {
+                       $tocLength++;
+                       $heading = htmlspecialchars( $this->getNamespaceHeading( $namespace ) );
+                       $anchor = "editwatchlist-ns" . $namespace;
+
+                       $list .= $skin->makeHeadLine( 2, ">", $anchor, $heading, "" );
+                       $toc .= $skin->tocLine( $anchor, $heading, $tocLength, 1 ) . $skin->tocLineEnd();
+
+                       $list .= "<ul>\n";
+                       foreach( $pages as $dbkey => $redirect ) {
+                               $title = Title::makeTitleSafe( $namespace, $dbkey );
+                               $list .= $this->buildRemoveLine( $title, $redirect, $skin );
+                       }
+                       $list .= "</ul>\n";
+               }
+               // ISSUE: omit the TOC if the total number of titles is low?
+               if( $tocLength > 1 ) {
+                       $list = $skin->tocList( $toc ) . $list;
+               }
+               return $list;
+       }
+
        /**
         * Get the correct "heading" for a namespace
         *