Added EditFilterMerged hook: like EditFilter but uses the text after section merging...
[lhc/web/wiklou.git] / includes / SpecialRecentchanges.php
index 95e9ee5..2744cd8 100644 (file)
@@ -1,20 +1,19 @@
 <?php
 /**
  *
- * @package MediaWiki
- * @subpackage SpecialPage
+ * @addtogroup SpecialPage
  */
 
 /**
  *
  */
-require_once( 'ChangesList.php' );
+require_once( dirname(__FILE__) . '/ChangesList.php' );
 
 /**
  * Constructor
  */
 function wfSpecialRecentchanges( $par, $specialPage ) {
-       global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol, $wgDBtype;
+       global $wgUser, $wgOut, $wgRequest, $wgUseRCPatrol;
        global $wgRCShowWatchingUsers, $wgShowUpdatedMarker;
        global $wgAllowCategorizedRecentChanges ;
        $fname = 'wfSpecialRecentchanges';
@@ -22,7 +21,7 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
        # Get query parameters
        $feedFormat = $wgRequest->getVal( 'feed' );
 
-       /* Checkbox values can't be true be default, because
+       /* Checkbox values can't be true by default, because
         * we cannot differentiate between unset and not set at all
         */
        $defaults = array(
@@ -43,12 +42,10 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
        extract($defaults);
 
 
-       $days = $wgUser->getOption( 'rcdays' );
-       if ( !$days ) { $days = $defaults['days']; }
+       $days = $wgUser->getOption( 'rcdays', $defaults['days']);
        $days = $wgRequest->getInt( 'days', $days );
 
-       $limit = $wgUser->getOption( 'rclimit' );
-       if ( !$limit ) { $limit = $defaults['limit']; }
+       $limit = $wgUser->getOption( 'rclimit', $defaults['limit'] );
 
        #       list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
        $limit = $wgRequest->getInt( 'limit', $limit );
@@ -60,7 +57,7 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
        if( $feedFormat ) {
                global $wgFeedLimit;
                if( $limit > $wgFeedLimit ) {
-                       $options['limit'] = $wgFeedLimit;
+                       $limit = $wgFeedLimit;
                }
 
        } else {
@@ -90,7 +87,8 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
                                if ( is_numeric( $bit ) ) {
                                        $limit = $bit;
                                }
-
+                               
+                               $m = array();
                                if ( preg_match( '/^limit=(\d+)$/', $bit, $m ) ) {
                                        $limit = $m[1];
                                }
@@ -106,8 +104,8 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
 
 
        # Database connection and caching
-       $dbr =& wfGetDB( DB_SLAVE );
-       extract( $dbr->tableNames( 'recentchanges', 'watchlist' ) );
+       $dbr = wfGetDB( DB_SLAVE );
+       list( $recentchanges, $watchlist ) = $dbr->tableNamesN( 'recentchanges', 'watchlist' );
 
 
        $cutoff_unixtime = time() - ( $days * 86400 );
@@ -198,7 +196,7 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
 
                // Output header
                if ( !$specialPage->including() ) {
-                       $wgOut->addWikiText( wfMsgForContent( "recentchangestext" ) );
+                       $wgOut->addWikiText( wfMsgForContentNoTrans( "recentchangestext" ) );
 
                        // Dump everything here
                        $nondefaults = array();
@@ -222,8 +220,6 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
                }
 
                // And now for the content
-               $wgOut->setSyndicated( true );
-
                $list = ChangesList::newFromUser( $wgUser );
                
                if ( $wgAllowCategorizedRecentChanges ) {
@@ -271,8 +267,6 @@ function wfSpecialRecentchanges( $par, $specialPage ) {
 }
 
 function rcFilterByCategories ( &$rows , $categories , $any ) {
-       require_once ( 'Categoryfinder.php' ) ;
-       
        # Filter categories
        $cats = array () ;
        foreach ( $categories AS $cat ) {
@@ -333,9 +327,17 @@ function rcOutputFeed( $rows, $feedFormat, $limit, $hideminor, $lastmod ) {
                ' [' . $wgContLanguageCode . ']';
        $feed = new $wgFeedClasses[$feedFormat](
                $feedTitle,
-               htmlspecialchars( wfMsgForContent( 'recentchangestext' ) ),
+               htmlspecialchars( wfMsgForContent( 'recentchanges-feed-description' ) ),
                $wgTitle->getFullUrl() );
 
+       //purge cache if requested
+       global $wgRequest, $wgUser;
+       $purge = $wgRequest->getVal( 'action' ) == 'purge';
+       if ( $purge && $wgUser->isAllowed('purge') ) {
+               $messageMemc->delete( $timekey );
+               $messageMemc->delete( $key );
+       }
+
        /**
         * Bumping around loading up diffs can be pretty slow, so where
         * possible we want to cache the feed output so the next visitor
@@ -396,7 +398,6 @@ function rcDoOutputFeed( $rows, &$feed ) {
                        $sorted[$n] = $obj;
                        $n++;
                }
-               $first = false;
        }
 
        foreach( $sorted as $obj ) {
@@ -420,8 +421,9 @@ function rcDoOutputFeed( $rows, &$feed ) {
  *
  */
 function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) {
-       global $wgLang, $wgContLang;
-       $s = Linker::makeKnownLink( $wgContLang->specialPage( $page ),
+       global $wgUser, $wgLang, $wgContLang;
+       $sk = $wgUser->getSkin();
+       $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
          ($lim ? $wgLang->formatNum( "{$lim}" ) : wfMsg( 'recentchangesall' ) ), "{$more}" .
          ($d ? "days={$d}&" : '') . 'limit='.$lim );
        return $s;
@@ -431,8 +433,9 @@ function rcCountLink( $lim, $d, $page='Recentchanges', $more='' ) {
  *
  */
 function rcDaysLink( $lim, $d, $page='Recentchanges', $more='' ) {
-       global $wgLang, $wgContLang;
-       $s = Linker::makeKnownLink( $wgContLang->specialPage( $page ),
+       global $wgUser, $wgLang, $wgContLang;
+       $sk = $wgUser->getSkin();
+       $s = $sk->makeKnownLink( $wgContLang->specialPage( $page ),
          ($d ? $wgLang->formatNum( "{$d}" ) : wfMsg( 'recentchangesall' ) ), $more.'days='.$d .
          ($lim ? '&limit='.$lim : '') );
        return $s;
@@ -470,13 +473,14 @@ function rcDayLimitLinks( $days, $limit, $page='Recentchanges', $more='', $doall
 
 /**
  * Makes change an option link which carries all the other options
- * @param $title @see Title
+ * @param $title see Title
  * @param $override
  * @param $options
  */
 function makeOptionsLink( $title, $override, $options ) {
-       global $wgContLang;
-       return Linker::makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ),
+       global $wgUser, $wgContLang;
+       $sk = $wgUser->getSkin();
+       return $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchanges' ),
                htmlspecialchars( $title ), wfArrayToCGI( $override, $options ) );
 }
 
@@ -617,13 +621,20 @@ function rcFormatDiff( $row ) {
 }
 
 function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment ) {
-       global $wgFeedDiffCutoff, $wgContLang;
+       global $wgFeedDiffCutoff, $wgContLang, $wgUser;
        $fname = 'rcFormatDiff';
        wfProfileIn( $fname );
 
-       $completeText = '<p>' . Linker::formatComment( $comment ) . "</p>\n";
+       $skin = $wgUser->getSkin();
+       $completeText = '<p>' . $skin->formatComment( $comment ) . "</p>\n";
 
-       if( $title->getNamespace() >= 0 ) {
+       //NOTE: Check permissions for anonymous users, not current user.
+       //      No "privileged" version should end up in the cache.
+       //      Most feed readers will not log in anway.
+       $anon = new User();
+       $accErrors = $title->getUserPermissionsErrors( 'read', $anon, true );
+
+       if( $title->getNamespace() >= 0 && !$accErrors ) {
                if( $oldid ) {
                        wfProfileIn( "$fname-dodiff" );
 
@@ -684,13 +695,13 @@ function rcFormatDiffRow( $title, $oldid, $newid, $timestamp, $comment ) {
  */
 function rcApplyDiffStyle( $text ) {
        $styles = array(
-               'diff'             => 'background-color: white;',
-               'diff-otitle'      => 'background-color: white;',
-               'diff-ntitle'      => 'background-color: white;',
-               'diff-addedline'   => 'background: #cfc; font-size: smaller;',
-               'diff-deletedline' => 'background: #ffa; font-size: smaller;',
-               'diff-context'     => 'background: #eee; font-size: smaller;',
-               'diffchange'       => 'color: red; font-weight: bold;',
+               'diff'             => 'background-color: white; color:black;',
+               'diff-otitle'      => 'background-color: white; color:black;',
+               'diff-ntitle'      => 'background-color: white; color:black;',
+               'diff-addedline'   => 'background: #cfc; color:black; font-size: smaller;',
+               'diff-deletedline' => 'background: #ffa; color:black; font-size: smaller;',
+               'diff-context'     => 'background: #eee; color:black; font-size: smaller;',
+               'diffchange'       => 'color: red; font-weight: bold; text-decoration: none;',
        );
        
        foreach( $styles as $class => $style ) {
@@ -701,4 +712,4 @@ function rcApplyDiffStyle( $text ) {
        return $text;
 }
 
-?>
+