Date/time fixes: try to ensure that timestamps are always kept in GMT, with conversio...
[lhc/web/wiklou.git] / includes / SpecialRecentchangeslinked.php
1 <?
2 global $IP;
3 include_once( "$IP/SpecialRecentchanges.php" );
4
5 function wfSpecialRecentchangeslinked()
6 {
7 global $wgUser, $wgOut, $wgLang, $wgTitle;
8 global $days, $target, $hideminor; # From query string
9 $fname = "wfSpecialRecentchangeslinked";
10
11 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
12 $sk = $wgUser->getSkin();
13
14 if ( "" == $target ) {
15 $wgOut->errorpage( "notargettitle", "notargettext" );
16 return;
17 }
18 $nt = Title::newFromURL( $target );
19 $sub = str_replace( "$1", $nt->getPrefixedText(), wfMsg( "rclsub" ) );
20 $wgOut->setSubtitle( $sub );
21
22 if ( ! $days ) {
23 $days = $wgUser->getOption( "rcdays" );
24 if ( ! $days ) { $days = 7; }
25 }
26 $days = (int)$days;
27 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
28 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
29
30 if ( ! isset( $hideminor ) ) {
31 $hideminor = $wgUser->getOption( "hideminor" );
32 }
33 if ( $hideminor ) {
34 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
35 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
36 "&days={$days}&limit={$limit}&hideminor=0" );
37 } else {
38 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
39 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
40 "&days={$days}&limit={$limit}&hideminor=1" );
41 }
42 if ( $hideminor ) {
43 $cmq = "AND cur_minor_edit=0";
44 } else { $cmq = ""; }
45
46 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
47 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
48 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
49 wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
50 "ORDER BY inverse_timestamp LIMIT {$limit}";
51 $res = wfQuery( $sql, $fname );
52
53 $note = wfMsg( "rcnote", $limit, $days );
54 $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
55
56 $tu = "target=" . $nt->getPrefixedURL();
57 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked", $tu );
58 $wgOut->addHTML( "{$note}\n" );
59
60 $s = $sk->beginRecentChangesList();
61 $count = wfNumRows( $res );
62
63 while ( $limit ) {
64 if ( 0 == $count ) { break; }
65 $obj = wfFetchObject( $res );
66 --$count;
67
68 $ts = $obj->cur_timestamp;
69 $u = $obj->cur_user;
70 $ut = $obj->cur_user_text;
71 $ns = $obj->cur_namespace;
72 $ttl = $obj->cur_title;
73 $com = $obj->cur_comment;
74 $me = ( $obj->cur_minor_edit > 0 );
75 $new = ( $obj->cur_is_new > 0 );
76
77 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
78 --$limit;
79 }
80 $s .= $sk->endRecentChangesList();
81
82 wfFreeResult( $res );
83 $wgOut->addHTML( $s );
84 }
85
86 ?>