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();
27 if (is_null($target)) {
28 $wgOut->errorpage( 'notargettitle', 'notargettext' );
31 $nt = Title
::newFromURL( $target );
33 $wgOut->errorpage( 'notargettitle', 'notargettext' );
36 $id = $nt->getArticleId();
38 $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $nt->getPrefixedText() ) );
39 $wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
42 $days = (int)$wgUser->getOption( 'rcdays', 7 );
44 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
46 $dbr = wfGetDB( DB_SLAVE
,'recentchangeslinked' );
47 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
49 $hideminor = ($hideminor ?
1 : 0);
51 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
52 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
53 "&days={$days}&limit={$limit}&hideminor=0" );
55 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
56 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
57 "&days={$days}&limit={$limit}&hideminor=1" );
60 $cmq = 'AND rc_minor=0';
63 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
64 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
66 $uid = $wgUser->getID();
69 GROUP BY rc_cur_id,rc_namespace,rc_title,
70 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_deleted,
71 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len
72 " . ($uid ?
",wl_user" : "") . "
73 ORDER BY rc_timestamp DESC
76 // If target is a Category, use categorylinks and invert from and to
77 if( $nt->getNamespace() == NS_CATEGORY
) {
78 $catkey = $dbr->addQuotes( $nt->getDBKey() );
79 $sql = "SELECT /* wfSpecialRecentchangeslinked */
98 " . ($uid ?
",wl_user" : "") . "
99 FROM $categorylinks, $recentchanges
100 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
101 WHERE rc_timestamp > '{$cutoff}'
103 AND cl_from=rc_cur_id
109 "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->makeLinkObj($nt, "", "redirect=no" )."<br />\n");
142 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $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 );
158 if ( 0 == $count ) { break; }
159 $obj = $dbr->fetchObject( $res );
161 $rc = RecentChange
::newFromRow( $obj );
162 $rc->counter
= $counter++
;
163 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
167 $wgOut->addWikiText( wfMsg('recentchangeslinked-noresult') );
169 $s .= $list->endRecentChangesList();
171 $dbr->freeResult( $res );
172 $wgOut->addHTML( $s );