3 * This is to display changes made to all articles linked in an article.
4 * @addtogroup SpecialPage
10 require_once( 'SpecialRecentchanges.php' );
14 * @param string $par parent page we will look at
16 function wfSpecialRecentchangeslinked( $par = NULL ) {
17 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
18 $fname = 'wfSpecialRecentchangeslinked';
20 $days = $wgRequest->getInt( 'days' );
21 $target = isset($par) ?
$par : $wgRequest->getText( 'target' );
22 $hideminor = $wgRequest->getBool( 'hideminor' ) ?
1 : 0;
24 $wgOut->setPagetitle( wfMsg( 'recentchangeslinked' ) );
25 $sk = $wgUser->getSkin();
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 = (int)$wgUser->getOption( 'rcdays', 7 );
48 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
50 $dbr = wfGetDB( DB_SLAVE
);
51 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
53 $hideminor = ($hideminor ?
1 : 0);
55 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
56 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
57 "&days={$days}&limit={$limit}&hideminor=0" );
59 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
60 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
61 "&days={$days}&limit={$limit}&hideminor=1" );
64 $cmq = 'AND rc_minor=0';
67 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
68 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
70 $uid = $wgUser->getID();
73 GROUP BY rc_cur_id,rc_namespace,rc_title,
74 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
75 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len
76 " . ($uid ?
",wl_user" : "") . "
77 ORDER BY rc_timestamp DESC
80 // If target is a Category, use categorylinks and invert from and to
81 if( $nt->getNamespace() == NS_CATEGORY
) {
82 $catkey = $dbr->addQuotes( $nt->getDBKey() );
83 $sql = "SELECT /* wfSpecialRecentchangeslinked */
101 " . ($uid ?
",wl_user" : "") . "
102 FROM $categorylinks, $recentchanges
103 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
104 WHERE rc_timestamp > '{$cutoff}'
106 AND cl_from=rc_cur_id
112 "SELECT /* wfSpecialRecentchangeslinked */
130 " . ($uid ?
",wl_user" : "") . "
131 FROM $pagelinks, $recentchanges
132 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
133 WHERE rc_timestamp > '{$cutoff}'
135 AND pl_namespace=rc_namespace
136 AND pl_title=rc_title
141 $res = $dbr->query( $sql, $fname );
143 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
144 $note = wfMsg( "rcnote", $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
145 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
147 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
148 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
151 $wgOut->addHTML( $note."\n" );
153 $list = ChangesList
::newFromUser( $wgUser );
154 $s = $list->beginRecentChangesList();
155 $count = $dbr->numRows( $res );
159 if ( 0 == $count ) { break; }
160 $obj = $dbr->fetchObject( $res );
162 $rc = RecentChange
::newFromRow( $obj );
163 $rc->counter
= $counter++
;
164 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
167 $s .= $list->endRecentChangesList();
169 $dbr->freeResult( $res );
170 $wgOut->addHTML( $s );