34 parent::__construct(
'Recentchangeslinked' );
38 $opts = parent::getDefaultOptions();
39 $opts->add(
'target',
'' );
40 $opts->add(
'showlinkedto',
false );
46 $opts[
'target'] = $par;
52 protected function doMainQuery( $tables, $select, $conds, $query_options,
55 $target = $opts[
'target'];
56 $showlinkedto = $opts[
'showlinkedto'];
57 $limit = $opts[
'limit'];
59 if ( $target ===
'' ) {
63 $title = Title::newFromText( $target );
66 Html::errorBox( $this->
msg(
'allpagesbadtitle' )->parse() )
71 $outputPage->setPageTitle( $this->
msg(
'recentchangeslinked-title',
$title->getPrefixedText() ) );
83 $id =
$title->getArticleID();
84 $ns =
$title->getNamespace();
85 $dbkey =
$title->getDBkey();
87 $rcQuery = RecentChange::getQueryInfo();
88 $tables = array_merge( $tables, $rcQuery[
'tables'] );
89 $select = array_merge( $rcQuery[
'fields'], $select );
90 $join_conds = array_merge( $join_conds, $rcQuery[
'joins'] );
97 $join_conds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
98 $select[] =
'page_latest';
100 $tagFilter = $opts[
'tagfilter'] !==
'' ? explode(
'|', $opts[
'tagfilter'] ) : [];
110 if (
$dbr->unionSupportsOrderAndLimit() ) {
111 if ( count( $tagFilter ) > 1 ) {
116 'GROUP BY' => [
'rc_timestamp',
'rc_id' ],
117 'ORDER BY' => [
'rc_timestamp DESC',
'rc_id DESC' ]
120 $order = [
'ORDER BY' =>
'rc_timestamp DESC' ];
126 if ( !$this->
runMainQueryHook( $tables, $select, $conds, $query_options, $join_conds,
135 $link_tables = [
'categorylinks' ];
136 $showlinkedto =
true;
139 $link_tables = [
'pagelinks',
'templatelinks' ];
141 if ( $ns ==
NS_FILE || !$showlinkedto ) {
142 $link_tables[] =
'imagelinks';
146 if ( $id == 0 && !$showlinkedto ) {
153 'templatelinks' =>
'tl',
154 'categorylinks' =>
'cl',
160 foreach ( $link_tables as $link_table ) {
161 $pfx = $prefix[$link_table];
165 if ( $link_table ==
'imagelinks' ) {
167 } elseif ( $link_table ==
'categorylinks' ) {
173 if ( $showlinkedto ) {
176 if ( $ns != $link_ns ) {
179 $subconds = [
"{$pfx}_to" => $dbkey ];
181 $subconds = [
"{$pfx}_namespace" => $ns,
"{$pfx}_title" => $dbkey ];
183 $subjoin =
"rc_cur_id = {$pfx}_from";
186 $subconds = [
"{$pfx}_from" => $id ];
187 if ( $link_table ==
'imagelinks' || $link_table ==
'categorylinks' ) {
188 $subconds[
"rc_namespace"] = $link_ns;
189 $subjoin =
"rc_title = {$pfx}_to";
191 $subjoin = [
"rc_namespace = {$pfx}_namespace",
"rc_title = {$pfx}_title" ];
195 $query =
$dbr->selectSQLText(
196 array_merge( $tables, [ $link_table ] ),
200 $order + $query_options,
201 $join_conds + [ $link_table => [
'JOIN', $subjoin ] ]
204 if (
$dbr->unionSupportsOrderAndLimit() ) {
205 $query =
$dbr->limitResult( $query, $limit );
211 if ( count( $subsql ) == 0 ) {
214 if ( count( $subsql ) == 1 &&
$dbr->unionSupportsOrderAndLimit() ) {
218 $sql =
$dbr->unionQueries( $subsql, $dbr::UNION_DISTINCT ) .
219 ' ORDER BY rc_timestamp DESC';
220 $sql =
$dbr->limitResult( $sql, $limit,
false );
222 return $dbr->query( $sql, __METHOD__ );
228 $this->
getOutput()->addBacklinkSubtitle( $target );
229 $this->
getSkin()->setRelevantTitle( $target );
240 $extraOpts = parent::getExtraOptions( $opts );
242 $opts->consumeValues( [
'showlinkedto',
'target' ] );
244 $extraOpts[
'target'] = [ $this->
msg(
'recentchangeslinked-page' )->escaped(),
245 Xml::input(
'target', 40, str_replace(
'_',
' ', $opts[
'target'] ) ) .
246 Xml::check(
'showlinkedto', $opts[
'showlinkedto'], [
'id' =>
'showlinkedto' ] ) .
' ' .
247 Xml::label( $this->
msg(
'recentchangeslinked-to' )->text(),
'showlinkedto' ) ];
257 if ( $this->rclTargetTitle ===
null ) {
259 if ( isset( $opts[
'target'] ) && $opts[
'target'] !==
'' ) {
260 $this->rclTargetTitle = Title::newFromText( $opts[
'target'] );
262 $this->rclTargetTitle =
false;
283 if ( $targetTitle ===
false ) {
287 [
'class' =>
'mw-changeslist-empty mw-changeslist-notargetpage' ],
288 $this->
msg(
'recentchanges-notargetpage' )->parse()
291 } elseif ( !$targetTitle || $targetTitle->isExternal() ) {
295 [
'class' =>
'mw-changeslist-empty mw-changeslist-invalidtargetpage' ],
296 $this->
msg(
'allpagesbadtitle' )->parse()
300 parent::outputNoResults();
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
getOptions()
Get the current FormOptions for this request.
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.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
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
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.
getExtraOptions( $opts)
Get options to be displayed in a form.
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...
Represents a title within MediaWiki.