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 = $wgUser->getOption( 'rcdays' );
48 if ( ! $days ) { $days = 7; }
51 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
53 $dbr =& wfGetDB( DB_SLAVE
);
54 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
56 $hideminor = ($hideminor ?
1 : 0);
58 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
59 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
60 "&days={$days}&limit={$limit}&hideminor=0" );
62 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
63 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
64 "&days={$days}&limit={$limit}&hideminor=1" );
67 $cmq = 'AND rc_minor=0';
70 extract( $dbr->tableNames( 'recentchanges', 'categorylinks', 'pagelinks', 'revision', 'page' , "watchlist" ) );
72 $uid = $wgUser->getID();
75 GROUP BY rc_cur_id,rc_namespace,rc_title,
76 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
77 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type
78 " . ($uid ?
",wl_user" : "") . "
79 ORDER BY rc_timestamp DESC
82 // If target is a Category, use categorylinks and invert from and to
83 if( $nt->getNamespace() == NS_CATEGORY
) {
84 $catkey = $dbr->addQuotes( $nt->getDBKey() );
85 $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 */
128 " . ($uid ?
",wl_user" : "") . "
129 FROM $pagelinks, $recentchanges
130 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
131 WHERE rc_timestamp > '{$cutoff}'
133 AND pl_namespace=rc_namespace
134 AND pl_title=rc_title
139 $res = $dbr->query( $sql, $fname );
141 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
142 $note = wfMsg( "rcnote", $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
143 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
145 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
146 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
149 $wgOut->addHTML( $note."\n" );
151 $list = ChangesList
::newFromUser( $wgUser );
152 $s = $list->beginRecentChangesList();
153 $count = $dbr->numRows( $res );
157 if ( 0 == $count ) { break; }
158 $obj = $dbr->fetchObject( $res );
160 $rc = RecentChange
::newFromRow( $obj );
161 $rc->counter
= $counter++
;
162 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
165 $s .= $list->endRecentChangesList();
167 $dbr->freeResult( $res );
168 $wgOut->addHTML( $s );