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' ) );
28 $nt = Title
::newFromURL( $target );
29 if( !is_object( $nt ) ) {
30 $wgOut->errorPage( 'notargettitle', 'notargettext' );
35 # Do a quiet redirect back to the page itself if it doesn't
36 if( !$nt->exists() ) {
37 $wgOut->redirect( $nt->getLocalUrl() );
41 $id = $nt->getArticleId();
43 $wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
46 $days = $wgUser->getOption( 'rcdays' );
47 if ( ! $days ) { $days = 7; }
50 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
52 $dbr =& wfGetDB( DB_SLAVE
);
53 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
55 $hideminor = ($hideminor ?
1 : 0);
57 $mlink = Linker
::makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
58 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
59 "&days={$days}&limit={$limit}&hideminor=0" );
61 $mlink = Linker
::makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
62 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
63 "&days={$days}&limit={$limit}&hideminor=1" );
66 $cmq = 'AND rc_minor=0';
69 extract( $dbr->tableNames( 'recentchanges', 'categorylinks', 'pagelinks', 'revision', 'page' , "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 */
100 " . ($uid ?
",wl_user" : "") . "
101 FROM $categorylinks, $recentchanges
102 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
103 WHERE rc_timestamp > '{$cutoff}'
105 AND cl_from=rc_cur_id
111 "SELECT /* wfSpecialRecentchangeslinked */
127 " . ($uid ?
",wl_user" : "") . "
128 FROM $pagelinks, $recentchanges
129 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
130 WHERE rc_timestamp > '{$cutoff}'
132 AND pl_namespace=rc_namespace
133 AND pl_title=rc_title
138 $res = $dbr->query( $sql, $fname );
140 $wgOut->addHTML("< ".Linker
::makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
141 $note = wfMsg( "rcnote", $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
142 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
144 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
145 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
148 $wgOut->addHTML( $note."\n" );
150 $list = ChangesList
::newFromUser( $wgUser );
151 $s = $list->beginRecentChangesList();
152 $count = $dbr->numRows( $res );
156 if ( 0 == $count ) { break; }
157 $obj = $dbr->fetchObject( $res );
159 $rc = RecentChange
::newFromRow( $obj );
160 $rc->counter
= $counter++
;
161 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
164 $s .= $list->endRecentChangesList();
166 $dbr->freeResult( $res );
167 $wgOut->addHTML( $s );