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->showErrorPage( 'notargettitle', 'notargettext' );
31 $nt = Title
::newFromURL( $target );
33 $wgOut->showErrorPage( '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_log_type,rc_log_action,rc_params,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 */
102 " . ($uid ?
",wl_user" : "") . "
103 FROM $categorylinks, $recentchanges
104 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
105 WHERE rc_timestamp > '{$cutoff}'
107 AND cl_from=rc_cur_id
113 "SELECT /* wfSpecialRecentchangeslinked */
135 " . ($uid ?
",wl_user" : "") . "
136 FROM $pagelinks, $recentchanges
137 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
138 WHERE rc_timestamp > '{$cutoff}'
140 AND pl_namespace=rc_namespace
141 AND pl_title=rc_title
146 $res = $dbr->query( $sql, $fname );
148 $wgOut->addHTML("< ".$sk->makeLinkObj($nt, "", "redirect=no" )."<br />\n");
149 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
150 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
152 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
153 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
156 $wgOut->addHTML( $note."\n" );
158 $list = ChangesList
::newFromUser( $wgUser );
159 $s = $list->beginRecentChangesList();
160 $count = $dbr->numRows( $res );
166 if ( 0 == $count ) { break; }
167 $obj = $dbr->fetchObject( $res );
169 $rc = RecentChange
::newFromRow( $obj );
170 $rc->counter
= $counter++
;
171 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
176 $wgOut->addWikiMsg('recentchangeslinked-noresult');
178 $s .= $list->endRecentChangesList();
180 $dbr->freeResult( $res );
181 $wgOut->addHTML( $s );
183 global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
184 $feedFormat = $wgRequest->getVal( 'feed' );
185 if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) {
186 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . ' [' . $wgContLanguageCode . ']';
187 $feed = new $wgFeedClasses[$feedFormat]( $feedTitle,
188 htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() );
190 require_once( "SpecialRecentchanges.php" );
192 rcDoOutputFeed( $rchanges, $feed );