Special:EditWatchlist/clear: use destructive button
[lhc/web/wiklou.git] / includes / specials / SpecialEditWatchlist.php
index 76f2f4a..9007603 100644 (file)
@@ -553,7 +553,15 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $fields = array();
                $count = 0;
 
-               foreach ( $this->getWatchlistInfo() as $namespace => $pages ) {
+               // Allow subscribers to manipulate the list of watched pages (or use it
+               // to preload lots of details at once)
+               $watchlistInfo = $this->getWatchlistInfo();
+               wfRunHooks(
+                       'WatchlistEditorBeforeFormRender',
+                       array( &$watchlistInfo )
+               );
+
+               foreach ( $watchlistInfo as $namespace => $pages ) {
                        $options = array();
 
                        foreach ( array_keys( $pages ) as $dbkey ) {
@@ -601,6 +609,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $context->setTitle( $this->getPageTitle() ); // Remove subpage
                $form = new EditWatchlistNormalHTMLForm( $fields, $context );
                $form->setSubmitTextMsg( 'watchlistedit-normal-submit' );
+               $form->setSubmitDestructive();
                # Used message keys:
                # 'accesskey-watchlistedit-normal-submit', 'tooltip-watchlistedit-normal-submit'
                $form->setSubmitTooltip( 'watchlistedit-normal-submit' );
@@ -620,15 +629,13 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
        private function buildRemoveLine( $title ) {
                $link = Linker::link( $title );
 
-               if ( $title->isRedirect() ) {
-                       // Linker already makes class mw-redirect, so this is redundant
-                       $link = '<span class="watchlistredir">' . $link . '</span>';
-               }
-
-               $tools[] = Linker::link( $title->getTalkPage(), $this->msg( 'talkpagelinktext' )->escaped() );
+               $tools['talk'] = Linker::link(
+                       $title->getTalkPage(),
+                       $this->msg( 'talkpagelinktext' )->escaped()
+               );
 
                if ( $title->exists() ) {
-                       $tools[] = Linker::linkKnown(
+                       $tools['history'] = Linker::linkKnown(
                                $title,
                                $this->msg( 'history_short' )->escaped(),
                                array(),
@@ -637,7 +644,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                }
 
                if ( $title->getNamespace() == NS_USER && !$title->isSubpage() ) {
-                       $tools[] = Linker::linkKnown(
+                       $tools['contributions'] = Linker::linkKnown(
                                SpecialPage::getTitleFor( 'Contributions', $title->getText() ),
                                $this->msg( 'contributions' )->escaped()
                        );
@@ -645,9 +652,14 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
 
                wfRunHooks(
                        'WatchlistEditorBuildRemoveLine',
-                       array( &$tools, $title, $title->isRedirect(), $this->getSkin() )
+                       array( &$tools, $title, $title->isRedirect(), $this->getSkin(), &$link )
                );
 
+               if ( $title->isRedirect() ) {
+                       // Linker already makes class mw-redirect, so this is redundant
+                       $link = '<span class="watchlistredir">' . $link . '</span>';
+               }
+
                return $link . " (" . $this->getLanguage()->pipeList( $tools ) . ")";
        }
 
@@ -693,6 +705,7 @@ class SpecialEditWatchlist extends UnlistedSpecialPage {
                $form->setWrapperLegendMsg( 'watchlistedit-clear-legend' );
                $form->addHeaderText( $this->msg( 'watchlistedit-clear-explain' )->parse() );
                $form->setSubmitCallback( array( $this, 'submitClear' ) );
+               $form->setSubmitDestructive();
 
                return $form;
        }