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, $wgScript;
18 $fname = 'wfSpecialRecentchangeslinked';
20 $days = $wgRequest->getInt( 'days' );
21 $target = isset($par) ?
$par : $wgRequest->getVal( 'target' );
22 $hideminor = $wgRequest->getBool( 'hideminor' ) ?
1 : 0;
23 $showlinkedto = $wgRequest->getBool( 'showlinkedto' ) ?
1 : 0;
25 $title = Title
::newFromURL( $target );
26 $target = $title ?
$title->getPrefixedText() : '';
28 $wgOut->setPagetitle( wfMsg( 'recentchangeslinked' ) );
29 $sk = $wgUser->getSkin();
32 Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
33 Xml
::openElement( 'fieldset' ) .
34 Xml
::element( 'legend', array(), wfMsg( 'recentchangeslinked' ) ) . "\n" .
35 Xml
::inputLabel( wfMsg( 'recentchangeslinked-page' ), 'target', 'recentchangeslinked-target', 40, $target ) .
36 " <span style='white-space: nowrap'>" .
37 Xml
::check( 'showlinkedto', $showlinkedto, array('id' => 'showlinkedto') ) . ' ' .
38 Xml
::label( wfMsg("recentchangeslinked-to"), 'showlinkedto' ) .
40 Xml
::hidden( 'title', $wgTitle->getPrefixedText() ). "\n" .
41 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
42 Xml
::closeElement( 'fieldset' ) .
43 Xml
::closeElement( 'form' ) . "\n"
49 $nt = Title
::newFromURL( $target );
51 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
54 $id = $nt->getArticleId();
56 $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $nt->getPrefixedText() ) );
57 $wgOut->setSyndicated();
58 $wgOut->setFeedAppendQuery( "target=" . urlencode( $target ) );
61 $days = (int)$wgUser->getOption( 'rcdays', 7 );
63 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
65 $dbr = wfGetDB( DB_SLAVE
,'recentchangeslinked' );
66 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
68 $hideminor = ($hideminor ?
1 : 0);
70 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
71 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
72 "&days={$days}&limit={$limit}&hideminor=0&showlinkedto={$showlinkedto}" );
74 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
75 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
76 "&days={$days}&limit={$limit}&hideminor=1&showlinkedto={$showlinkedto}" );
79 $cmq = 'AND rc_minor=0';
82 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
83 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
85 $uid = $wgUser->getID();
88 GROUP BY rc_cur_id,rc_namespace,rc_title,
89 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_log_type,rc_log_action,rc_params,rc_deleted,
90 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len
91 " . ($uid ?
",wl_user" : "") . "
92 ORDER BY rc_timestamp DESC
95 // If target is a Category, use categorylinks and invert from and to
96 if( $nt->getNamespace() == NS_CATEGORY
) {
97 $catkey = $dbr->addQuotes( $nt->getDBkey() );
98 $sql = "SELECT /* wfSpecialRecentchangeslinked */
120 " . ($uid ?
",wl_user" : "") . "
121 FROM $categorylinks, $recentchanges
122 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
123 WHERE rc_timestamp > '{$cutoff}'
125 AND cl_from=rc_cur_id
130 if( $showlinkedto ) {
131 $ns = $dbr->addQuotes( $nt->getNamespace() );
132 $dbkey = $dbr->addQuotes( $nt->getDBkey() );
133 $joinConds = "AND pl_namespace={$ns} AND pl_title={$dbkey} AND pl_from=rc_cur_id";
135 $joinConds = "AND pl_namespace=rc_namespace AND pl_title=rc_title AND pl_from=$id";
139 "SELECT /* wfSpecialRecentchangeslinked */
161 " . ($uid ?
",wl_user" : "") . "
162 FROM $pagelinks, $recentchanges
163 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
164 WHERE rc_timestamp > '{$cutoff}'
170 $res = $dbr->query( $sql, $fname );
172 $wgOut->addHTML("< ".$sk->makeLinkObj($nt, "", "redirect=no" )."<br />\n");
173 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
174 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
176 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
177 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}&showlinkedto={$showlinkedto}",
180 $wgOut->addHTML( $note."\n" );
182 $list = ChangesList
::newFromUser( $wgUser );
183 $s = $list->beginRecentChangesList();
184 $count = $dbr->numRows( $res );
190 if ( 0 == $count ) { break; }
191 $obj = $dbr->fetchObject( $res );
193 $rc = RecentChange
::newFromRow( $obj );
194 $rc->counter
= $counter++
;
195 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
200 $wgOut->addWikiMsg('recentchangeslinked-noresult');
202 $s .= $list->endRecentChangesList();
204 $dbr->freeResult( $res );
205 $wgOut->addHTML( $s );
207 global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
208 $feedFormat = $wgRequest->getVal( 'feed' );
209 if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) {
210 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . ' [' . $wgContLanguageCode . ']';
211 $feed = new $wgFeedClasses[$feedFormat]( $feedTitle,
212 htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() );
214 require_once( "SpecialRecentchanges.php" );
216 rcDoOutputFeed( $rchanges, $feed );