b841ade4ddf036f9eda8ca6fdb4c62b28b2f6f77
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;
19 $days = $wgRequest->getInt( 'days' );
20 $target = isset($par) ?
$par : $wgRequest->getVal( 'target' );
21 $hideminor = $wgRequest->getBool( 'hideminor' ) ?
1 : 0;
22 $showlinkedto = $wgRequest->getBool( 'showlinkedto' ) ?
1 : 0;
24 $title = Title
::newFromURL( $target );
25 $target = $title ?
$title->getPrefixedText() : '';
27 $wgOut->setPagetitle( wfMsg( 'recentchangeslinked' ) );
28 $sk = $wgUser->getSkin();
31 Xml
::openElement( 'form', array( 'method' => 'get', 'action' => $wgScript ) ) .
32 Xml
::openElement( 'fieldset' ) .
33 Xml
::element( 'legend', array(), wfMsg( 'recentchangeslinked' ) ) . "\n" .
34 Xml
::inputLabel( wfMsg( 'recentchangeslinked-page' ), 'target', 'recentchangeslinked-target', 40, $target ) .
35 " <span style='white-space: nowrap'>" .
36 Xml
::check( 'showlinkedto', $showlinkedto, array('id' => 'showlinkedto') ) . ' ' .
37 Xml
::label( wfMsg("recentchangeslinked-to"), 'showlinkedto' ) .
39 Xml
::hidden( 'title', $wgTitle->getPrefixedText() ). "\n" .
40 Xml
::submitButton( wfMsg( 'allpagessubmit' ) ) . "\n" .
41 Xml
::closeElement( 'fieldset' ) .
42 Xml
::closeElement( 'form' ) . "\n"
48 $nt = Title
::newFromURL( $target );
50 $wgOut->showErrorPage( 'notargettitle', 'notargettext' );
53 $id = $nt->getArticleId();
55 $wgOut->setPageTitle( wfMsg( 'recentchangeslinked-title', $nt->getPrefixedText() ) );
56 $wgOut->setSyndicated();
57 $wgOut->setFeedAppendQuery( "target=" . urlencode( $target ) );
60 $days = (int)$wgUser->getOption( 'rcdays', 7 );
62 list( $limit, /* offset */ ) = wfCheckLimits( 100, 'rclimit' );
64 $dbr = wfGetDB( DB_SLAVE
,'recentchangeslinked' );
65 $cutoff = $dbr->timestamp( time() - ( $days * 86400 ) );
67 $hideminor = ($hideminor ?
1 : 0);
69 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( 'Recentchangeslinked' ),
70 wfMsg( 'show' ), 'target=' . htmlspecialchars( $nt->getPrefixedURL() ) .
71 "&days={$days}&limit={$limit}&hideminor=0&showlinkedto={$showlinkedto}" );
73 $mlink = $sk->makeKnownLink( $wgContLang->specialPage( "Recentchangeslinked" ),
74 wfMsg( "hide" ), "target=" . htmlspecialchars( $nt->getPrefixedURL() ) .
75 "&days={$days}&limit={$limit}&hideminor=1&showlinkedto={$showlinkedto}" );
78 $cmq = 'AND rc_minor=0';
81 list($recentchanges, $categorylinks, $pagelinks, $watchlist) =
82 $dbr->tableNamesN( 'recentchanges', 'categorylinks', 'pagelinks', "watchlist" );
84 $uid = $wgUser->getID();
85 // The fields we are selecting
86 $fields = "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 $fields .= $uid ?
",wl_user" : "";
91 // Check if this should be a feed
93 global $wgSitename, $wgFeedClasses, $wgContLanguageCode, $wgFeedLimit;
94 $feedFormat = $wgRequest->getVal( 'feed' );
95 if( $feedFormat && isset( $wgFeedClasses[$feedFormat] ) ) {
96 $feedTitle = $wgSitename . ' - ' . wfMsgForContent( 'recentchangeslinked-title', $nt->getPrefixedText() ) .
97 ' [' . $wgContLanguageCode . ']';
98 $feed = new $wgFeedClasses[$feedFormat]( $feedTitle,
99 htmlspecialchars( wfMsgForContent('recentchangeslinked') ), $wgTitle->getFullUrl() );
101 if( $limit > $wgFeedLimit ) {
102 $limit = $wgFeedLimit;
106 // If target is a Category, use categorylinks and invert from and to
107 if( $nt->getNamespace() == NS_CATEGORY
) {
108 $catkey = $dbr->addQuotes( $nt->getDBkey() );
110 $tables = "$categorylinks, $recentchanges";
111 $tables .= $uid ?
"LEFT JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "";
113 $sql = "SELECT /* wfSpecialRecentchangeslinked */ $fields FROM $tables
114 WHERE rc_timestamp > '{$cutoff}' {$cmq}
115 AND cl_from=rc_cur_id
117 GROUP BY $fields ORDER BY rc_timestamp DESC LIMIT {$limit}"; // Shitty-ass GROUP BY by for postgres apparently
119 if( $showlinkedto ) {
120 $ns = $dbr->addQuotes( $nt->getNamespace() );
121 $dbkey = $dbr->addQuotes( $nt->getDBkey() );
122 $joinConds = "AND pl_namespace={$ns} AND pl_title={$dbkey} AND pl_from=rc_cur_id";
124 $joinConds = "AND pl_namespace=rc_namespace AND pl_title=rc_title AND pl_from=$id";
127 $tables = "$pagelinks, $recentchanges";
128 $tables .= $uid ?
"LEFT JOIN $watchlist ON wl_user={$uid} AND wl_title=rc_title AND wl_namespace=rc_namespace " : "";
130 $sql = "SELECT /* wfSpecialRecentchangeslinked */ $fields FROM $tables
131 WHERE rc_timestamp > '{$cutoff}' {$cmq}
133 GROUP BY $fields ORDER BY rc_timestamp DESC LIMIT {$limit}"; // Shitty-ass GROUP BY by for postgres apparently
135 # Actually do the query
136 $res = $dbr->query( $sql, __METHOD__
);
137 $count = $dbr->numRows( $res );
139 # Output feeds now and be done with it!
144 if ( 0 == $count ) { break; }
145 $obj = $dbr->fetchObject( $res );
147 $rc = RecentChange
::newFromRow( $obj );
148 $rc->counter
= $counter++
;
153 require_once( "SpecialRecentchanges.php" );
155 rcDoOutputFeed( $rchanges, $feed );
159 # Otherwise, carry on with regular output...
160 $wgOut->addHTML("< ".$sk->makeLinkObj($nt, "", "redirect=no" )."<br />\n");
161 $note = wfMsgExt( "rcnote", array ( 'parseinline' ), $limit, $days, $wgLang->timeAndDate( wfTimestampNow(), true ) );
162 $wgOut->addHTML( "<hr />\n{$note}\n<br />" );
164 $note = rcDayLimitlinks( $days, $limit, "Recentchangeslinked",
165 "target=" . $nt->getPrefixedURL() . "&hideminor={$hideminor}&showlinkedto={$showlinkedto}",
168 $wgOut->addHTML( $note."\n" );
170 $list = ChangesList
::newFromUser( $wgUser );
171 $s = $list->beginRecentChangesList();
176 if ( 0 == $count ) { break; }
177 $obj = $dbr->fetchObject( $res );
179 $rc = RecentChange
::newFromRow( $obj );
180 $rc->counter
= $counter++
;
181 $s .= $list->recentChangesLine( $rc , !empty( $obj->wl_user
) );
185 $wgOut->addWikiMsg('recentchangeslinked-noresult');
187 $s .= $list->endRecentChangesList();
189 $dbr->freeResult( $res );
190 $wgOut->addHTML( $s );