* td background set to White to avoid header border shining through
[mediawiki.git] / includes / SpecialRecentchangeslinked.php
blob25c1687fb1293ef8a122c61bce984a95230a9e7a
1 <?php
2 include_once( "SpecialRecentchanges.php" );
4 function wfSpecialRecentchangeslinked( $par = NULL )
6 global $wgUser, $wgOut, $wgLang, $wgTitle, $wgRequest;
7 $fname = "wfSpecialRecentchangeslinked";
9 $days = $wgRequest->getInt( 'days' );
10 $target = $wgRequest->getText( 'target' );
11 $hideminor = $wgRequest->getBool( 'hideminor' ) ? 1 : 0;
13 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
14 $sk = $wgUser->getSkin();
16 if( $par ) {
17 $target = $par;
19 if ( "" == $target ) {
20 $wgOut->errorpage( "notargettitle", "notargettext" );
21 return;
23 $nt = Title::newFromURL( $target );
24 if( !$nt ) {
25 $wgOut->errorpage( "notargettitle", "notargettext" );
26 return;
28 $id = $nt->getArticleId();
30 $wgOut->setSubtitle( wfMsg( "rclsub", $nt->getPrefixedText() ) );
32 if ( ! $days ) {
33 $days = $wgUser->getOption( "rcdays" );
34 if ( ! $days ) { $days = 7; }
36 $days = (int)$days;
37 list( $limit, $offset ) = wfCheckLimits( 100, "rclimit" );
38 $cutoff = wfUnix2Timestamp( time() - ( $days * 86400 ) );
40 $hideminor = ($hideminor ? 1 : 0);
41 if ( $hideminor ) {
42 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
43 WfMsg( "show" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
44 "&days={$days}&limit={$limit}&hideminor=0" );
45 } else {
46 $mlink = $sk->makeKnownLink( $wgLang->specialPage( "Recentchangeslinked" ),
47 WfMsg( "hide" ), "target=" . wfEscapeHTML( $nt->getPrefixedURL() ) .
48 "&days={$days}&limit={$limit}&hideminor=1" );
50 if ( $hideminor ) {
51 $cmq = "AND cur_minor_edit=0";
52 } else { $cmq = ""; }
54 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
55 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM links, cur " .
56 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
57 "GROUP BY cur_id ORDER BY inverse_timestamp LIMIT {$limit}";
58 $res = wfQuery( $sql, DB_READ, $fname );
60 $note = wfMsg( "rcnote", $limit, $days );
61 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
63 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
64 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
65 false, $mlink );
67 $wgOut->addHTML( "{$note}\n" );
69 $s = $sk->beginRecentChangesList();
70 $count = wfNumRows( $res );
72 while ( $limit ) {
73 if ( 0 == $count ) { break; }
74 $obj = wfFetchObject( $res );
75 --$count;
77 $rc = RecentChange::newFromCurRow( $obj );
78 $s .= $sk->recentChangesLine( $rc );
79 --$limit;
81 $s .= $sk->endRecentChangesList();
83 wfFreeResult( $res );
84 $wgOut->addHTML( $s );