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, $wgRequest;
19 $fname = 'wfSpecialRecentchangeslinked';
21 $days = $wgRequest->getInt( 'days' );
22 $target = isset($par) ?
$par : $wgRequest->getText( 'target' );
23 $hideminor = $wgRequest->getBool( 'hideminor' ) ?
1 : 0;
25 $wgOut->setPagetitle( wfMsg( 'recentchangeslinked' ) );
26 $sk = $wgUser->getSkin();
29 $nt = Title
::newFromURL( $target );
30 if( !is_object( $nt ) ) {
31 $wgOut->errorPage( 'notargettitle', 'notargettext' );
36 # Do a quiet redirect back to the page itself if it doesn't
37 if( !$nt->exists() ) {
38 $wgOut->redirect( $nt->getLocalUrl() );
42 $id = $nt->getArticleId();
44 $wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
47 $days = (int)$wgUser->getOption( 'rcdays', 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 rc_minor=0';
68 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
69 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
71 $uid = $wgUser->getID();
74 GROUP BY rc_cur_id,rc_namespace,rc_title,
75 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
76 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type
77 " . ($uid ?
",wl_user" : "") . "
78 ORDER BY rc_timestamp DESC
81 // If target is a Category, use categorylinks and invert from and to
82 if( $nt->getNamespace() == NS_CATEGORY
) {
83 $catkey = $dbr->addQuotes( $nt->getDBKey() );
84 $sql = "SELECT /* wfSpecialRecentchangeslinked */
102 " . ($uid ?
",wl_user" : "") . "
103 FROM $categorylinks, $recentchanges
104 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
105 WHERE rc_timestamp > '{$cutoff}'
107 AND cl_from=rc_cur_id
113 "SELECT /* wfSpecialRecentchangeslinked */
131 " . ($uid ?
",wl_user" : "") . "
132 FROM $pagelinks, $recentchanges
133 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
134 WHERE rc_timestamp > '{$cutoff}'
136 AND pl_namespace=rc_namespace
137 AND pl_title=rc_title
142 $res = $dbr->query( $sql, $fname );
144 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
145 $note = wfMsg( "rcnote", $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
146 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
148 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
149 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
152 $wgOut->addHTML( $note."\n" );
154 $list = ChangesList
::newFromUser( $wgUser );
155 $s = $list->beginRecentChangesList();
156 $count = $dbr->numRows( $res );
160 if ( 0 == $count ) { break; }
161 $obj = $dbr->fetchObject( $res );
163 $rc = RecentChange
::newFromRow( $obj );
164 $rc->counter
= $counter++
;
165 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
168 $s .= $list->endRecentChangesList();
170 $dbr->freeResult( $res );
171 $wgOut->addHTML( $s );