3 function wfSpecialRecentchanges()
5 global $wgUser, $wgOut, $wgLang, $wgTitle;
6 global $days, $limit, $hideminor, $from, $hidebots; # From query string
7 $fname = "wfSpecialRecentchanges";
9 $sql = "SELECT MAX(rc_timestamp) AS lastmod FROM recentchanges";
10 $res = wfQuery( $sql, $fname );
11 $s = wfFetchObject( $res );
12 $wgOut->checkLastModified( $s->lastmod
);
14 $rctext = wfMsg( "recentchangestext" );
15 $sql = "SELECT cur_text FROM cur WHERE cur_namespace=4 AND cur_title='Recentchanges'";
16 $res = wfQuery( $sql, $fname );
17 if( ( $s = wfFetchObject( $res ) ) and ( $s->cur_text
!= "" ) ) {
18 $rctext = $s->cur_text
;
20 $wgOut->addWikiText( $rctext );
23 $days = $wgUser->getOption( "rcdays" );
24 if ( ! $days ) { $days = 3; }
27 $limit = $wgUser->getOption( "rclimit" );
28 if ( ! $limit ) { $limit = 100; }
30 $cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
31 if(preg_match('/^[0-9]{14}$/', $from) and $from > $cutoff) {
37 $sk = $wgUser->getSkin();
39 if ( ! isset( $hideminor ) ) {
40 $hideminor = $wgUser->getOption( "hideminor" );
43 $hidem = "AND rc_minor=0";
44 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
45 WfMsg( "show" ), "days={$days}&limit={$limit}&hideminor=0" );
48 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
49 WfMsg( "hide" ), "days={$days}&limit={$limit}&hideminor=1" );
52 if ( !isset( $hidebots ) ) {
56 $hidem .= " AND rc_bot=0";
59 $uid = $wgUser->getID();
60 $sql2 = "SELECT rc_cur_id,rc_namespace,rc_title,rc_user,rc_new," .
61 "rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_this_oldid,rc_last_oldid,rc_bot" . ($uid ?
",wl_user" : "") . " FROM recentchanges " .
62 ($uid ?
"LEFT OUTER JOIN watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace & 65534 " : "") .
63 "WHERE rc_timestamp > '{$cutoff}' {$hidem} " .
64 "ORDER BY rc_timestamp DESC LIMIT {$limit}";
65 $res = wfQuery( $sql2, $fname );
68 $note = str_replace( "$1", $limit, wfMsg( "rcnotefrom" ) );
69 $note = str_replace( "$2", $wgLang->timeanddate( $from, true ), $note );
71 $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
72 $note = str_replace( "$2", $days, $note );
74 $wgOut->addHTML( "\n<hr>\n{$note}\n<br>" );
76 $note = rcDayLimitLinks( $days, $limit );
78 $now = date( "YmdHis" );
79 $note .= "<br>\n" . str_replace( "$1",
80 $sk->makeKnownLink( $wgLang->specialPage( "Recentchanges" ),
81 $wgLang->timeanddate( $now, true ), "from=$now" ),
82 wfMsg( "rclistfrom" ) );
84 $wgOut->addHTML( "{$note}\n" );
86 $count1 = wfNumRows( $res );
87 $obj1 = wfFetchObject( $res );
89 $s = $sk->beginRecentChangesList();
91 if ( ( 0 == $count1 ) ) { break; }
93 $ts = $obj1->rc_timestamp
;
95 $ut = $obj1->rc_user_text
;
96 $ns = $obj1->rc_namespace
;
97 $ttl = $obj1->rc_title
;
98 $com = $obj1->rc_comment
;
99 $me = ( $obj1->rc_minor
> 0 );
100 $new = ( $obj1->rc_new
> 0 );
101 $watched = ($obj1->wl_user
> 0);
102 $oldid = $obj1->rc_this_oldid
;
103 $diffid = $obj1->rc_last_oldid
;
105 $obj1 = wfFetchObject( $res );
107 if ( ! ( $hideminor && $me ) ) {
108 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl,
109 $com, $me, $new, $watched, $oldid , $diffid );
113 $s .= $sk->endRecentChangesList();
115 wfFreeResult( $res );
116 $wgOut->addHTML( $s );
119 function rcCountLink( $lim, $d, $page="Recentchanges", $more="" )
121 global $wgUser, $wgLang;
122 $sk = $wgUser->getSkin();
123 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
124 ($lim ?
"{$lim}" : wfMsg( "all" ) ), "{$more}" .
125 ($d ?
"days={$d}&" : "") . "limit={$lim}" );
129 function rcDaysLink( $lim, $d, $page="Recentchanges", $more="" )
131 global $wgUser, $wgLang;
132 $sk = $wgUser->getSkin();
133 $s = $sk->makeKnownLink( $wgLang->specialPage( $page ),
134 ($d ?
"{$d}" : wfMsg( "all" ) ), "{$more}days={$d}" .
135 ($lim ?
"&limit={$lim}" : "") );
139 function rcDayLimitLinks( $days, $limit, $page="Recentchanges", $more="", $doall = false )
141 if ($more != "") $more .= "&";
142 $cl = rcCountLink( 50, $days, $page, $more ) . " | " .
143 rcCountLink( 100, $days, $page, $more ) . " | " .
144 rcCountLink( 250, $days, $page, $more ) . " | " .
145 rcCountLink( 500, $days, $page, $more ) .
146 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
147 $dl = rcDaysLink( $limit, 1, $page, $more ) . " | " .
148 rcDaysLink( $limit, 3, $page, $more ) . " | " .
149 rcDaysLink( $limit, 7, $page, $more ) . " | " .
150 rcDaysLink( $limit, 14, $page, $more ) . " | " .
151 rcDaysLink( $limit, 30, $page, $more ) .
152 ( $doall ?
( " | " . rcDaysLink( $limit, 0, $page, $more ) ) : "" );
153 $note = str_replace( "$1", $cl, wfMsg( "rclinks" ) );
154 $note = str_replace( "$2", $dl, $note );
155 $note = str_replace( "$3", $mlink, $note );
159 function rcLimitLinks( $page="Recentchanges", $more="", $doall = false )
161 if ($more != "") $more .= "&";
162 $cl = rcCountLink( 50, 0, $page, $more ) . " | " .
163 rcCountLink( 100, 0, $page, $more ) . " | " .
164 rcCountLink( 250, 0, $page, $more ) . " | " .
165 rcCountLink( 500, 0, $page, $more ) .
166 ( $doall ?
( " | " . rcCountLink( 0, $days, $page, $more ) ) : "" );
167 $note = str_replace( "$1", $cl, wfMsg( "rclinks" ) );
168 $note = str_replace( "$3", $mlink, $note );