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, $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();
28 if (is_null($target)) {
29 $wgOut->errorpage( 'notargettitle', 'notargettext' );
32 $nt = Title
::newFromURL( $target );
34 $wgOut->errorpage( 'notargettitle', 'notargettext' );
37 $id = $nt->getArticleId();
39 $wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
42 $days = $wgUser->getOption( 'rcdays' );
43 if ( ! $days ) { $days = 7; }
46 list( $limit, $offset ) = wfCheckLimits( 100, 'rclimit' );
48 $dbr =& wfGetDB( DB_SLAVE
);
49 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
51 $hideminor = ($hideminor ?
1 : 0);
53 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
54 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
55 "&days={$days}&limit={$limit}&hideminor=0" );
57 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
58 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
59 "&days={$days}&limit={$limit}&hideminor=1" );
62 $cmq = 'AND rc_minor=0';
65 extract( $dbr->tableNames( 'recentchanges', 'categorylinks', 'pagelinks', 'revision', 'page' , "watchlist" ) );
67 $uid = $wgUser->getID();
69 // If target is a Category, use categorylinks and invert from and to
70 if( $nt->getNamespace() == NS_CATEGORY
) {
71 $catkey = $dbr->addQuotes( $nt->getDBKey() );
72 $sql = "SELECT /* wfSpecialRecentchangeslinked */
87 " . ($uid ?
",wl_user" : "") . "
88 FROM $categorylinks, $recentchanges
89 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
90 WHERE rc_timestamp > '{$cutoff}'
94 GROUP BY rc_cur_id,rc_namespace,rc_title,
95 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
97 ORDER BY rc_timestamp DESC
102 "SELECT /* wfSpecialRecentchangeslinked */
117 " . ($uid ?
",wl_user" : "") . "
118 FROM $pagelinks, $recentchanges
119 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
120 WHERE rc_timestamp > '{$cutoff}'
122 AND pl_namespace=rc_namespace
123 AND pl_title=rc_title
125 GROUP BY rc_cur_id,rc_namespace,rc_title,
126 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,
128 ORDER BY rc_timestamp DESC
131 $res = $dbr->query( $sql, $fname );
133 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
134 $note = wfMsg( "rcnote", $limit, $days );
135 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
137 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
138 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
141 $wgOut->addHTML( $note."\n" );
143 $list = ChangesList
::newFromUser( $wgUser );
144 $s = $list->beginRecentChangesList();
145 $count = $dbr->numRows( $res );
149 if ( 0 == $count ) { break; }
150 $obj = $dbr->fetchObject( $res );
155 $rc = RecentChange
::newFromRow( $obj );
156 $rc->counter
= $counter++
;
157 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
160 $s .= $list->endRecentChangesList();
162 $dbr->freeResult( $res );
163 $wgOut->addHTML( $s );