3 function wfSpecialRecentchanges( $par )
5 global $wgUser, $wgOut, $wgLang, $wgTitle;
6 global $days, $hideminor, $from, $hidebots; # 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;
17 $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
18 $res = wfQuery( $sql, DB_READ
, $fname );
19 $s = wfFetchObject( $res );
20 if( $wgOut->checkLastModified( $s->lastmod
) ){
21 # Client cache fresh and headers sent, nothing more to do.
25 $rctext = wfMsg( "recentchangestext" );
27 # The next few lines can probably be commented out now that wfMsg can get text from the DB
28 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
29 $res = wfQuery( $sql, DB_READ
, $fname );
30 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
31 $rctext = $s->cur_text
;
34 $wgOut->addWikiText( $rctext );
37 $days = $wgUser->getOption( "rcdays" );
38 if ( ! $days ) { $days = 3; }
41 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
42 $now = wfTimestampNow();
43 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
44 if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
50 $sk = $wgUser->getSkin();
52 if ( ! isset( $hideminor ) ) {
53 $hideminor = $wgUser->getOption( "hideminor" );
55 $hideminor = ($hideminor ?
1 : 0);
57 $hidem = "AND rc_minor=0";
58 $mltitle = wfMsg( "show" );
62 $mltitle = wfMsg( "hide" );
66 if ( isset( $from ) ) {
67 $mlparams = "from={$from}&hideminor={$mlhide}";
69 $mlparams = "days={$days}&limit={$limit}&hideminor={$mlhide}";
72 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
73 $mltitle, $mlparams );
75 if ( !isset( $hidebots ) ) {
79 $hidem .= " AND rc_bot=0";
82 $uid = $wgUser->getID();
83 $sql2 = "SELECT rc_cur_id,rc_namespace,rc_title,rc_user,rc_new," .
84 "rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_this_oldid,rc_last_oldid,rc_bot" . ($uid ?
",wl_user" : "") . " FROM recentchanges " .
85 ($uid ?
"LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
86 "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
87 "ORDER BY rc_timestamp DESC LIMIT {$limit}";
88 $res = wfQuery( $sql2, DB_READ
, $fname );
91 $note = wfMsg( "rcnotefrom", $limit,
92 $wgLang->timeanddate( $from, true ) );
94 $note = wfMsg( "rcnote", $limit, $days );
96 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
98 $note = rcDayLimitLinks( $days, $limit, "Recentchanges", "hideminor={$hideminor}", false, $mlink );
100 $note .= "<br>\n" . wfMsg( "rclistfrom",
101 $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
102 $wgLang->timeanddate( $now, true ), "hideminor={$hideminor}&from=$now" ) );
104 $wgOut->addHTML( "{$note}\n" );
106 $count1 = wfNumRows( $res );
107 $obj1 = wfFetchObject( $res );
109 $s = $sk->beginRecentChangesList();
111 if ( ( 0 == $count1 ) ) { break; }
113 $ts = $obj1->rc_timestamp
;
115 $ut = $obj1->rc_user_text
;
116 $ns = $obj1->rc_namespace
;
117 $ttl = $obj1->rc_title
;
118 $com = $obj1->rc_comment
;
119 $me = ( $obj1->rc_minor
> 0 );
120 $new = ( $obj1->rc_new
> 0 );
121 $watched = ($obj1->wl_user
> 0);
122 $oldid = $obj1->rc_this_oldid
;
123 $diffid = $obj1->rc_last_oldid
;
125 $obj1 = wfFetchObject( $res );
127 if ( ! ( $hideminor && $me ) ) {
128 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl,
129 $com, $me, $new, $watched, $oldid , $diffid );
133 $s .= $sk->endRecentChangesList();
135 wfFreeResult( $res );
136 $wgOut->addHTML( $s );
139 function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
141 global $wgUser, $wgLang;
142 $sk = $wgUser->getSkin();
143 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
144 ($lim ?
"{$lim}" : wfMsg( "all" ) ), "{$more}" .
145 ($d ?
"days={$d}&" : "") . "limit={$lim}" );
149 function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" )
151 global $wgUser, $wgLang;
152 $sk = $wgUser->getSkin();
153 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
154 ($d ?
"{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" .
155 ($lim ?
"&limit={$lim}" : "") );
159 function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall = false, $mlink = "" )
161 if ($more != "") $more .= "&";
162 $cl = rcCountLink( 50, $days, $page, $more ) . " | " .
163 rcCountLink( 100, $days, $page, $more ) . " | " .
164 rcCountLink( 250, $days, $page, $more ) . " | " .
165 rcCountLink( 500, $days, $page, $more ) .
166 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
167 $dl = rcDaysLink( $limit, 1, $page, $more ) . " | " .
168 rcDaysLink( $limit, 3, $page, $more ) . " | " .
169 rcDaysLink( $limit, 7, $page, $more ) . " | " .
170 rcDaysLink( $limit, 14, $page, $more ) . " | " .
171 rcDaysLink( $limit, 30, $page, $more ) .
172 ( $doall ?
( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
173 $shm = wfMsg( "showhideminor", $mlink );
174 $note = wfMsg( "rclinks", $cl, $dl, $shm );
178 function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
180 if ($more != "") $more .= "&";
181 $cl = rcCountLink( 50, 0, $page, $more ) . " | " .
182 rcCountLink( 100, 0, $page, $more ) . " | " .
183 rcCountLink( 250, 0, $page, $more ) . " | " .
184 rcCountLink( 500, 0, $page, $more ) .
185 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
186 $note = wfMsg( "rclinks", $cl, "", $mlink );