From 1f793bb6897e3b52675033bbc101fa3972061db6 Mon Sep 17 00:00:00 2001 From: Happy-melon Date: Mon, 7 Nov 2011 22:11:04 +0000 Subject: [PATCH] (bug 31502) (follow-up r84718) Restore ToC to Special:EditWatchlist if there is more than one namespace and more than 30 titles total (also resolves the commented TODO in the pre-r84718 code). --- includes/specials/SpecialEditWatchlist.php | 24 ++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index fa16de9ebe..9fcd95eb87 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -18,6 +18,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { protected $successMessage; + protected $toc; + public function __construct(){ parent::__construct( 'EditWatchlist' ); } @@ -90,6 +92,8 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { if( $form->show() ){ $out->addHTML( $this->successMessage ); $out->returnToMain(); + } elseif ( $this->toc !== false ) { + $out->prependHTML( $this->toc ); } break; } @@ -382,10 +386,6 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $haveInvalidNamespaces = true; continue; } - - $namespace == NS_MAIN - ? wfMsgHtml( 'blanknamespace' ) - : htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) ); $fields['TitlesNs'.$namespace] = array( 'class' => 'EditWatchlistCheckboxSeriesField', @@ -397,6 +397,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $title = Title::makeTitleSafe( $namespace, $dbkey ); $text = $this->buildRemoveLine( $title ); $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText(); + $count++; } } if ( $haveInvalidNamespaces ) { @@ -404,6 +405,21 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $this->getContext()->getUser()->cleanupWatchlist(); } + if ( count( $fields ) > 1 && $count > 30 ) { + $this->toc = Linker::tocIndent(); + $tocLength = 0; + foreach( $fields as $key => $data ) { + $ns = substr( $data['section'], 2 ); + $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::tocList( $this->toc ); + } else { + $this->toc = false; + } + $form = new EditWatchlistNormalHTMLForm( $fields, $this->getContext() ); $form->setTitle( $this->getTitle() ); $form->setSubmitText( wfMessage( 'watchlistedit-normal-submit' )->text() ); -- 2.20.1