* (bug 19442) Show/hide options on watchlist only work once
authorNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 5 Jul 2009 09:11:09 +0000 (09:11 +0000)
committerNiklas Laxström <nikerabbit@users.mediawiki.org>
Sun, 5 Jul 2009 09:11:09 +0000 (09:11 +0000)
* Regression is probably since r51572

RELEASE-NOTES
includes/specials/SpecialWatchlist.php

index dc66781..18088da 100644 (file)
@@ -228,6 +228,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
    and attempted to upload with the source name. Now warns about not having an
    extension (since 0.ext is perfectly valid)
 * (bug 19468) Enotif preferences are now only displayed when they are turned on
+* (bug 19442) Show/hide options on watchlist only work once
 
 == API changes in 1.16 ==
 
index 8703d1b..4d159f5 100644 (file)
@@ -252,108 +252,17 @@ function wfSpecialWatchlist( $par ) {
 
        $cutofflinks = "\n" . wlCutoffLinks( $days, 'Watchlist', $nondefaults ) . "<br />\n";
 
-       # Spit out some control panel links
        $thisTitle = SpecialPage::getTitleFor( 'Watchlist' );
-       $skin = $wgUser->getSkin();
-
-       $showLinktext = wfMsgHtml( 'show' );
-       $hideLinktext = wfMsgHtml( 'hide' );
-       # Hide/show minor edits
-       $label = $hideMinor ? $showLinktext : $hideLinktext;
-       $linkBits = array_merge(
-               array( 'hideMinor' => 1 - (int)$hideMinor ),
-               $nondefaults
-       );
-       $links[] = wfMsgHtml(
-               'rcshowhideminor',
-               $skin->linkKnown(
-                       $thisTitle,
-                       $label,
-                       array(),
-                       $linkBits
-               )
-       );
-
-       # Hide/show bot edits
-       $label = $hideBots ? $showLinktext : $hideLinktext;
-       $linkBits = array_merge(
-               array( 'hideBots' => 1 - (int)$hideBots ),
-               $nondefaults
-       );
-       $links[] = wfMsgHtml(
-               'rcshowhidebots',
-               $skin->linkKnown(
-                       $thisTitle,
-                       $label,
-                       array(),
-                       $linkBits
-               )
-       );
 
-       # Hide/show anonymous edits
-       $label = $hideAnons ? $showLinktext : $hideLinktext;
-       $linkBits = array_merge(
-               array( 'hideAnons' => 1 - (int)$hideAnons ),
-               $nondefaults
-       );
-       $links[] = wfMsgHtml(
-               'rcshowhideanons',
-               $skin->linkKnown(
-                       $thisTitle,
-                       $label,
-                       array(),
-                       $linkBits
-               )
-       );
-
-       # Hide/show logged in edits
-       $label = $hideLiu ? $showLinktext : $hideLinktext;
-       $linkBits = array_merge(
-               array( 'hideLiu' => 1 - (int)$hideLiu ),
-               $nondefaults
-       );
-       $links[] = wfMsgHtml(
-               'rcshowhideliu',
-               $skin->linkKnown(
-                       $thisTitle,
-                       $label,
-                       array(),
-                       $linkBits
-               )
-       );
-
-       # Hide/show own edits
-       $label = $hideOwn ? $showLinktext : $hideLinktext;
-       $linkBits = array_merge(
-               array( 'hideOwn' => 1 - (int)$hideOwn ),
-               $nondefaults
-       );
-       $links[] = wfMsgHtml(
-               'rcshowhidemine',
-               $skin->linkKnown(
-                       $thisTitle,
-                       $label,
-                       array(),
-                       $linkBits
-               )
-       );
+       # Spit out some control panel links
+       $links[] = wlShowHideLink( $nondefaults, 'rcshowhideminor', 'hideMinor', $hideMinor );
+       $links[] = wlShowHideLink( $nondefaults, 'rcshowhidebots', 'hideBots', $hideBots );
+       $links[] = wlShowHideLink( $nondefaults, 'rcshowhideanons', 'hideAnons', $hideAnons );
+       $links[] = wlShowHideLink( $nondefaults, 'rcshowhideliu', 'hideLiu', $hideLiu );
+       $links[] = wlShowHideLink( $nondefaults, 'rcshowhidemine', 'hideOwn', $hideOwn );
 
-       # Hide/show patrolled edits
        if( $wgUser->useRCPatrol() ) {
-               $label = $hidePatrolled ? $showLinktext : $hideLinktext;
-               $linkBits = array_merge(
-                       array( 'hidePatrolled' => 1 - (int)$hidePatrolled ),
-                       $nondefaults
-               );
-               $links[] = wfMsgHtml(
-                       'rcshowhidepatr',
-                       $skin->linkKnown(
-                               $thisTitle,
-                               $label,
-                               array(),
-                               $linkBits
-                       )
-               );
+               $links[] = wlShowHideLink( $nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled );
        }
 
        # Namespace filter and put the whole form together.
@@ -439,6 +348,21 @@ function wfSpecialWatchlist( $par ) {
        $wgOut->addHTML( $s );
 }
 
+function wlShowHideLink( $options, $message, $name, $value ) {
+       global $wgUser;
+
+       $showLinktext = wfMsgHtml( 'show' );
+       $hideLinktext = wfMsgHtml( 'hide' );
+       $title = SpecialPage::getTitleFor( 'Watchlist' );
+       $skin = $wgUser->getSkin();
+
+       $label = $value ? $showLinktext : $hideLinktext;
+       $options[$name] = 1 - (int) $value;
+
+       return wfMsgHtml( $message, $skin->linkKnown( $title, $label, array(), $options ) );
+}
+
+
 function wlHoursLink( $h, $page, $options = array() ) {
        global $wgUser, $wgLang, $wgContLang;