3 function wfSpecialRecentchanges( $par )
5 global $wgUser, $wgOut, $wgLang, $wgTitle, $wgMemc, $wgDBname;
6 global $days, $hideminor, $from, $hidebots, $hideliu; # From query string
7 $fname = "wfSpecialRecentchanges";
10 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
11 if( in_array( "hidebots", $bits ) ) $hidebots = 1;
12 if( in_array( "bots", $bits ) ) $hidebots = 0;
13 if( in_array( "hideminor", $bits ) ) $hideminor = 1;
14 if( in_array( "minor", $bits ) ) $hideminor = 0;
15 if( in_array( "hideliu", $bits) ) $hideliu = 1;
18 $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
19 $res = wfQuery( $sql, DB_READ
, $fname );
20 $s = wfFetchObject( $res );
21 # 10 seconds server-side caching max
22 $wgOut->setSquidMaxage( 10 );
23 if( $wgOut->checkLastModified( $s->lastmod
) ){
24 # Client cache fresh and headers sent, nothing more to do.
28 $rctext = wfMsg( "recentchangestext" );
30 # The next few lines can probably be commented out now that wfMsg can get text from the DB
31 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
32 $res = wfQuery( $sql, DB_READ
, $fname );
33 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
34 $rctext = $s->cur_text
;
37 $wgOut->addWikiText( $rctext );
40 $days = $wgUser->getOption( "rcdays" );
41 if ( ! $days ) { $days = 3; }
44 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
45 $now = wfTimestampNow();
46 $cutoff_unixtime = time() - ( $days * 86400 );
47 $cutoff_unixtime = $cutoff_unixtime - ($cutoff_unixtime %
86400);
48 $cutoff = wfUnix2Timestamp( $cutoff_unixtime );
49 if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
55 $sk = $wgUser->getSkin();
56 $showhide = array( wfMsg( "show" ), wfMsg( "hide" ));
58 if ( ! isset( $hideminor ) ) {
59 $hideminor = $wgUser->getOption( "hideminor" );
61 $hideminor = ($hideminor ?
1 : 0);
63 $hidem = "AND rc_minor=0";
68 if ( !isset( $hidebots ) ) {
72 $hidem .= " AND rc_bot=0";
74 $hidebots = ($hidebots ?
1 : 0);
76 if ( !isset( $hideliu ) ) {
80 $hidem .= " AND rc_user=0";
82 $hideliu = ($hideliu ?
1 : 0);
83 #$hideparams = "hideminor={$hideminor}&hideliu={$hideliu}&hidebots={$hidebots}";
84 $urlparams = array( "hideminor" => $hideminor, "hideliu" => $hideliu, "hidebots" => $hidebots );
85 $hideparams = wfArrayToCGI( $urlparams );
87 $minorLink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
88 $showhide[1-$hideminor], wfArrayToCGI( array( "hideminor" => 1-$hideminor ), $urlparams ) );
89 $botLink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
90 $showhide[1-$hidebots], wfArrayToCGI( array( "hidebots" => 1-$hidebots ), $urlparams ) );
91 $liuLink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
92 $showhide[1-$hideliu], wfArrayToCGI( array( "hideliu" => 1-$hideliu ), $urlparams ) );
94 $uid = $wgUser->getID();
95 $sql2 = "SELECT recentchanges.*" . ($uid ?
",wl_user" : "") . " FROM recentchanges " .
96 ($uid ?
"LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
97 "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
98 "ORDER BY rc_timestamp DESC LIMIT {$limit}";
100 $res = wfQuery( $sql2, DB_READ
, $fname );
102 while( $row = wfFetchObject( $res ) ){
107 $note = wfMsg( "rcnotefrom", $wgLang->formatNum( $limit ),
108 $wgLang->timeanddate( $from, true ) );
110 $note = wfMsg( "rcnote", $wgLang->formatNum( $limit ), $wgLang->formatNum( $days ) );
112 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
114 $note = rcDayLimitLinks( $days, $limit, "Recentchanges", $hideparams, false, $minorLink, $botLink, $liuLink );
116 $note .= "<br>\n" . wfMsg( "rclistfrom",
117 $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
118 $wgLang->timeanddate( $now, true ), "{$hideparams}&from=$now" ) );
120 $wgOut->addHTML( "{$note}\n" );
122 $s = $sk->beginRecentChangesList();
123 foreach( $rows as $obj ){
128 if ( ! ( $hideminor && $obj->rc_minor
) ) {
129 $rc = RecentChange
::newFromRow( $obj );
130 $s .= $sk->recentChangesLine( $rc, $obj->wl_user
);
134 $s .= $sk->endRecentChangesList();
136 wfFreeResult( $res );
137 $wgOut->addHTML( $s );
140 function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
142 global $wgUser, $wgLang;
143 $sk = $wgUser->getSkin();
144 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
145 ($lim ?
$wgLang->formatNum( "{$lim}" ) : wfMsg( "all" ) ), "{$more}" .
146 ($d ?
"days={$d}&" : "") . "limit={$lim}" );
150 function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" )
152 global $wgUser, $wgLang;
153 $sk = $wgUser->getSkin();
154 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
155 ($d ?
$wgLang->formatNum( "{$d}" ) : wfMsg( "all" ) ), "{$more}days={$d}" .
156 ($lim ?
"&limit={$lim}" : "") );
160 function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall = false, $minorLink = "",
161 $botLink = "", $liuLink = "" )
163 if ($more != "") $more .= "&";
164 $cl = rcCountLink( 50, $days, $page, $more ) . " | " .
165 rcCountLink( 100, $days, $page, $more ) . " | " .
166 rcCountLink( 250, $days, $page, $more ) . " | " .
167 rcCountLink( 500, $days, $page, $more ) .
168 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
169 $dl = rcDaysLink( $limit, 1, $page, $more ) . " | " .
170 rcDaysLink( $limit, 3, $page, $more ) . " | " .
171 rcDaysLink( $limit, 7, $page, $more ) . " | " .
172 rcDaysLink( $limit, 14, $page, $more ) . " | " .
173 rcDaysLink( $limit, 30, $page, $more ) .
174 ( $doall ?
( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
175 $shm = wfMsg( "showhideminor", $minorLink, $botLink, $liuLink );
176 $note = wfMsg( "rclinks", $cl, $dl, $shm );
180 # Obsolete? Isn't called from anywhere and $mlink isn't defined
181 function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
183 if ($more != "") $more .= "&";
184 $cl = rcCountLink( 50, 0, $page, $more ) . " | " .
185 rcCountLink( 100, 0, $page, $more ) . " | " .
186 rcCountLink( 250, 0, $page, $more ) . " | " .
187 rcCountLink( 500, 0, $page, $more ) .
188 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
189 $note = wfMsg( "rclinks", $cl, "", $mlink );