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, $wgTitle;
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->setSyndicated();
40 $wgOut->setFeedAppendQuery( "target=" . urlencode( $target ) );
43 $days = (int)$wgUser->getOption( 'rcdays', 7 );
45 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
47 $dbr = wfGetDB( DB_SLAVE
,'recentchangeslinked' );
48 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
50 $hideminor = ($hideminor ?
1 : 0);
52 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
53 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
54 "&days={$days}&limit={$limit}&hideminor=0" );
56 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
57 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
58 "&days={$days}&limit={$limit}&hideminor=1" );
61 $cmq = 'AND rc_minor=0';
64 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
65 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
67 $uid = $wgUser->getID();
70 GROUP BY rc_cur_id,rc_namespace,rc_title,
71 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_deleted,
72 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len
73 " . ($uid ?
",wl_user" : "") . "
74 ORDER BY rc_timestamp DESC
77 // If target is a Category, use categorylinks and invert from and to
78 if( $nt->getNamespace() == NS_CATEGORY
) {
79 $catkey = $dbr->addQuotes( $nt->getDBkey() );
80 $sql = "SELECT /* wfSpecialRecentchangeslinked */
99 " . ($uid ?
",wl_user" : "") . "
100 FROM $categorylinks, $recentchanges
101 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
102 WHERE rc_timestamp > '{$cutoff}'
104 AND cl_from=rc_cur_id
110 "SELECT /* wfSpecialRecentchangeslinked */
129 " . ($uid ?
",wl_user" : "") . "
130 FROM $pagelinks, $recentchanges
131 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
132 WHERE rc_timestamp > '{$cutoff}'
134 AND pl_namespace=rc_namespace
135 AND pl_title=rc_title
140 $res = $dbr->query( $sql, $fname );
142 $wgOut->addHTML("< ".$sk->makeLinkObj($nt, "", "redirect=no" )."<br />\n");
143 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
144 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
146 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
147 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
150 $wgOut->addHTML( $note."\n" );
152 $list = ChangesList
::newFromUser( $wgUser );
153 $s = $list->beginRecentChangesList();
154 $count = $dbr->numRows( $res );
160 if ( 0 == $count ) { break; }
161 $obj = $dbr->fetchObject( $res );
163 $rc = RecentChange
::newFromRow( $obj );
164 $rc->counter
= $counter++
;
165 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
170 $wgOut->addWikiMsg('recentchangeslinked-noresult');
172 $s .= $list->endRecentChangesList();
174 $dbr->freeResult( $res );
175 $wgOut->addHTML( $s );
177 global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
178 $feedFormat = $wgRequest->getVal( 'feed' );
179 if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) {
180 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . ' [' . $wgContLanguageCode . ']';
181 $feed = new $wgFeedClasses[$feedFormat]( $feedTitle,
182 htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() );
184 require_once( "SpecialRecentchanges.php" );
186 rcDoOutputFeed( $rchanges, $feed );