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 '<p>' . Xml
::check( 'showlinkedto', $showlinkedto, array('id' => 'showlinkedto') ) .
37 ' ' . Xml
::label( wfMsg("recentchangeslinked-to"), 'showlinkedto' ) . "</p>\n" .
38 Xml
::hidden( 'title', $wgTitle->getPrefixedText() ). "\n" .
39 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
40 Xml
::closeElement( 'fieldset' ) .
41 Xml
::closeElement( 'form' ) . "\n"
47 $nt = Title
::newFromURL( $target );
49 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
52 $id = $nt->getArticleId();
54 $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $nt->getPrefixedText() ) );
55 $wgOut->setSyndicated();
56 $wgOut->setFeedAppendQuery( "target=" . urlencode( $target ) );
59 $days = (int)$wgUser->getOption( 'rcdays', 7 );
61 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
63 $dbr = wfGetDB( DB_SLAVE
,'recentchangeslinked' );
64 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
66 $hideminor = ($hideminor ?
1 : 0);
68 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
69 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
70 "&days={$days}&limit={$limit}&hideminor=0" );
72 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
73 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
74 "&days={$days}&limit={$limit}&hideminor=1" );
77 $cmq = 'AND rc_minor=0';
80 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
81 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
83 $uid = $wgUser->getID();
86 GROUP BY rc_cur_id,rc_namespace,rc_title,
87 rc_user,rc_comment,rc_user_text,rc_timestamp,rc_minor,rc_log_type,rc_log_action,rc_params,rc_deleted,
88 rc_new, rc_id, rc_this_oldid, rc_last_oldid, rc_bot, rc_patrolled, rc_type, rc_old_len, rc_new_len
89 " . ($uid ?
",wl_user" : "") . "
90 ORDER BY rc_timestamp DESC
93 // If target is a Category, use categorylinks and invert from and to
94 if( $nt->getNamespace() == NS_CATEGORY
) {
95 $catkey = $dbr->addQuotes( $nt->getDBkey() );
96 $sql = "SELECT /* wfSpecialRecentchangeslinked */
118 " . ($uid ?
",wl_user" : "") . "
119 FROM $categorylinks, $recentchanges
120 " . ($uid ?
"LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
121 WHERE rc_timestamp > '{$cutoff}'
123 AND cl_from=rc_cur_id
128 if( $showlinkedto ) {
129 $ns = $dbr->addQuotes( $nt->getNamespace() );
130 $dbkey = $dbr->addQuotes( $nt->getDBkey() );
131 $joinConds = "AND pl_namespace={$ns} AND pl_title={$dbkey} AND pl_from=rc_cur_id";
133 $joinConds = "AND pl_namespace=rc_namespace AND pl_title=rc_title AND pl_from=$id";
137 "SELECT /* wfSpecialRecentchangeslinked */
159 " . ($uid ?
",wl_user" : "") . "
160 FROM $pagelinks, $recentchanges
161 " . ($uid ?
" LEFT OUTER JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "") . "
162 WHERE rc_timestamp > '{$cutoff}'
168 $res = $dbr->query( $sql, $fname );
170 $wgOut->addHTML("< ".$sk->makeLinkObj($nt, "", "redirect=no" )."<br />\n");
171 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
172 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
174 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
175 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}",
178 $wgOut->addHTML( $note."\n" );
180 $list = ChangesList
::newFromUser( $wgUser );
181 $s = $list->beginRecentChangesList();
182 $count = $dbr->numRows( $res );
188 if ( 0 == $count ) { break; }
189 $obj = $dbr->fetchObject( $res );
191 $rc = RecentChange
::newFromRow( $obj );
192 $rc->counter
= $counter++
;
193 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
198 $wgOut->addWikiMsg('recentchangeslinked-noresult');
200 $s .= $list->endRecentChangesList();
202 $dbr->freeResult( $res );
203 $wgOut->addHTML( $s );
205 global $wgSitename, $wgFeedClasses, $wgContLanguageCode;
206 $feedFormat = $wgRequest->getVal( 'feed' );
207 if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) {
208 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) . ' [' . $wgContLanguageCode . ']';
209 $feed = new $wgFeedClasses[$feedFormat]( $feedTitle,
210 htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() );
212 require_once( "SpecialRecentchanges.php" );
214 rcDoOutputFeed( $rchanges, $feed );