Go to the documentation of this file.
36 parent::__construct(
'Recentchangeslinked' );
40 $opts = parent::getDefaultOptions();
41 $opts->add(
'target',
'' );
42 $opts->add(
'showlinkedto',
false );
48 $opts[
'target'] = $par;
54 protected function doMainQuery( $tables, $select, $conds, $query_options,
57 $target = $opts[
'target'];
58 $showlinkedto = $opts[
'showlinkedto'];
59 $limit = $opts[
'limit'];
61 if ( $target ===
'' ) {
68 Html::errorBox( $this->
msg(
'allpagesbadtitle' )->parse() )
73 $outputPage->setPageTitle( $this->
msg(
'recentchangeslinked-title',
$title->getPrefixedText() ) );
85 $id =
$title->getArticleID();
86 $ns =
$title->getNamespace();
87 $dbkey =
$title->getDBkey();
90 $tables = array_merge( $tables, $rcQuery[
'tables'] );
91 $select = array_merge( $rcQuery[
'fields'], $select );
92 $join_conds = array_merge( $join_conds, $rcQuery[
'joins'] );
95 $uid = $this->
getUser()->getId();
96 if ( $uid && MediaWikiServices::getInstance()
98 ->userHasRight( $this->
getUser(),
'viewmywatchlist' )
100 $tables[] =
'watchlist';
101 $select[] =
'wl_user';
102 $join_conds[
'watchlist'] = [
'LEFT JOIN', [
105 'wl_namespace=rc_namespace'
111 $join_conds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
112 $select[] =
'page_latest';
114 $tagFilter = $opts[
'tagfilter'] ? explode(
'|', $opts[
'tagfilter'] ) : [];
124 if (
$dbr->unionSupportsOrderAndLimit() ) {
125 if ( count( $tagFilter ) > 1 ) {
130 'GROUP BY' =>
'rc_timestamp, rc_id',
131 'ORDER BY' =>
'rc_timestamp DESC, rc_id DESC'
134 $order = [
'ORDER BY' =>
'rc_timestamp DESC' ];
140 if ( !$this->
runMainQueryHook( $tables, $select, $conds, $query_options, $join_conds,
149 $link_tables = [
'categorylinks' ];
150 $showlinkedto =
true;
153 $link_tables = [
'pagelinks',
'templatelinks' ];
155 if ( $ns ==
NS_FILE || !$showlinkedto ) {
156 $link_tables[] =
'imagelinks';
160 if ( $id == 0 && !$showlinkedto ) {
167 'templatelinks' =>
'tl',
168 'categorylinks' =>
'cl',
174 foreach ( $link_tables as $link_table ) {
175 $pfx = $prefix[$link_table];
179 if ( $link_table ==
'imagelinks' ) {
181 } elseif ( $link_table ==
'categorylinks' ) {
187 if ( $showlinkedto ) {
190 if ( $ns != $link_ns ) {
193 $subconds = [
"{$pfx}_to" => $dbkey ];
195 $subconds = [
"{$pfx}_namespace" => $ns,
"{$pfx}_title" => $dbkey ];
197 $subjoin =
"rc_cur_id = {$pfx}_from";
200 $subconds = [
"{$pfx}_from" => $id ];
201 if ( $link_table ==
'imagelinks' || $link_table ==
'categorylinks' ) {
202 $subconds[
"rc_namespace"] = $link_ns;
203 $subjoin =
"rc_title = {$pfx}_to";
205 $subjoin = [
"rc_namespace = {$pfx}_namespace",
"rc_title = {$pfx}_title" ];
209 $query =
$dbr->selectSQLText(
210 array_merge( $tables, [ $link_table ] ),
214 $order + $query_options,
215 $join_conds + [ $link_table => [
'JOIN', $subjoin ] ]
218 if (
$dbr->unionSupportsOrderAndLimit() ) {
219 $query =
$dbr->limitResult( $query, $limit );
225 if ( count( $subsql ) == 0 ) {
228 if ( count( $subsql ) == 1 &&
$dbr->unionSupportsOrderAndLimit() ) {
232 $sql =
$dbr->unionQueries( $subsql, $dbr::UNION_DISTINCT ) .
233 ' ORDER BY rc_timestamp DESC';
234 $sql =
$dbr->limitResult( $sql, $limit,
false );
237 return $dbr->query( $sql, __METHOD__ );
243 $this->
getOutput()->addBacklinkSubtitle( $target );
244 $this->
getSkin()->setRelevantTitle( $target );
255 $extraOpts = parent::getExtraOptions( $opts );
257 $opts->consumeValues( [
'showlinkedto',
'target' ] );
259 $extraOpts[
'target'] = [ $this->
msg(
'recentchangeslinked-page' )->escaped(),
260 Xml::input(
'target', 40, str_replace(
'_',
' ', $opts[
'target'] ) ) .
261 Xml::check(
'showlinkedto', $opts[
'showlinkedto'], [
'id' =>
'showlinkedto' ] ) .
' ' .
262 Xml::label( $this->
msg(
'recentchangeslinked-to' )->text(),
'showlinkedto' ) ];
272 if ( $this->rclTargetTitle ===
null ) {
274 if ( isset( $opts[
'target'] ) && $opts[
'target'] !==
'' ) {
277 $this->rclTargetTitle =
false;
298 if ( $targetTitle ===
false ) {
302 [
'class' =>
'mw-changeslist-empty mw-changeslist-notargetpage' ],
303 $this->
msg(
'recentchanges-notargetpage' )->parse()
306 } elseif ( !$targetTitle || $targetTitle->isExternal() ) {
310 [
'class' =>
'mw-changeslist-empty mw-changeslist-invalidtargetpage' ],
311 $this->
msg(
'allpagesbadtitle' )->parse()
315 parent::outputNoResults();
getExtraOptions( $opts)
Get options to be displayed in a form.
static getQueryInfo()
Return the tables, fields, and join conditions to be selected to create a new recentchanges object.
outputNoResults()
Add the "no results" message to the output.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
static newFromText( $text, $defaultNamespace=NS_MAIN)
Create a new Title from text, such as what one would find in a link.
parseParameters( $par, FormOptions $opts)
Process $par and put options found in $opts.
getOutput()
Get the OutputPage being used for this instance.
This is to display changes made to all articles linked in an article.
static label( $label, $id, $attribs=[])
Convenience function to build an HTML form label.
setTopText(FormOptions $opts)
Send the text to be displayed above the options.
getSkin()
Shortcut to get the skin being used for this instance.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
prefixSearchString( $search, $limit, $offset)
Perform a regular substring search for prefixSearchSubpages.
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
getUser()
Shortcut to get the User executing this instance.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
doMainQuery( $tables, $select, $conds, $query_options, $join_conds, FormOptions $opts)
Process the query.Array of tables; see IDatabase::select $table Array of fields; see IDatabase::selec...
A special page that lists last changes made to the wiki.
Represents a title within MediaWiki.
getDefaultOptions()
Get a FormOptions object containing the default options.
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
bool Title $rclTargetTitle
getOptions()
Get the current FormOptions for this request.