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();
28 $nt = Title
::newFromURL( $target );
29 if( !is_object( $nt ) ) {
30 $wgOut->errorPage( 'notargettitle', 'notargettext' );
35 # Do a quiet redirect back to the page itself if it doesn't
36 if( !$nt->exists() ) {
37 $wgOut->redirect( $nt->getLocalUrl() );
41 $id = $nt->getArticleId();
43 $wgOut->setSubtitle( htmlspecialchars( wfMsg( 'rclsub', $nt->getPrefixedText() ) ) );
46 $days = (int)$wgUser->getOption( 'rcdays', 7 );
48 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
50 $dbr = wfGetDB( DB_SLAVE
,'recentchangeslinked' );
51 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
53 $hideminor = ($hideminor ?
1 : 0);
55 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
56 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
57 "&days={$days}&limit={$limit}&hideminor=0" );
59 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
60 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
61 "&days={$days}&limit={$limit}&hideminor=1" );
64 $cmq = 'AND rc_minor=0';
67 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
68 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
70 $uid = $wgUser->getID();
73 GROUP BY rc_cur_id,rc_namespace,rc_title,
74 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_deleted,
75 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len
76 " . ($uid ?
",wl_user" : "") . "
77 ORDER BY rc_timestamp DESC
80 // If target is a Category, use categorylinks and invert from and to
81 if( $nt->getNamespace() == NS_CATEGORY
) {
82 $catkey = $dbr->addQuotes( $nt->getDBKey() );
83 $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 */
132 " . ($uid ?
",wl_user" : "") . "
133 FROM $pagelinks, $recentchanges
134 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
135 WHERE rc_timestamp > '{$cutoff}'
137 AND pl_namespace=rc_namespace
138 AND pl_title=rc_title
143 $res = $dbr->query( $sql, $fname );
145 $wgOut->addHTML("< ".$sk->makeKnownLinkObj($nt, "", "redirect=no" )."<br />\n");
146 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
147 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
149 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
150 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
153 $wgOut->addHTML( $note."\n" );
155 $list = ChangesList
::newFromUser( $wgUser );
156 $s = $list->beginRecentChangesList();
157 $count = $dbr->numRows( $res );
162 if ( 0 == $count ) { break; }
163 $obj = $dbr->fetchObject( $res );
165 $rc = RecentChange
::newFromRow( $obj );
166 $rc->counter
= $counter++
;
167 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
171 $wgOut->addWikiText( wfMsg('recentchangeslinked-noresult') );
173 $s .= $list->endRecentChangesList();
175 $dbr->freeResult( $res );
176 $wgOut->addHTML( $s );