X-Git-Url: http://git.cyclocoop.org/?a=blobdiff_plain;f=includes%2FSpecialRecentchanges.php;h=9cf8adb4e5a52f506632d1326e8c0220392c7f26;hb=f9eb13cbd90de0da6d8b006492c8cc9167bf40af;hp=bb3855a6724722c7077d6ac226cea05f8c05fbf3;hpb=13c17d0cc9cc901c74469ece3c7646f830ca9623;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/SpecialRecentchanges.php b/includes/SpecialRecentchanges.php index bb3855a672..9cf8adb4e5 100644 --- a/includes/SpecialRecentchanges.php +++ b/includes/SpecialRecentchanges.php @@ -1,28 +1,47 @@ - +getVal( "feed" ); + $feeding = ( $feedFormat == "rss" ); + $defaultDays = $wgUser->getOption( 'rcdays' ); + if ( !$defaultDays ) { + $defaultDays = 3; + } + + $days = $wgRequest->getInt( 'days', $defaultDays ); + $hideminor = $wgRequest->getBool( 'hideminor', $wgUser->getOption( 'hideminor' ) ) ? 1 : 0; + $from = $wgRequest->getText( 'from' ); + $hidebots = $wgRequest->getBool( 'hidebots', true ) ? 1 : 0; + $hideliu = $wgRequest->getBool( 'hideliu', false ) ? 1 : 0; + + # Get query parameters from path if( $par ) { $bits = preg_split( '/\s*,\s*/', trim( $par ) ); if( in_array( "hidebots", $bits ) ) $hidebots = 1; if( in_array( "bots", $bits ) ) $hidebots = 0; if( in_array( "hideminor", $bits ) ) $hideminor = 1; if( in_array( "minor", $bits ) ) $hideminor = 0; + if( in_array( "hideliu", $bits) ) $hideliu = 1; } $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges"; $res = wfQuery( $sql, DB_READ, $fname ); $s = wfFetchObject( $res ); - $wgOut->checkLastModified( $s->lastmod ); + # 10 seconds server-side caching max + $wgOut->setSquidMaxage( 10 ); + if( $wgOut->checkLastModified( $s->lastmod ) ){ + # Client cache fresh and headers sent, nothing more to do. + return; + } $rctext = wfMsg( "recentchangestext" ); @@ -34,15 +53,12 @@ function wfSpecialRecentchanges( $par ) } $wgOut->addWikiText( $rctext ); - - if ( ! $days ) { - $days = $wgUser->getOption( "rcdays" ); - if ( ! $days ) { $days = 3; } - } - $days = (int)$days; + list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" ); $now = wfTimestampNow(); - $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) ); + $cutoff_unixtime = time() - ( $days * 86400 ); + $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime % 86400); + $cutoff = wfUnix2Timestamp( $cutoff_unixtime ); if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) { $cutoff = $from; } else { @@ -50,82 +66,96 @@ function wfSpecialRecentchanges( $par ) } $sk = $wgUser->getSkin(); - - if ( ! isset( $hideminor ) ) { - $hideminor = $wgUser->getOption( "hideminor" ); - } + $showhide = array( wfMsg( "show" ), wfMsg( "hide" )); + if ( $hideminor ) { $hidem = "AND rc_minor=0"; - $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ), - WfMsg( "show" ), "days={$days}&limit={$limit}&hideminor=0" ); } else { $hidem = ""; - $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ), - WfMsg( "hide" ), "days={$days}&limit={$limit}&hideminor=1" ); } - if ( !isset( $hidebots ) ) { - $hidebots = 1; - } if( $hidebots ) { $hidem .= " AND rc_bot=0"; } + + if ( $hideliu ) { + $hidem .= " AND rc_user=0"; + } + $hideliu = ($hideliu ? 1 : 0); + #$hideparams = "hideminor={$hideminor}&hideliu={$hideliu}&hidebots={$hidebots}"; + $urlparams = array( "hideminor" => $hideminor, "hideliu" => $hideliu, "hidebots" => $hidebots ); + $hideparams = wfArrayToCGI( $urlparams ); + + $minorLink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ), + $showhide[1-$hideminor], wfArrayToCGI( array( "hideminor" => 1-$hideminor ), $urlparams ) ); + $botLink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ), + $showhide[1-$hidebots], wfArrayToCGI( array( "hidebots" => 1-$hidebots ), $urlparams ) ); + $liuLink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ), + $showhide[1-$hideliu], wfArrayToCGI( array( "hideliu" => 1-$hideliu ), $urlparams ) ); $uid = $wgUser->getID(); - $sql2 = "SELECT rc_cur_id,rc_namespace,rc_title,rc_user,rc_new," . - "rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_this_oldid,rc_last_oldid,rc_bot" . ($uid ? ",wl_user" : "") . " FROM recentchanges " . + $sql2 = "SELECT recentchanges.*" . ($uid ? ",wl_user" : "") . " FROM recentchanges " . ($uid ? "LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") . "WHERE rc_timestamp > '{$cutoff}' {$hidem} " . "ORDER BY rc_timestamp DESC LIMIT {$limit}"; + $res = wfQuery( $sql2, DB_READ, $fname ); + $rows = array(); + while( $row = wfFetchObject( $res ) ){ + $rows[] = $row; + } if(isset($from)) { - $note = wfMsg( "rcnotefrom", $limit, + $note = wfMsg( "rcnotefrom", $wgLang->formatNum( $limit ), $wgLang->timeanddate( $from, true ) ); } else { - $note = wfMsg( "rcnote", $limit, $days ); + $note = wfMsg( "rcnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( $days ) ); } - $wgOut->addHTML( "\n