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