3 function wfSpecialRecentchanges( $par )
5 global $wgUser, $wgOut, $wgLang, $wgTitle;
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 if( $wgOut->checkLastModified( $s->lastmod
) ){
22 # Client cache fresh and headers sent, nothing more to do.
26 $rctext = wfMsg( "recentchangestext" );
28 # The next few lines can probably be commented out now that wfMsg can get text from the DB
29 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
30 $res = wfQuery( $sql, DB_READ
, $fname );
31 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
32 $rctext = $s->cur_text
;
35 $wgOut->addWikiText( $rctext );
38 $days = $wgUser->getOption( "rcdays" );
39 if ( ! $days ) { $days = 3; }
42 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
43 $now = wfTimestampNow();
44 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
45 if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
51 $sk = $wgUser->getSkin();
53 if ( ! isset( $hideminor ) ) {
54 $hideminor = $wgUser->getOption( "hideminor" );
56 $hideminor = ($hideminor ?
1 : 0);
58 $hidem = "AND rc_minor=0";
59 $mltitle = wfMsg( "show" );
63 $mltitle = wfMsg( "hide" );
67 if ( isset( $from ) ) {
68 $mlparams = "from={$from}&hideminor={$mlhide}";
70 $mlparams = "days={$days}&limit={$limit}&hideminor={$mlhide}";
73 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
74 $mltitle, $mlparams );
76 if ( !isset( $hidebots ) ) {
80 $hidem .= " AND rc_bot=0";
84 $hidem .= " AND rc_user=0";
87 $uid = $wgUser->getID();
88 $sql2 = "SELECT recentchanges.*" . ($uid ?
",wl_user" : "") . " FROM recentchanges " .
89 ($uid ?
"LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
90 "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
91 "ORDER BY rc_timestamp DESC LIMIT {$limit}";
92 $res = wfQuery( $sql2, DB_READ
, $fname );
95 $note = wfMsg( "rcnotefrom", $limit,
96 $wgLang->timeanddate( $from, true ) );
98 $note = wfMsg( "rcnote", $limit, $days );
100 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
102 $note = rcDayLimitLinks( $days, $limit, "Recentchanges", "hideminor={$hideminor}", false, $mlink );
104 $note .= "<br>\n" . wfMsg( "rclistfrom",
105 $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
106 $wgLang->timeanddate( $now, true ), "hideminor={$hideminor}&from=$now" ) );
108 $wgOut->addHTML( "{$note}\n" );
110 $count1 = wfNumRows( $res );
111 $obj1 = wfFetchObject( $res );
113 $s = $sk->beginRecentChangesList();
115 if ( ( 0 == $count1 ) ) {
118 if ( ! ( $hideminor && $obj1->rc_minor
) ) {
119 $rc = RecentChange
::newFromRow( $obj1 );
120 $s .= $sk->recentChangesLine( $rc, $obj1->wl_user
);
123 $obj1 = wfFetchObject( $res );
126 $s .= $sk->endRecentChangesList();
128 wfFreeResult( $res );
129 $wgOut->addHTML( $s );
132 function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
134 global $wgUser, $wgLang;
135 $sk = $wgUser->getSkin();
136 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
137 ($lim ?
"{$lim}" : wfMsg( "all" ) ), "{$more}" .
138 ($d ?
"days={$d}&" : "") . "limit={$lim}" );
142 function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" )
144 global $wgUser, $wgLang;
145 $sk = $wgUser->getSkin();
146 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
147 ($d ?
"{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" .
148 ($lim ?
"&limit={$lim}" : "") );
152 function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall = false, $mlink = "" )
154 if ($more != "") $more .= "&";
155 $cl = rcCountLink( 50, $days, $page, $more ) . " | " .
156 rcCountLink( 100, $days, $page, $more ) . " | " .
157 rcCountLink( 250, $days, $page, $more ) . " | " .
158 rcCountLink( 500, $days, $page, $more ) .
159 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
160 $dl = rcDaysLink( $limit, 1, $page, $more ) . " | " .
161 rcDaysLink( $limit, 3, $page, $more ) . " | " .
162 rcDaysLink( $limit, 7, $page, $more ) . " | " .
163 rcDaysLink( $limit, 14, $page, $more ) . " | " .
164 rcDaysLink( $limit, 30, $page, $more ) .
165 ( $doall ?
( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
166 $shm = wfMsg( "showhideminor", $mlink );
167 $note = wfMsg( "rclinks", $cl, $dl, $shm );
171 function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
173 if ($more != "") $more .= "&";
174 $cl = rcCountLink( 50, 0, $page, $more ) . " | " .
175 rcCountLink( 100, 0, $page, $more ) . " | " .
176 rcCountLink( 250, 0, $page, $more ) . " | " .
177 rcCountLink( 500, 0, $page, $more ) .
178 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
179 $note = wfMsg( "rclinks", $cl, "", $mlink );