3 function wfSpecialRecentchanges( $par )
5 global $wgUser, $wgOut, $wgLang, $wgTitle;
6 global $days, $hideminor, $from, $hidebots; # From query string
7 $days = $_REQUEST["days"];
8 $hideminor = $_REQUEST["hideminor"];
9 $from = $_REQUEST["from"];
10 $hidebots = $_REQUEST["hidebots"];
12 $fname = "wfSpecialRecentchanges";
15 $bits = preg_split( '/\s*,\s*/', trim( $par ) );
16 if( in_array( "hidebots", $bits ) ) $hidebots = 1;
17 if( in_array( "bots", $bits ) ) $hidebots = 0;
18 if( in_array( "hideminor", $bits ) ) $hideminor = 1;
19 if( in_array( "minor", $bits ) ) $hideminor = 0;
22 $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
23 $res = wfQuery( $sql, DB_READ
, $fname );
24 $s = wfFetchObject( $res );
25 $wgOut->checkLastModified( $s->lastmod
);
27 $rctext = wfMsg( "recentchangestext" );
29 # The next few lines can probably be commented out now that wfMsg can get text from the DB
30 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
31 $res = wfQuery( $sql, DB_READ
, $fname );
32 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
33 $rctext = $s->cur_text
;
36 $wgOut->addWikiText( $rctext );
39 $days = $wgUser->getOption( "rcdays" );
40 if ( ! $days ) { $days = 3; }
43 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
44 $now = wfTimestampNow();
45 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
46 if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
52 $sk = $wgUser->getSkin();
54 if ( ! isset( $hideminor ) ) {
55 $hideminor = $wgUser->getOption( "hideminor" );
58 $hidem = "AND rc_minor=0";
59 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
60 WfMsg( "show" ), "days={$days}&limit={$limit}&hideminor=0" );
63 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
64 WfMsg( "hide" ), "days={$days}&limit={$limit}&hideminor=1" );
67 if ( !isset( $hidebots ) ) {
71 $hidem .= " AND rc_bot=0";
74 $uid = $wgUser->getID();
75 $sql2 = "SELECT rc_cur_id,rc_namespace,rc_title,rc_user,rc_new," .
76 "rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_this_oldid,rc_last_oldid,rc_bot" . ($uid ?
",wl_user" : "") . " FROM recentchanges " .
77 ($uid ?
"LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
78 "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
79 "ORDER BY rc_timestamp DESC LIMIT {$limit}";
80 $res = wfQuery( $sql2, DB_READ
, $fname );
83 $note = wfMsg( "rcnotefrom", $limit,
84 $wgLang->timeanddate( $from, true ) );
86 $note = wfMsg( "rcnote", $limit, $days );
88 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
90 $note = rcDayLimitLinks( $days, $limit );
92 $note .= "<br>\n" . wfMsg( "rclistfrom",
93 $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
94 $wgLang->timeanddate( $now, true ), "from=$now" ) );
96 $wgOut->addHTML( "{$note}\n" );
98 $count1 = wfNumRows( $res );
99 $obj1 = wfFetchObject( $res );
101 $s = $sk->beginRecentChangesList();
103 if ( ( 0 == $count1 ) ) { break; }
105 $ts = $obj1->rc_timestamp
;
107 $ut = $obj1->rc_user_text
;
108 $ns = $obj1->rc_namespace
;
109 $ttl = $obj1->rc_title
;
110 $com = $obj1->rc_comment
;
111 $me = ( $obj1->rc_minor
> 0 );
112 $new = ( $obj1->rc_new
> 0 );
113 $watched = ($obj1->wl_user
> 0);
114 $oldid = $obj1->rc_this_oldid
;
115 $diffid = $obj1->rc_last_oldid
;
117 $obj1 = wfFetchObject( $res );
119 if ( ! ( $hideminor && $me ) ) {
120 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl,
121 $com, $me, $new, $watched, $oldid , $diffid );
125 $s .= $sk->endRecentChangesList();
127 wfFreeResult( $res );
128 $wgOut->addHTML( $s );
131 function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
133 global $wgUser, $wgLang;
134 $sk = $wgUser->getSkin();
135 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
136 ($lim ?
"{$lim}" : wfMsg( "all" ) ), "{$more}" .
137 ($d ?
"days={$d}&" : "") . "limit={$lim}" );
141 function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" )
143 global $wgUser, $wgLang;
144 $sk = $wgUser->getSkin();
145 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
146 ($d ?
"{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" .
147 ($lim ?
"&limit={$lim}" : "") );
151 function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall = false )
153 if ($more != "") $more .= "&";
154 $cl = rcCountLink( 50, $days, $page, $more ) . " | " .
155 rcCountLink( 100, $days, $page, $more ) . " | " .
156 rcCountLink( 250, $days, $page, $more ) . " | " .
157 rcCountLink( 500, $days, $page, $more ) .
158 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
159 $dl = rcDaysLink( $limit, 1, $page, $more ) . " | " .
160 rcDaysLink( $limit, 3, $page, $more ) . " | " .
161 rcDaysLink( $limit, 7, $page, $more ) . " | " .
162 rcDaysLink( $limit, 14, $page, $more ) . " | " .
163 rcDaysLink( $limit, 30, $page, $more ) .
164 ( $doall ?
( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
165 $note = wfMsg( "rclinks", $cl, $dl, $mlink );
169 function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
171 if ($more != "") $more .= "&";
172 $cl = rcCountLink( 50, 0, $page, $more ) . " | " .
173 rcCountLink( 100, 0, $page, $more ) . " | " .
174 rcCountLink( 250, 0, $page, $more ) . " | " .
175 rcCountLink( 500, 0, $page, $more ) .
176 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
177 $note = wfMsg( "rclinks", $cl, "", $mlink );