From 222b01f5169f1c7e69762e0e8904c24f78f71882 Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Wed, 28 Jul 2010 11:52:48 +0200 Subject: update to MediaWiki 1.16.0 --- includes/specials/SpecialWatchlist.php | 120 ++++++++++++++++++++------------- 1 file changed, 75 insertions(+), 45 deletions(-) (limited to 'includes/specials/SpecialWatchlist.php') diff --git a/includes/specials/SpecialWatchlist.php b/includes/specials/SpecialWatchlist.php index b14577b5..c32af2ae 100644 --- a/includes/specials/SpecialWatchlist.php +++ b/includes/specials/SpecialWatchlist.php @@ -12,7 +12,25 @@ function wfSpecialWatchlist( $par ) { global $wgUser, $wgOut, $wgLang, $wgRequest; global $wgRCShowWatchingUsers, $wgEnotifWatchlist, $wgShowUpdatedMarker; - global $wgEnotifWatchlist; + + // Add feed links + $wlToken = $wgUser->getOption( 'watchlisttoken' ); + if (!$wlToken) { + $wlToken = sha1( mt_rand() . microtime( true ) ); + $wgUser->setOption( 'watchlisttoken', $wlToken ); + $wgUser->saveSettings(); + } + + global $wgServer, $wgScriptPath, $wgFeedClasses; + $apiParams = array( 'action' => 'feedwatchlist', 'allrev' => 'allrev', + 'wlowner' => $wgUser->getName(), 'wltoken' => $wlToken ); + $feedTemplate = wfScript('api').'?'; + + foreach( $wgFeedClasses as $format => $class ) { + $theseParams = $apiParams + array( 'feedformat' => $format ); + $url = $feedTemplate . wfArrayToCGI( $theseParams ); + $wgOut->addFeedLink( $format, $url ); + } $skin = $wgUser->getSkin(); $specialTitle = SpecialPage::getTitleFor( 'Watchlist' ); @@ -21,8 +39,12 @@ function wfSpecialWatchlist( $par ) { # Anons don't get a watchlist if( $wgUser->isAnon() ) { $wgOut->setPageTitle( wfMsg( 'watchnologin' ) ); - $llink = $skin->makeKnownLinkObj( SpecialPage::getTitleFor( 'Userlogin' ), - wfMsgHtml( 'loginreqlink' ), 'returnto=' . $specialTitle->getPrefixedUrl() ); + $llink = $skin->linkKnown( + SpecialPage::getTitleFor( 'Userlogin' ), + wfMsgHtml( 'loginreqlink' ), + array(), + array( 'returnto' => $specialTitle->getPrefixedText() ) + ); $wgOut->addHTML( wfMsgWikiHtml( 'watchlistanontext', $llink ) ); return; } @@ -248,42 +270,17 @@ function wfSpecialWatchlist( $par ) { $cutofflinks = "\n" . wlCutoffLinks( $days, 'Watchlist', $nondefaults ) . "
\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 = wfArrayToCGI( array( 'hideMinor' => 1 - (int)$hideMinor ), $nondefaults ); - $links[] = wfMsgHtml( 'rcshowhideminor', $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ) ); - - # Hide/show bot edits - $label = $hideBots ? $showLinktext : $hideLinktext; - $linkBits = wfArrayToCGI( array( 'hideBots' => 1 - (int)$hideBots ), $nondefaults ); - $links[] = wfMsgHtml( 'rcshowhidebots', $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ) ); - - # Hide/show anonymous edits - $label = $hideAnons ? $showLinktext : $hideLinktext; - $linkBits = wfArrayToCGI( array( 'hideAnons' => 1 - (int)$hideAnons ), $nondefaults ); - $links[] = wfMsgHtml( 'rcshowhideanons', $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ) ); - - # Hide/show logged in edits - $label = $hideLiu ? $showLinktext : $hideLinktext; - $linkBits = wfArrayToCGI( array( 'hideLiu' => 1 - (int)$hideLiu ), $nondefaults ); - $links[] = wfMsgHtml( 'rcshowhideliu', $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ) ); - - # Hide/show own edits - $label = $hideOwn ? $showLinktext : $hideLinktext; - $linkBits = wfArrayToCGI( array( 'hideOwn' => 1 - (int)$hideOwn ), $nondefaults ); - $links[] = wfMsgHtml( 'rcshowhidemine', $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ) ); - - # Hide/show patrolled edits + # 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 ); + if( $wgUser->useRCPatrol() ) { - $label = $hidePatrolled ? $showLinktext : $hideLinktext; - $linkBits = wfArrayToCGI( array( 'hidePatrolled' => 1 - (int)$hidePatrolled ), $nondefaults ); - $links[] = wfMsgHtml( 'rcshowhidepatr', $skin->makeKnownLinkObj( $thisTitle, $label, $linkBits ) ); + $links[] = wlShowHideLink( $nondefaults, 'rcshowhidepatr', 'hidePatrolled', $hidePatrolled ); } # Namespace filter and put the whole form together. @@ -311,6 +308,8 @@ function wfSpecialWatchlist( $par ) { $form .= Xml::closeElement( 'fieldset' ); $wgOut->addHTML( $form ); + $wgOut->addHTML( ChangesList::flagLegend() ); + # If there's nothing to show, stop here if( $numRows == 0 ) { $wgOut->addWikiMsg( 'watchnochange' ); @@ -334,7 +333,8 @@ function wfSpecialWatchlist( $par ) { $dbr->dataSeek( $res, 0 ); $list = ChangesList::newFromUser( $wgUser ); - + $list->setWatchlistDivs(); + $s = $list->beginRecentChangesList(); $counter = 1; while ( $obj = $dbr->fetchObject( $res ) ) { @@ -368,23 +368,53 @@ 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; + $sk = $wgUser->getSkin(); - $s = $sk->makeKnownLink( - $wgContLang->specialPage( $page ), - $wgLang->formatNum( $h ), - wfArrayToCGI( array('days' => ($h / 24.0)), $options ) ); + $title = Title::newFromText( $wgContLang->specialPage( $page ) ); + $options['days'] = ($h / 24.0); + + $s = $sk->linkKnown( + $title, + $wgLang->formatNum( $h ), + array(), + $options + ); + return $s; } function wlDaysLink( $d, $page, $options = array() ) { global $wgUser, $wgLang, $wgContLang; + $sk = $wgUser->getSkin(); - $s = $sk->makeKnownLink( - $wgContLang->specialPage( $page ), - ($d ? $wgLang->formatNum( $d ) : wfMsgHtml( 'watchlistall2' ) ), - wfArrayToCGI( array('days' => $d), $options ) ); + $title = Title::newFromText( $wgContLang->specialPage( $page ) ); + $options['days'] = $d; + $message = ($d ? $wgLang->formatNum( $d ) : wfMsgHtml( 'watchlistall2' ) ); + + $s = $sk->linkKnown( + $title, + $message, + array(), + $options + ); + return $s; } -- cgit v1.2.3-54-g00ecf