r102334 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r102333‎ | r102334 | r102335 >
Date:22:11, 7 November 2011
Author:happy-melon
Status:ok (Comments)
Tags:
Comment:
(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).
Modified paths:
  • /trunk/phase3/includes/specials/SpecialEditWatchlist.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/specials/SpecialEditWatchlist.php
@@ -18,6 +18,8 @@
1919
2020 protected $successMessage;
2121
 22+ protected $toc;
 23+
2224 public function __construct(){
2325 parent::__construct( 'EditWatchlist' );
2426 }
@@ -90,6 +92,8 @@
9193 if( $form->show() ){
9294 $out->addHTML( $this->successMessage );
9395 $out->returnToMain();
 96+ } elseif ( $this->toc !== false ) {
 97+ $out->prependHTML( $this->toc );
9498 }
9599 break;
96100 }
@@ -382,10 +386,6 @@
383387 $haveInvalidNamespaces = true;
384388 continue;
385389 }
386 -
387 - $namespace == NS_MAIN
388 - ? wfMsgHtml( 'blanknamespace' )
389 - : htmlspecialchars( $wgContLang->getFormattedNsText( $namespace ) );
390390
391391 $fields['TitlesNs'.$namespace] = array(
392392 'class' => 'EditWatchlistCheckboxSeriesField',
@@ -397,6 +397,7 @@
398398 $title = Title::makeTitleSafe( $namespace, $dbkey );
399399 $text = $this->buildRemoveLine( $title );
400400 $fields['TitlesNs'.$namespace]['options'][$text] = $title->getEscapedText();
 401+ $count++;
401402 }
402403 }
403404 if ( $haveInvalidNamespaces ) {
@@ -404,6 +405,21 @@
405406 $this->getContext()->getUser()->cleanupWatchlist();
406407 }
407408
 409+ if ( count( $fields ) > 1 && $count > 30 ) {
 410+ $this->toc = Linker::tocIndent();
 411+ $tocLength = 0;
 412+ foreach( $fields as $key => $data ) {
 413+ $ns = substr( $data['section'], 2 );
 414+ $nsText = $ns == NS_MAIN
 415+ ? wfMsgHtml( 'blanknamespace' )
 416+ : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
 417+ -$this->toc .= Linker::tocLine( "mw-htmlform-{$data['section']}", $nsText, ++$tocLength, 1 ) . Linker::tocLineEnd();
 418+ }
 419+ $this->toc = Linker::tocList( $this->toc );
 420+ } else {
 421+ $this->toc = false;
 422+ }
 423+
408424 $form = new EditWatchlistNormalHTMLForm( $fields, $this->getContext() );
409425 $form->setTitle( $this->getTitle() );
410426 $form->setSubmitText( wfMessage( 'watchlistedit-normal-submit' )->text() );

Follow-up revisions

RevisionCommit summaryAuthorDate
r102335Follow-up r102334: odd that this minus sign (yes, copied from a diff) was act...happy-melon22:15, 7 November 2011
r102393add quick comment from r102334 crhashar12:07, 8 November 2011
r102546REL1_18 MFT r102334, r102335reedy17:40, 9 November 2011
r1025981.18wmf1 MFT r101445, r101464, r101666, r101802, r101860, r101990, r102297, r...reedy23:20, 9 November 2011
r102892Localise numbers in TOC added in r102334robin12:46, 13 November 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r84718Move WatchlistEditor.php to /specials since inside it is essentially a comple...happy-melon23:28, 24 March 2011

Comments

#Comment by Hashar (talk | contribs)   22:29, 7 November 2011

seems to fix a regression

#Comment by Nikerabbit (talk | contribs)   09:45, 8 November 2011

That's the leading "-" in the last line of the loop?

#Comment by Nikerabbit (talk | contribs)   09:47, 8 November 2011

Bad bunny, didn't notice the followup. Could perhaps explain where the number 2 comes in

$ns = substr( $data['section'], 2 );
#Comment by Happy-melon (talk | contribs)   11:22, 8 November 2011

$data['section'] = "ns$namespace", so we need to strip the "ns" off the front again.

#Comment by Hashar (talk | contribs)   12:07, 8 November 2011

Comment added with r102393 :D

#Comment by Duplicatebug (talk | contribs)   16:12, 14 November 2011

The TOC shows the namespace always in content language, but the title of the fieldset is in user language.

The id should at the fieldset or legend tag and not at the table, because now you does not see the header of that table when using the toc.

#Comment by Duplicatebug (talk | contribs)   10:36, 15 November 2011

>The id should at the fieldset or legend tag and not at the table, because now you does not see the header of that table when using the toc.

bug 32412

Status & tagging log