]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blobdiff - includes/specials/SpecialWatchlist.php
MediaWiki 1.16.0
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialWatchlist.php
index b14577b552f55f0456259acd753a98503e98376a..c32af2ae39c6a0caee607809e4dad9111691e4bf 100644 (file)
 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 ) . "<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 = 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;
 }