$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:
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
*
$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 );
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
switch ( $mode ) {
case 'clear':
case self::EDIT_CLEAR:
+ return self::EDIT_CLEAR;
case 'raw':
case self::EDIT_RAW:
return self::EDIT_RAW;
'view' => array( 'Watchlist', false ),
'edit' => array( 'EditWatchlist', false ),
'raw' => array( 'EditWatchlist', 'raw' ),
+ 'clear' => array( 'EditWatchlist', 'clear' ),
);
foreach ( $modes as $mode => $arr ) {
if ( $mode !== false ) {
if ( $mode === SpecialEditWatchlist::EDIT_RAW ) {
$title = SpecialPage::getTitleFor( 'EditWatchlist', 'raw' );
+ } elseif ( $mode === SpecialEditWatchlist::EDIT_CLEAR ) {
+ $title = SpecialPage::getTitleFor( 'EditWatchlist', 'clear' );
} else {
$title = SpecialPage::getTitleFor( 'EditWatchlist' );
}
"watchlistedit-normal-submit": "Remove titles",
"watchlistedit-normal-done": "{{PLURAL:$1|1 title was|$1 titles were}} removed from your watchlist:",
"watchlistedit-raw-title": "Edit raw watchlist",
- "watchlistedit-raw-legend": "Edit raw watchlist",
+ "watchlistedit-raw-legend": "Edit raw watchlist",
"watchlistedit-raw-explain": "Titles on your watchlist are shown below, and can be edited by adding to and removing from the list;\none title per line.\nWhen finished, click \"{{int:Watchlistedit-raw-submit}}\".\nYou can also [[Special:EditWatchlist|use the standard editor]].",
- "watchlistedit-raw-titles": "Titles:",
- "watchlistedit-raw-submit": "Update watchlist",
- "watchlistedit-raw-done": "Your watchlist has been updated.",
- "watchlistedit-raw-added": "{{PLURAL:$1|1 title was|$1 titles were}} added:",
- "watchlistedit-raw-removed": "{{PLURAL:$1|1 title was|$1 titles were}} removed:",
+ "watchlistedit-raw-titles": "Titles:",
+ "watchlistedit-raw-submit": "Update watchlist",
+ "watchlistedit-raw-done": "Your watchlist has been updated.",
+ "watchlistedit-raw-added": "{{PLURAL:$1|1 title was|$1 titles were}} added:",
+ "watchlistedit-raw-removed": "{{PLURAL:$1|1 title was|$1 titles were}} removed:",
+ "watchlistedit-clear-title": "Cleared watchlist",
+ "watchlistedit-clear-legend": "Clear watchlist",
+ "watchlistedit-clear-explain": "All of the titles will be removed from your watchlist",
+ "watchlistedit-clear-titles": "Titles:",
+ "watchlistedit-clear-submit": "Clear the watchlist (This is permanent!)",
+ "watchlistedit-clear-done": "Your watchlist has been cleared.",
+ "watchlistedit-clear-removed": "{{PLURAL:$1|1 title was|$1 titles were}} removed:",
+ "watchlistedit-too-many": "There are too many pages to display here.",
+ "watchlisttools-clear": "Clear the watchlist",
"watchlisttools-view": "View relevant changes",
"watchlisttools-edit": "View and edit watchlist",
"watchlisttools-raw": "Edit raw watchlist",
"watchlistedit-raw-done": "A message which appears after the raw watchlist has been updated using [[Special:Watchlist/raw]].",
"watchlistedit-raw-added": "Message on [[Special:EditWatchlist/raw]].\n\nThe message appears after at least 1 message is added to the raw watchlist.\n\nFollowed by list of page titles which are added.\n\nParameters:\n* $1 - number of page titles which are added\nSee also:\n* {{msg-mw|Watchlistedit-normal-done}}\n* {{msg-mw|Watchlistedit-raw-removed}}",
"watchlistedit-raw-removed": "Message on [[Special:EditWatchlist/raw]].\n\nThe message appears after at least 1 message is deleted from the raw watchlist.\n\nFollowed by list of page titles which are removed.\n\nParameters:\n* $1 - number of page titles which are removed\nSee also:\n* {{msg-mw|Watchlistedit-normal-done}}\n* {{msg-mw|Watchlistedit-raw-added}}",
+ "watchlistedit-clear-title": "Title of [[Special:Watchlist/clear|Special page]].\n\n{{Identical|Clear watchlist}}",
+ "watchlistedit-clear-legend": "Heading of dialogue box on [[Special:Watchlist/clear]].\n\n{{Identical|Edit clear watchlist}}",
+ "watchlistedit-clear-explain": "All of the titles will be removed from your watchlist",
+ "watchlistedit-clear-titles": "Text above edit box containing items being watched on [[Special:Watchlist/clear]].\n{{Identical|Title}}",
+ "watchlistedit-clear-submit": "Text of submit button on [[Special:Watchlist/clear]].\n\nSee also:\n* {{msg-mw|Watchlistedit-clear-submit}}\n* {{msg-mw|Tooltip-watchlistedit-clear-submit}}",
+ "watchlistedit-clear-done": "A message which appears after the watchlist has been cleared using [[Special:Watchlist/clear]].",
+ "watchlistedit-clear-removed": "Message on [[Special:EditWatchlist/clear]].\n\nThe message appears once the watchlist has been cleared.",
+ "watchlistedit-too-many": "Message on [[Special:EditWatchlist]] that is used when there are too many titles to display.",
+ "watchlisttools-clear": "[[Special:Watchlist]]: Navigation link under the title.\n\nSee also:\n* {{msg-mw|watchlisttools-clear}}\n* {{msg-mw|watchlisttools-clear}}",
"watchlisttools-view": "[[Special:Watchlist]]: Navigation link under the title.\n\nSee also:\n* {{msg-mw|watchlisttools-edit}}\n* {{msg-mw|watchlisttools-raw}}",
"watchlisttools-edit": "[[Special:Watchlist]]: Navigation link under the title.\n\nSee also:\n* {{msg-mw|Watchlisttools-view}}\n* {{msg-mw|Watchlisttools-raw}}",
"watchlisttools-raw": "[[Special:Watchlist]]: Navigation link under the title.\n\nSee also:\n* {{msg-mw|watchlisttools-view}}\n* {{msg-mw|watchlisttools-edit}}\n{{Identical|Edit raw watchlist}}",