X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialEditWatchlist.php;h=76f2f4a940a5603420d082bc07c2d71d86684fec;hb=14f1a1c238dd70d34ff3068008cd13cea43d01e7;hp=0896929a66500f6c02d695edd46b025b6a1aa442;hpb=66d3eb56afc737e4e5ee66f7cad1dc78d1aec6b0;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 0896929a66..76f2f4a940 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -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 ); @@ -538,23 +554,26 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $count = 0; foreach ( $this->getWatchlistInfo() as $namespace => $pages ) { - if ( $namespace >= 0 ) { - $fields['TitlesNs' . $namespace] = array( - 'class' => 'EditWatchlistCheckboxSeriesField', - 'options' => array(), - 'section' => "ns$namespace", - ); - } + $options = array(); foreach ( array_keys( $pages ) as $dbkey ) { $title = Title::makeTitleSafe( $namespace, $dbkey ); if ( $this->checkTitle( $title, $namespace, $dbkey ) ) { $text = $this->buildRemoveLine( $title ); - $fields['TitlesNs' . $namespace]['options'][$text] = $title->getPrefixedText(); + $options[$text] = $title->getPrefixedText(); $count++; } } + + // checkTitle can filter some options out, avoid empty sections + if ( count( $options ) > 0 ) { + $fields['TitlesNs' . $namespace] = array( + 'class' => 'EditWatchlistCheckboxSeriesField', + 'options' => $options, + 'section' => "ns$namespace", + ); + } } $this->cleanupWatchlist();