62 $this->mName =
'Recentchangeslinked';
68 $opts = parent::getDefaultOptions();
69 $opts->add(
'target',
'' );
70 $opts->add(
'showlinkedto',
false );
76 $opts[
'target'] = $par;
82 protected function doMainQuery( $tables, $select, $conds, $query_options,
85 $target = $opts[
'target'];
86 $showlinkedto = $opts[
'showlinkedto'];
87 $limit = $opts[
'limit'];
89 if ( $target ===
'' ) {
93 $title = Title::newFromText( $target );
96 Html::errorBox( $this->
msg(
'allpagesbadtitle' )->parse(),
'',
'mw-recentchangeslinked-errorbox' )
101 $outputPage->setPageTitle( $this->
msg(
'recentchangeslinked-title',
$title->getPrefixedText() ) );
112 $dbr = $this->loadBalancer->getConnectionRef( ILoadBalancer::DB_REPLICA,
'recentchangeslinked' );
113 $id =
$title->getArticleID();
114 $ns =
$title->getNamespace();
115 $dbkey =
$title->getDBkey();
117 $rcQuery = RecentChange::getQueryInfo();
118 $tables = array_merge( $rcQuery[
'tables'], $tables );
119 $select = array_merge( $rcQuery[
'fields'], $select );
120 $join_conds = array_merge( $rcQuery[
'joins'], $join_conds );
127 $join_conds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
128 $select[] =
'page_latest';
130 $tagFilter = $opts[
'tagfilter'] !==
'' ? explode(
'|', $opts[
'tagfilter'] ) : [];
140 if (
$dbr->unionSupportsOrderAndLimit() ) {
141 if ( count( $tagFilter ) > 1 ) {
146 'GROUP BY' => [
'rc_timestamp',
'rc_id' ],
147 'ORDER BY' => [
'rc_timestamp DESC',
'rc_id DESC' ]
150 $order = [
'ORDER BY' =>
'rc_timestamp DESC' ];
156 if ( !$this->
runMainQueryHook( $tables, $select, $conds, $query_options, $join_conds,
165 $link_tables = [
'categorylinks' ];
166 $showlinkedto =
true;
169 $link_tables = [
'pagelinks',
'templatelinks' ];
171 if ( $ns ===
NS_FILE || !$showlinkedto ) {
172 $link_tables[] =
'imagelinks';
176 if ( $id == 0 && !$showlinkedto ) {
183 'templatelinks' =>
'tl',
184 'categorylinks' =>
'cl',
190 foreach ( $link_tables as $link_table ) {
191 $pfx = $prefix[$link_table];
195 if ( $link_table ==
'imagelinks' ) {
197 } elseif ( $link_table ==
'categorylinks' ) {
203 if ( $showlinkedto ) {
206 if ( $ns != $link_ns ) {
209 $subconds = [
"{$pfx}_to" => $dbkey ];
211 $subconds = [
"{$pfx}_namespace" => $ns,
"{$pfx}_title" => $dbkey ];
213 $subjoin =
"rc_cur_id = {$pfx}_from";
216 $subconds = [
"{$pfx}_from" => $id ];
217 if ( $link_table ==
'imagelinks' || $link_table ==
'categorylinks' ) {
218 $subconds[
"rc_namespace"] = $link_ns;
219 $subjoin =
"rc_title = {$pfx}_to";
221 $subjoin = [
"rc_namespace = {$pfx}_namespace",
"rc_title = {$pfx}_title" ];
225 $query =
$dbr->selectSQLText(
226 array_merge( $tables, [ $link_table ] ),
230 $order + $query_options,
231 $join_conds + [ $link_table => [
'JOIN', $subjoin ] ]
234 if (
$dbr->unionSupportsOrderAndLimit() ) {
235 $query =
$dbr->limitResult( $query, $limit );
241 if ( count( $subsql ) == 0 ) {
244 if ( count( $subsql ) == 1 &&
$dbr->unionSupportsOrderAndLimit() ) {
248 $sql =
$dbr->unionQueries( $subsql, $dbr::UNION_DISTINCT ) .
249 ' ORDER BY rc_timestamp DESC';
250 $sql =
$dbr->limitResult( $sql, $limit,
false );
252 return $dbr->query( $sql, __METHOD__ );
258 $this->
getOutput()->addBacklinkSubtitle( $target );
259 $this->
getSkin()->setRelevantTitle( $target );
270 $extraOpts = parent::getExtraOptions( $opts );
272 $opts->consumeValues( [
'showlinkedto',
'target' ] );
274 $extraOpts[
'target'] = [ $this->
msg(
'recentchangeslinked-page' )->escaped(),
275 Xml::input(
'target', 40, str_replace(
'_',
' ', $opts[
'target'] ) ) .
276 Xml::check(
'showlinkedto', $opts[
'showlinkedto'], [
'id' =>
'showlinkedto' ] ) .
' ' .
277 Xml::label( $this->
msg(
'recentchangeslinked-to' )->text(),
'showlinkedto' ) ];
287 if ( $this->rclTargetTitle ===
null ) {
289 if ( isset( $opts[
'target'] ) && $opts[
'target'] !==
'' ) {
290 $this->rclTargetTitle = Title::newFromText( $opts[
'target'] );
292 $this->rclTargetTitle =
false;
308 return $this->
prefixSearchString( $search, $limit, $offset, $this->searchEngineFactory );
313 if ( $targetTitle ===
false ) {
317 [
'class' =>
'mw-changeslist-empty mw-changeslist-notargetpage' ],
318 $this->
msg(
'recentchanges-notargetpage' )->parse()
321 } elseif ( !$targetTitle || $targetTitle->isExternal() ) {
325 [
'class' =>
'mw-changeslist-empty mw-changeslist-invalidtargetpage' ],
326 $this->
msg(
'allpagesbadtitle' )->parse()
330 parent::outputNoResults();
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
getOptions()
Get the current FormOptions for this request.
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
Factory class for SearchEngine.
getOutput()
Get the OutputPage being used for this instance.
getSkin()
Shortcut to get the skin being used for this instance.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
prefixSearchString( $search, $limit, $offset, SearchEngineFactory $searchEngineFactory=null)
Perform a regular substring search for prefixSearchSubpages.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
This is to display changes made to all articles linked in an article.
setTopText(FormOptions $opts)
Send the text to be displayed above the options.
doMainQuery( $tables, $select, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.bool|IResultWrapper Result or false
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
getDefaultOptions()
Get a FormOptions object containing the default options.
bool Title $rclTargetTitle
ILoadBalancer $loadBalancer
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
outputNoResults()
Add the "no results" message to the output.
__construct(WatchedItemStoreInterface $watchedItemStore, MessageCache $messageCache, ILoadBalancer $loadBalancer, UserOptionsLookup $userOptionsLookup, SearchEngineFactory $searchEngineFactory)
getExtraOptions( $opts)
Get options to be displayed in a form.
SearchEngineFactory $searchEngineFactory
A special page that lists last changes made to the wiki.
addWatchlistJoins(IDatabase $dbr, &$tables, &$fields, &$joinConds, &$conds)
Add required values to a query's $tables, $fields, $joinConds, and $conds arrays to join to the watch...
UserOptionsLookup $userOptionsLookup
MessageCache $messageCache
WatchedItemStoreInterface $watchedItemStore
Represents a title within MediaWiki.