3 * This is to display changes made to all articles linked in an article.
5 * @subpackage SpecialPage
11 require_once( 'SpecialRecentchanges.php' );
15 * @param string $par parent page we will look at
17 function wfSpecialRecentchangeslinked( $par = NULL ) {
18 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgTitle, $wgRequest;
19 $fname = 'wfSpecialRecentchangeslinked';
21 $days = $wgRequest->getInt( 'days' );
22 $target = $wgRequest->getText( 'target' );
23 $hideminor = $wgRequest->getBool( 'hideminor' ) ?
1 : 0;
25 $wgOut->setPagetitle( wfMsg( "recentchanges" ) );
26 $sk = $wgUser->getSkin();
32 $wgOut->errorpage( 'notargettitle', 'notargettext' );
35 $nt = Title
::newFromURL( $target );
37 $wgOut->errorpage( 'notargettitle', 'notargettext' );
40 $id = $nt->getArticleId();
42 $wgOut->setSubtitle( wfMsg( 'rclsub', $nt->getPrefixedText() ) );
45 $days = $wgUser->getOption( 'rcdays' );
46 if ( ! $days ) { $days = 7; }
49 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
51 $dbr =& wfGetDB( DB_SLAVE
);
52 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
54 $hideminor = ($hideminor ?
1 : 0);
56 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
57 WfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
58 "&days={$days}&limit={$limit}&hideminor=0" );
60 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
61 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
62 "&days={$days}&limit={$limit}&hideminor=1" );
65 $cmq = 'AND cur_minor_edit=0';
68 // If target is a Category, use categorylinks and invert from and to
69 if ( $nt->getNamespace() == NS_CATEGORY
) {
70 extract( $dbr->tableNames( 'cur', 'categorylinks' ) );
71 $catkey = $dbr->addQuotes( $nt->getDBKey() );
72 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
73 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM $categorylinks, $cur " .
74 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND cl_from=cur_id AND cl_to=$catkey " .
75 "GROUP BY cur_id,cur_namespace,cur_title,cur_user,cur_comment,cur_user_text," .
76 "cur_timestamp,cur_minor_edit,cur_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
78 extract( $dbr->tableNames( 'cur', 'links' ) );
79 $sql = "SELECT cur_id,cur_namespace,cur_title,cur_user,cur_comment," .
80 "cur_user_text,cur_timestamp,cur_minor_edit,cur_is_new FROM $links, $cur " .
81 "WHERE cur_timestamp > '{$cutoff}' {$cmq} AND l_to=cur_id AND l_from=$id " .
82 "GROUP BY cur_id,cur_namespace,cur_title,cur_user,cur_comment,cur_user_text," .
83 "cur_timestamp,cur_minor_edit,cur_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
86 $res = $dbr->query( $sql, $fname );
88 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
89 $note = wfMsg( "rcnote", $limit, $days );
90 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
92 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
93 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
96 $wgOut->addHTML( $note."\n" );
98 $list =& new ChangesList( $sk );
99 $s = $list->beginRecentChangesList();
100 $count = $dbr->numRows( $res );
104 if ( 0 == $count ) { break; }
105 $obj = $dbr->fetchObject( $res );
108 $rc = RecentChange
::newFromCurRow( $obj );
109 $rc->counter
= $counter++
;
110 $s .= $list->recentChangesLine( $rc );
113 $s .= $list->endRecentChangesList();
115 $dbr->freeResult( $res );
116 $wgOut->addHTML( $s );