mediawiki.page.gallery.resize: Remove weird mw.hook call
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
1 <?php
2 /**
3 * @defgroup Watchlist Users watchlist handling
4 */
5
6 /**
7 * Implements Special:EditWatchlist
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 2 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License along
20 * with this program; if not, write to the Free Software Foundation, Inc.,
21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * http://www.gnu.org/copyleft/gpl.html
23 *
24 * @file
25 * @ingroup SpecialPage
26 * @ingroup Watchlist
27 */
28
29 /**
30 * Provides the UI through which users can perform editing
31 * operations on their watchlist
32 *
33 * @ingroup SpecialPage
34 * @ingroup Watchlist
35 * @author Rob Church <robchur@gmail.com>
36 */
37 class SpecialEditWatchlist extends UnlistedSpecialPage {
38 /**
39 * Editing modes. EDIT_CLEAR is no longer used; the "Clear" link scared people
40 * too much. Now it's passed on to the raw editor, from which it's very easy to clear.
41 */
42 const EDIT_CLEAR = 1;
43 const EDIT_RAW = 2;
44 const EDIT_NORMAL = 3;
45
46 protected $successMessage;
47
48 protected $toc;
49
50 private $badItems = array();
51
52 public function __construct() {
53 parent::__construct( 'EditWatchlist', 'editmywatchlist' );
54 }
55
56 /**
57 * Main execution point
58 *
59 * @param int $mode
60 */
61 public function execute( $mode ) {
62 $this->setHeaders();
63
64 # Anons don't get a watchlist
65 $this->requireLogin( 'watchlistanontext' );
66
67 $out = $this->getOutput();
68
69 $this->checkPermissions();
70 $this->checkReadOnly();
71
72 $this->outputHeader();
73
74 $out->addSubtitle( $this->msg( 'watchlistfor2', $this->getUser()->getName() )
75 ->rawParams( SpecialEditWatchlist::buildTools( null ) ) );
76
77 # B/C: $mode used to be waaay down the parameter list, and the first parameter
78 # was $wgUser
79 if ( $mode instanceof User ) {
80 $args = func_get_args();
81 if ( count( $args ) >= 4 ) {
82 $mode = $args[3];
83 }
84 }
85 $mode = self::getMode( $this->getRequest(), $mode );
86
87 switch ( $mode ) {
88 case self::EDIT_RAW:
89 $out->setPageTitle( $this->msg( 'watchlistedit-raw-title' ) );
90 $form = $this->getRawForm();
91 if ( $form->show() ) {
92 $out->addHTML( $this->successMessage );
93 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
94 }
95 break;
96 case self::EDIT_CLEAR:
97 $out->setPageTitle( $this->msg( 'watchlistedit-clear-title' ) );
98 $form = $this->getClearForm();
99 if ( $form->show() ) {
100 $out->addHTML( $this->successMessage );
101 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
102 }
103 break;
104
105 case self::EDIT_NORMAL:
106 default:
107 $out->setPageTitle( $this->msg( 'watchlistedit-normal-title' ) );
108 $form = $this->getNormalForm();
109 if ( $form->show() ) {
110 $out->addHTML( $this->successMessage );
111 $out->addReturnTo( SpecialPage::getTitleFor( 'Watchlist' ) );
112 } elseif ( $this->toc !== false ) {
113 $out->prependHTML( $this->toc );
114 $out->addModules( 'mediawiki.toc' );
115 }
116 break;
117 }
118 }
119
120 /**
121 * Return an array of subpages beginning with $search that this special page will accept.
122 *
123 * @param string $search Prefix to search for
124 * @param integer $limit Maximum number of results to return
125 * @return string[] Matching subpages
126 */
127 public function prefixSearchSubpages( $search, $limit = 10 ) {
128 // SpecialWatchlist uses SpecialEditWatchlist::getMode, so new types should be added
129 // here and there - no 'edit' here, because that the default for this page
130 $subpages = array( 'clear', 'raw' );
131 $escaped = preg_quote( $search );
132 return array_slice( preg_grep( "/^$escaped/i", $subpages ), 0, $limit );
133 }
134
135 /**
136 * Extract a list of titles from a blob of text, returning
137 * (prefixed) strings; unwatchable titles are ignored
138 *
139 * @param string $list
140 * @return array
141 */
142 private function extractTitles( $list ) {
143 $list = explode( "\n", trim( $list ) );
144 if ( !is_array( $list ) ) {
145 return array();
146 }
147
148 $titles = array();
149
150 foreach ( $list as $text ) {
151 $text = trim( $text );
152 if ( strlen( $text ) > 0 ) {
153 $title = Title::newFromText( $text );
154 if ( $title instanceof Title && $title->isWatchable() ) {
155 $titles[] = $title;
156 }
157 }
158 }
159
160 GenderCache::singleton()->doTitlesArray( $titles );
161
162 $list = array();
163 /** @var Title $title */
164 foreach ( $titles as $title ) {
165 $list[] = $title->getPrefixedText();
166 }
167
168 return array_unique( $list );
169 }
170
171 public function submitRaw( $data ) {
172 $wanted = $this->extractTitles( $data['Titles'] );
173 $current = $this->getWatchlist();
174
175 if ( count( $wanted ) > 0 ) {
176 $toWatch = array_diff( $wanted, $current );
177 $toUnwatch = array_diff( $current, $wanted );
178 $this->watchTitles( $toWatch );
179 $this->unwatchTitles( $toUnwatch );
180 $this->getUser()->invalidateCache();
181
182 if ( count( $toWatch ) > 0 || count( $toUnwatch ) > 0 ) {
183 $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
184 } else {
185 return false;
186 }
187
188 if ( count( $toWatch ) > 0 ) {
189 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-added' )
190 ->numParams( count( $toWatch ) )->parse();
191 $this->showTitles( $toWatch, $this->successMessage );
192 }
193
194 if ( count( $toUnwatch ) > 0 ) {
195 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
196 ->numParams( count( $toUnwatch ) )->parse();
197 $this->showTitles( $toUnwatch, $this->successMessage );
198 }
199 } else {
200 $this->clearWatchlist();
201 $this->getUser()->invalidateCache();
202
203 if ( count( $current ) > 0 ) {
204 $this->successMessage = $this->msg( 'watchlistedit-raw-done' )->parse();
205 } else {
206 return false;
207 }
208
209 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-raw-removed' )
210 ->numParams( count( $current ) )->parse();
211 $this->showTitles( $current, $this->successMessage );
212 }
213
214 return true;
215 }
216
217 public function submitClear( $data ) {
218 $current = $this->getWatchlist();
219 $this->clearWatchlist();
220 $this->getUser()->invalidateCache();
221 $this->successMessage = $this->msg( 'watchlistedit-clear-done' )->parse();
222 $this->successMessage .= ' ' . $this->msg( 'watchlistedit-clear-removed' )
223 ->numParams( count( $current ) )->parse();
224 $this->showTitles( $current, $this->successMessage );
225
226 return true;
227 }
228
229 /**
230 * Print out a list of linked titles
231 *
232 * $titles can be an array of strings or Title objects; the former
233 * is preferred, since Titles are very memory-heavy
234 *
235 * @param array $titles Array of strings, or Title objects
236 * @param string $output
237 */
238 private function showTitles( $titles, &$output ) {
239 $talk = $this->msg( 'talkpagelinktext' )->escaped();
240 // Do a batch existence check
241 $batch = new LinkBatch();
242 if (count($titles) >= 100) {
243 $output = wfMessage( 'watchlistedit-too-many' )->parse();
244 return;
245 }
246 foreach ( $titles as $title ) {
247 if ( !$title instanceof Title ) {
248 $title = Title::newFromText( $title );
249 }
250
251 if ( $title instanceof Title ) {
252 $batch->addObj( $title );
253 $batch->addObj( $title->getTalkPage() );
254 }
255 }
256
257 $batch->execute();
258
259 // Print out the list
260 $output .= "<ul>\n";
261
262 foreach ( $titles as $title ) {
263 if ( !$title instanceof Title ) {
264 $title = Title::newFromText( $title );
265 }
266
267 if ( $title instanceof Title ) {
268 $output .= "<li>"
269 . Linker::link( $title )
270 . ' (' . Linker::link( $title->getTalkPage(), $talk )
271 . ")</li>\n";
272 }
273 }
274
275 $output .= "</ul>\n";
276 }
277
278 /**
279 * Prepare a list of titles on a user's watchlist (excluding talk pages)
280 * and return an array of (prefixed) strings
281 *
282 * @return array
283 */
284 private function getWatchlist() {
285 $list = array();
286 $dbr = wfGetDB( DB_MASTER );
287
288 $res = $dbr->select(
289 'watchlist',
290 array(
291 'wl_namespace', 'wl_title'
292 ), array(
293 'wl_user' => $this->getUser()->getId(),
294 ),
295 __METHOD__
296 );
297
298 if ( $res->numRows() > 0 ) {
299 $titles = array();
300 foreach ( $res as $row ) {
301 $title = Title::makeTitleSafe( $row->wl_namespace, $row->wl_title );
302
303 if ( $this->checkTitle( $title, $row->wl_namespace, $row->wl_title )
304 && !$title->isTalkPage()
305 ) {
306 $titles[] = $title;
307 }
308 }
309 $res->free();
310
311 GenderCache::singleton()->doTitlesArray( $titles );
312
313 foreach ( $titles as $title ) {
314 $list[] = $title->getPrefixedText();
315 }
316 }
317
318 $this->cleanupWatchlist();
319
320 return $list;
321 }
322
323 /**
324 * Get a list of titles on a user's watchlist, excluding talk pages,
325 * and return as a two-dimensional array with namespace and title.
326 *
327 * @return array
328 */
329 private function getWatchlistInfo() {
330 $titles = array();
331 $dbr = wfGetDB( DB_MASTER );
332
333 $res = $dbr->select(
334 array( 'watchlist' ),
335 array( 'wl_namespace', 'wl_title' ),
336 array( 'wl_user' => $this->getUser()->getId() ),
337 __METHOD__,
338 array( 'ORDER BY' => array( 'wl_namespace', 'wl_title' ) )
339 );
340
341 $lb = new LinkBatch();
342
343 foreach ( $res as $row ) {
344 $lb->add( $row->wl_namespace, $row->wl_title );
345 if ( !MWNamespace::isTalk( $row->wl_namespace ) ) {
346 $titles[$row->wl_namespace][$row->wl_title] = 1;
347 }
348 }
349
350 $lb->execute();
351
352 return $titles;
353 }
354
355 /**
356 * Validates watchlist entry
357 *
358 * @param Title $title
359 * @param int $namespace
360 * @param string $dbKey
361 * @return bool Whether this item is valid
362 */
363 private function checkTitle( $title, $namespace, $dbKey ) {
364 if ( $title
365 && ( $title->isExternal()
366 || $title->getNamespace() < 0
367 )
368 ) {
369 $title = false; // unrecoverable
370 }
371
372 if ( !$title
373 || $title->getNamespace() != $namespace
374 || $title->getDBkey() != $dbKey
375 ) {
376 $this->badItems[] = array( $title, $namespace, $dbKey );
377 }
378
379 return (bool)$title;
380 }
381
382 /**
383 * Attempts to clean up broken items
384 */
385 private function cleanupWatchlist() {
386 if ( !count( $this->badItems ) ) {
387 return; //nothing to do
388 }
389
390 $dbw = wfGetDB( DB_MASTER );
391 $user = $this->getUser();
392
393 foreach ( $this->badItems as $row ) {
394 list( $title, $namespace, $dbKey ) = $row;
395 $action = $title ? 'cleaning up' : 'deleting';
396 wfDebug( "User {$user->getName()} has broken watchlist item ns($namespace):$dbKey, $action.\n" );
397
398 $dbw->delete( 'watchlist',
399 array(
400 'wl_user' => $user->getId(),
401 'wl_namespace' => $namespace,
402 'wl_title' => $dbKey,
403 ),
404 __METHOD__
405 );
406
407 // Can't just do an UPDATE instead of DELETE/INSERT due to unique index
408 if ( $title ) {
409 $user->addWatch( $title );
410 }
411 }
412 }
413
414 /**
415 * Remove all titles from a user's watchlist
416 */
417 private function clearWatchlist() {
418 $dbw = wfGetDB( DB_MASTER );
419 $dbw->delete(
420 'watchlist',
421 array( 'wl_user' => $this->getUser()->getId() ),
422 __METHOD__
423 );
424 }
425
426 /**
427 * Add a list of titles to a user's watchlist
428 *
429 * $titles can be an array of strings or Title objects; the former
430 * is preferred, since Titles are very memory-heavy
431 *
432 * @param array $titles Array of strings, or Title objects
433 */
434 private function watchTitles( $titles ) {
435 $dbw = wfGetDB( DB_MASTER );
436 $rows = array();
437
438 foreach ( $titles as $title ) {
439 if ( !$title instanceof Title ) {
440 $title = Title::newFromText( $title );
441 }
442
443 if ( $title instanceof Title ) {
444 $rows[] = array(
445 'wl_user' => $this->getUser()->getId(),
446 'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ),
447 'wl_title' => $title->getDBkey(),
448 'wl_notificationtimestamp' => null,
449 );
450 $rows[] = array(
451 'wl_user' => $this->getUser()->getId(),
452 'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ),
453 'wl_title' => $title->getDBkey(),
454 'wl_notificationtimestamp' => null,
455 );
456 }
457 }
458
459 $dbw->insert( 'watchlist', $rows, __METHOD__, 'IGNORE' );
460 }
461
462 /**
463 * Remove a list of titles from a user's watchlist
464 *
465 * $titles can be an array of strings or Title objects; the former
466 * is preferred, since Titles are very memory-heavy
467 *
468 * @param array $titles Array of strings, or Title objects
469 */
470 private function unwatchTitles( $titles ) {
471 $dbw = wfGetDB( DB_MASTER );
472
473 foreach ( $titles as $title ) {
474 if ( !$title instanceof Title ) {
475 $title = Title::newFromText( $title );
476 }
477
478 if ( $title instanceof Title ) {
479 $dbw->delete(
480 'watchlist',
481 array(
482 'wl_user' => $this->getUser()->getId(),
483 'wl_namespace' => MWNamespace::getSubject( $title->getNamespace() ),
484 'wl_title' => $title->getDBkey(),
485 ),
486 __METHOD__
487 );
488
489 $dbw->delete(
490 'watchlist',
491 array(
492 'wl_user' => $this->getUser()->getId(),
493 'wl_namespace' => MWNamespace::getTalk( $title->getNamespace() ),
494 'wl_title' => $title->getDBkey(),
495 ),
496 __METHOD__
497 );
498
499 $page = WikiPage::factory( $title );
500 wfRunHooks( 'UnwatchArticleComplete', array( $this->getUser(), &$page ) );
501 }
502 }
503 }
504
505 public function submitNormal( $data ) {
506 $removed = array();
507
508 foreach ( $data as $titles ) {
509 $this->unwatchTitles( $titles );
510 $removed = array_merge( $removed, $titles );
511 }
512
513 if ( count( $removed ) > 0 ) {
514 $this->successMessage = $this->msg( 'watchlistedit-normal-done'
515 )->numParams( count( $removed ) )->parse();
516 $this->showTitles( $removed, $this->successMessage );
517
518 return true;
519 } else {
520 return false;
521 }
522 }
523
524 /**
525 * Get the standard watchlist editing form
526 *
527 * @return HTMLForm
528 */
529 protected function getNormalForm() {
530 global $wgContLang;
531
532 $fields = array();
533 $count = 0;
534
535 foreach ( $this->getWatchlistInfo() as $namespace => $pages ) {
536 if ( $namespace >= 0 ) {
537 $fields['TitlesNs' . $namespace] = array(
538 'class' => 'EditWatchlistCheckboxSeriesField',
539 'options' => array(),
540 'section' => "ns$namespace",
541 );
542 }
543
544 foreach ( array_keys( $pages ) as $dbkey ) {
545 $title = Title::makeTitleSafe( $namespace, $dbkey );
546
547 if ( $this->checkTitle( $title, $namespace, $dbkey ) ) {
548 $text = $this->buildRemoveLine( $title );
549 $fields['TitlesNs' . $namespace]['options'][$text] = $title->getPrefixedText();
550 $count++;
551 }
552 }
553 }
554 $this->cleanupWatchlist();
555
556 if ( count( $fields ) > 1 && $count > 30 ) {
557 $this->toc = Linker::tocIndent();
558 $tocLength = 0;
559
560 foreach ( $fields as $data ) {
561 # strip out the 'ns' prefix from the section name:
562 $ns = substr( $data['section'], 2 );
563
564 $nsText = ( $ns == NS_MAIN )
565 ? $this->msg( 'blanknamespace' )->escaped()
566 : htmlspecialchars( $wgContLang->getFormattedNsText( $ns ) );
567 $this->toc .= Linker::tocLine( "editwatchlist-{$data['section']}", $nsText,
568 $this->getLanguage()->formatNum( ++$tocLength ), 1 ) . Linker::tocLineEnd();
569 }
570
571 $this->toc = Linker::tocList( $this->toc );
572 } else {
573 $this->toc = false;
574 }
575
576 $context = new DerivativeContext( $this->getContext() );
577 $context->setTitle( $this->getPageTitle() ); // Remove subpage
578 $form = new EditWatchlistNormalHTMLForm( $fields, $context );
579 $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
580 # Used message keys:
581 # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
582 $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
583 $form->setWrapperLegendMsg( 'watchlistedit-normal-legend' );
584 $form->addHeaderText( $this->msg( 'watchlistedit-normal-explain' )->parse() );
585 $form->setSubmitCallback( array( $this, 'submitNormal' ) );
586
587 return $form;
588 }
589
590 /**
591 * Build the label for a checkbox, with a link to the title, and various additional bits
592 *
593 * @param Title $title
594 * @return string
595 */
596 private function buildRemoveLine( $title ) {
597 $link = Linker::link( $title );
598
599 if ( $title->isRedirect() ) {
600 // Linker already makes class mw-redirect, so this is redundant
601 $link = '<span class="watchlistredir">' . $link . '</span>';
602 }
603
604 $tools[] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
605
606 if ( $title->exists() ) {
607 $tools[] = Linker::linkKnown(
608 $title,
609 $this->msg( 'history_short' )->escaped(),
610 array(),
611 array( 'action' => 'history' )
612 );
613 }
614
615 if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
616 $tools[] = Linker::linkKnown(
617 SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
618 $this->msg( 'contributions' )->escaped()
619 );
620 }
621
622 wfRunHooks(
623 'WatchlistEditorBuildRemoveLine',
624 array( &$tools, $title, $title->isRedirect(), $this->getSkin() )
625 );
626
627 return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
628 }
629
630 /**
631 * Get a form for editing the watchlist in "raw" mode
632 *
633 * @return HTMLForm
634 */
635 protected function getRawForm() {
636 $titles = implode( $this->getWatchlist(), "\n" );
637 $fields = array(
638 'Titles' => array(
639 'type' => 'textarea',
640 'label-message' => 'watchlistedit-raw-titles',
641 'default' => $titles,
642 ),
643 );
644 $context = new DerivativeContext( $this->getContext() );
645 $context->setTitle( $this->getPageTitle( 'raw' ) ); // Reset subpage
646 $form = new HTMLForm( $fields, $context );
647 $form->setSubmitTextMsg( 'watchlistedit-raw-submit' );
648 # Used message keys: 'accesskey-watchlistedit-raw-submit', 'tooltip-watchlistedit-raw-submit'
649 $form->setSubmitTooltip( 'watchlistedit-raw-submit' );
650 $form->setWrapperLegendMsg( 'watchlistedit-raw-legend' );
651 $form->addHeaderText( $this->msg( 'watchlistedit-raw-explain' )->parse() );
652 $form->setSubmitCallback( array( $this, 'submitRaw' ) );
653
654 return $form;
655 }
656
657 /**
658 * Get a form for clearing the watchlist
659 *
660 * @return HTMLForm
661 */
662 protected function getClearForm() {
663 $context = new DerivativeContext( $this->getContext() );
664 $context->setTitle( $this->getPageTitle( 'clear' ) ); // Reset subpage
665 $form = new HTMLForm( array(), $context );
666 $form->setSubmitTextMsg( 'watchlistedit-clear-submit' );
667 # Used message keys: 'accesskey-watchlistedit-clear-submit', 'tooltip-watchlistedit-clear-submit'
668 $form->setSubmitTooltip( 'watchlistedit-clear-submit' );
669 $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
670 $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
671 $form->setSubmitCallback( array( $this, 'submitClear' ) );
672
673 return $form;
674 }
675
676 /**
677 * Determine whether we are editing the watchlist, and if so, what
678 * kind of editing operation
679 *
680 * @param WebRequest $request
681 * @param string $par
682 * @return int
683 */
684 public static function getMode( $request, $par ) {
685 $mode = strtolower( $request->getVal( 'action', $par ) );
686
687 switch ( $mode ) {
688 case 'clear':
689 case self::EDIT_CLEAR:
690 return self::EDIT_CLEAR;
691 case 'raw':
692 case self::EDIT_RAW:
693 return self::EDIT_RAW;
694 case 'edit':
695 case self::EDIT_NORMAL:
696 return self::EDIT_NORMAL;
697 default:
698 return false;
699 }
700 }
701
702 /**
703 * Build a set of links for convenient navigation
704 * between watchlist viewing and editing modes
705 *
706 * @param null $unused
707 * @return string
708 */
709 public static function buildTools( $unused ) {
710 global $wgLang;
711
712 $tools = array();
713 $modes = array(
714 'view' => array( 'Watchlist', false ),
715 'edit' => array( 'EditWatchlist', false ),
716 'raw' => array( 'EditWatchlist', 'raw' ),
717 'clear' => array( 'EditWatchlist', 'clear' ),
718 );
719
720 foreach ( $modes as $mode => $arr ) {
721 // can use messages 'watchlisttools-view', 'watchlisttools-edit', 'watchlisttools-raw'
722 $tools[] = Linker::linkKnown(
723 SpecialPage::getTitleFor( $arr[0], $arr[1] ),
724 wfMessage( "watchlisttools-{$mode}" )->escaped()
725 );
726 }
727
728 return Html::rawElement(
729 'span',
730 array( 'class' => 'mw-watchlist-toollinks' ),
731 wfMessage( 'parentheses', $wgLang->pipeList( $tools ) )->text()
732 );
733 }
734 }
735
736 /**
737 * Extend HTMLForm purely so we can have a more sane way of getting the section headers
738 */
739 class EditWatchlistNormalHTMLForm extends HTMLForm {
740 public function getLegend( $namespace ) {
741 $namespace = substr( $namespace, 2 );
742
743 return $namespace == NS_MAIN
744 ? $this->msg( 'blanknamespace' )->escaped()
745 : htmlspecialchars( $this->getContext()->getLanguage()->getFormattedNsText( $namespace ) );
746 }
747
748 public function getBody() {
749 return $this->displaySection( $this->mFieldTree, '', 'editwatchlist-' );
750 }
751 }
752
753 class EditWatchlistCheckboxSeriesField extends HTMLMultiSelectField {
754 /**
755 * HTMLMultiSelectField throws validation errors if we get input data
756 * that doesn't match the data set in the form setup. This causes
757 * problems if something gets removed from the watchlist while the
758 * form is open (bug 32126), but we know that invalid items will
759 * be harmless so we can override it here.
760 *
761 * @param string $value the value the field was submitted with
762 * @param array $alldata the data collected from the form
763 * @return bool|string Bool true on success, or String error to display.
764 */
765 function validate( $value, $alldata ) {
766 // Need to call into grandparent to be a good citizen. :)
767 return HTMLFormField::validate( $value, $alldata );
768 }
769 }