Initial revision
[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, $limit, $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 if ( ! $limit ) {
27 $limit = $wgUser->getOption( "rclimit" );
28 if ( ! $limit ) { $limit = 100; }
29 }
30 $cutoff = date( "YmdHis", time() - ( $days * 86400 ) );
31
32 if ( ! isset( $hideminor ) ) {
33 $hideminor = $wgUser->getOption( "hideminor" );
34 }
35 if ( $hideminor ) {
36 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
37 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
38 "&days={$days}&limit={$limit}&hideminor=0" );
39 } else {
40 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
41 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
42 "&days={$days}&limit={$limit}&hideminor=1" );
43 }
44 if ( $hideminor ) {
45 $cmq = "AND cur_minor_edit=0";
46 } else { $cmq = ""; }
47
48 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
49 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
50 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from='" .
51 wfStrencode( $nt->getPrefixedDBkey() ) . "' GROUP BY cur_id " .
52 "ORDER BY inverse_timestamp LIMIT {$limit}";
53 $res = wfQuery( $sql, $fname );
54
55 $note = str_replace( "$1", $limit, wfMsg( "rcnote" ) );
56 $note = str_replace( "$2", $days, $note );
57 $wgOut->addHTML( "<hr>\n{$note}\n<br>" );
58
59 $tu = "target=" . $nt->getPrefixedURL();
60 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked", $tu );
61 $wgOut->addHTML( "{$note}\n" );
62
63 $s = $sk->beginRecentChangesList();
64 $count = wfNumRows( $res );
65
66 while ( $limit ) {
67 if ( 0 == $count ) { break; }
68 $obj = wfFetchObject( $res );
69 --$count;
70
71 $ts = $obj->cur_timestamp;
72 $u = $obj->cur_user;
73 $ut = $obj->cur_user_text;
74 $ns = $obj->cur_namespace;
75 $ttl = $obj->cur_title;
76 $com = $obj->cur_comment;
77 $me = ( $obj->cur_minor_edit > 0 );
78 $new = ( $obj->cur_is_new > 0 );
79
80 $s .= $sk->recentChangesLine( $ts, $u, $ut, $ns, $ttl, $com, $me, $new );
81 --$limit;
82 }
83 $s .= $sk->endRecentChangesList();
84
85 wfFreeResult( $res );
86 $wgOut->addHTML( $s );
87 }
88
89 ?>