X-Git-Url: https://git.cyclocoop.org/%242?a=blobdiff_plain;f=includes%2Fspecials%2FSpecialEditWatchlist.php;h=4d1933f27566251ffcb8f76faa0f801e8cb9c524;hb=803515148a676af3018219887124ea949371b782;hp=0c860a5b9df0865d866b5deef0dce1d8e885446d;hpb=10de9847fbed73593641393c29868e0e7a68d309;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/specials/SpecialEditWatchlist.php b/includes/specials/SpecialEditWatchlist.php index 0c860a5b9d..4d1933f275 100644 --- a/includes/specials/SpecialEditWatchlist.php +++ b/includes/specials/SpecialEditWatchlist.php @@ -93,6 +93,14 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) ); } break; + case self::EDIT_CLEAR: + $out->setPageTitle( $this->msg( 'watchlistedit-clear-title' ) ); + $form = $this->getClearForm(); + if ( $form->show() ) { + $out->addHTML( $this->successMessage ); + $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) ); + } + break; case self::EDIT_NORMAL: default: @@ -191,6 +199,18 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { return true; } + public function submitClear( $data ) { + $current = $this->getWatchlist(); + $this->clearWatchlist(); + $this->getUser()->invalidateCache(); + $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse(); + $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' ) + ->numParams( count( $current ) )->parse(); + $this->showTitles( $current, $this->successMessage ); + + return true; +} + /** * Print out a list of linked titles * @@ -204,6 +224,10 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { $talk = $this->msg( 'talkpagelinktext' )->escaped(); // Do a batch existence check $batch = new LinkBatch(); + if (count($titles) >= 100) { + $output = wfMessage( 'watchlistedit-too-many' )->parse(); + return; + } foreach ( $titles as $title ) { if ( !$title instanceof Title ) { $title = Title::newFromText( $title ); @@ -611,6 +635,25 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { return $form; } + /** + * Get a form for clearing the watchlist + * + * @return HTMLForm + */ + protected function getClearForm() { + $context = new DerivativeContext( $this->getContext() ); + $context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage + $form = new HTMLForm( array(), $context ); + $form->setSubmitTextMsg( 'watchlistedit-clear-submit' ); + # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit' + $form->setSubmitTooltip( 'watchlistedit-clear-submit' ); + $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' ); + $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() ); + $form->setSubmitCallback( array( $this, 'submitClear' ) ); + + return $form; + } + /** * Determine whether we are editing the watchlist, and if so, what * kind of editing operation @@ -625,6 +668,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { switch ( $mode ) { case 'clear': case self::EDIT_CLEAR: + return self::EDIT_CLEAR; case 'raw': case self::EDIT_RAW: return self::EDIT_RAW; @@ -651,6 +695,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { 'view' => array( 'Watchlist', false ), 'edit' => array( 'EditWatchlist', false ), 'raw' => array( 'EditWatchlist', 'raw' ), + 'clear' => array( 'EditWatchlist', 'clear' ), ); foreach ( $modes as $mode => $arr ) { @@ -669,10 +714,6 @@ class SpecialEditWatchlist extends UnlistedSpecialPage { } } -# B/C since 1.18 -class WatchlistEditor extends SpecialEditWatchlist { -} - /** * Extend HTMLForm purely so we can have a more sane way of getting the section headers */