Do *NOT* force all wikis into a non-functional initial state with a broken whitelist...
[mediawiki.git] / includes / SpecialRecentchangeslinked.php
blobb90b7b67055ad9f02583f4503427caa6d2f4a020
1 <?php
2 /**
3 * This is to display changes made to all articles linked in an article.
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
8 /**
11 require_once( 'SpecialRecentchanges.php' );
13 /**
14 * Entrypoint
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();
28 if( $par ) {
29 $target = $par;
31 if ( $target == '') {
32 $wgOut->errorpage( 'notargettitle', 'notargettext' );
33 return;
35 $nt = Title::newFromURL( $target );
36 if( !$nt ) {
37 $wgOut->errorpage( 'notargettitle', 'notargettext' );
38 return;
40 $id = $nt->getArticleId();
42 $wgOut->setSubtitle( wfMsg( 'rclsub', $nt->getPrefixedText() ) );
44 if ( ! $days ) {
45 $days = $wgUser->getOption( 'rcdays' );
46 if ( ! $days ) { $days = 7; }
48 $days = (int)$days;
49 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
51 $dbr =& wfGetDB( DB_SLAVE );
52 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
54 $hideminor = ($hideminor ? 1 : 0);
55 if ( $hideminor ) {
56 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
57 WfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
58 "&days={$days}&limit={$limit}&hideminor=0" );
59 } else {
60 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
61 WfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
62 "&days={$days}&limit={$limit}&hideminor=1" );
64 if ( $hideminor ) {
65 $cmq = 'AND rev_minor_edit=0';
66 } else { $cmq = ''; }
68 // If target is a Category, use categorylinks and invert from and to
69 if( $nt->getNamespace() == NS_CATEGORY ) {
70 $catkey = $dbr->addQuotes( $nt->getDBKey() );
71 $sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
72 "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $categorylinks, $revision, $page " .
73 "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND cl_from=page_id AND cl_to=$catkey " .
74 "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
75 "rev_timestamp,rev_minor_edit,page_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
76 } else {
77 $sql = "SELECT page_id,page_namespace,page_title,rev_user,rev_comment," .
78 "rev_user_text,rev_timestamp,rev_minor_edit,page_is_new FROM $links, $revision, $page " .
79 "WHERE rev_timestamp > '{$cutoff}' {$cmq} AND l_to=page_id AND l_from=$id " .
80 "GROUP BY page_id,page_namespace,page_title,rev_user,rev_comment,rev_user_text," .
81 "rev_timestamp,rev_minor_edit,page_is_new,inverse_timestamp ORDER BY inverse_timestamp LIMIT {$limit}";
83 $res = $dbr->query( $sql, $fname );
85 $wgOut->addHTML("&lt; ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
86 $note = wfMsg( "rcnote", $limit, $days );
87 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
89 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
90 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
91 false, $mlink );
93 $wgOut->addHTML( $note."\n" );
95 $list =& new ChangesList( $sk );
96 $s = $list->beginRecentChangesList();
97 $count = $dbr->numRows( $res );
99 $counter = 1;
100 while ( $limit ) {
101 if ( 0 == $count ) { break; }
102 $obj = $dbr->fetchObject( $res );
103 --$count;
105 $rc = RecentChange::newFromCurRow( $obj );
106 $rc->counter = $counter++;
107 $s .= $list->recentChangesLine( $rc );
108 --$limit;
110 $s .= $list->endRecentChangesList();
112 $dbr->freeResult( $res );
113 $wgOut->addHTML( $s );