Go to the documentation of this file.
66 $this->mName =
'Recentchangeslinked';
72 $opts = parent::getDefaultOptions();
73 $opts->add(
'target',
'' );
74 $opts->add(
'showlinkedto',
false );
80 $opts[
'target'] = $par;
86 protected function doMainQuery( $tables, $select, $conds, $query_options,
89 $target = $opts[
'target'];
90 $showlinkedto = $opts[
'showlinkedto'];
91 $limit = $opts[
'limit'];
93 if ( $target ===
'' ) {
105 $outputPage->setPageTitle( $this->
msg(
'recentchangeslinked-title',
$title->getPrefixedText() ) );
117 $id =
$title->getArticleID();
118 $ns =
$title->getNamespace();
119 $dbkey =
$title->getDBkey();
122 $tables = array_merge( $tables, $rcQuery[
'tables'] );
123 $select = array_merge( $rcQuery[
'fields'], $select );
124 $join_conds = array_merge( $join_conds, $rcQuery[
'joins'] );
131 $join_conds[
'page'] = [
'LEFT JOIN',
'rc_cur_id=page_id' ];
132 $select[] =
'page_latest';
134 $tagFilter = $opts[
'tagfilter'] ? explode(
'|', $opts[
'tagfilter'] ) : [];
144 if (
$dbr->unionSupportsOrderAndLimit() ) {
145 if ( count( $tagFilter ) > 1 ) {
150 'GROUP BY' => [
'rc_timestamp',
'rc_id' ],
151 'ORDER BY' => [
'rc_timestamp DESC',
'rc_id DESC' ]
154 $order = [
'ORDER BY' =>
'rc_timestamp DESC' ];
160 if ( !$this->
runMainQueryHook( $tables, $select, $conds, $query_options, $join_conds,
169 $link_tables = [
'categorylinks' ];
170 $showlinkedto =
true;
173 $link_tables = [
'pagelinks',
'templatelinks' ];
175 if ( $ns ===
NS_FILE || !$showlinkedto ) {
176 $link_tables[] =
'imagelinks';
180 if ( $id == 0 && !$showlinkedto ) {
187 'templatelinks' =>
'tl',
188 'categorylinks' =>
'cl',
194 foreach ( $link_tables as $link_table ) {
195 $pfx = $prefix[$link_table];
199 if ( $link_table ==
'imagelinks' ) {
201 } elseif ( $link_table ==
'categorylinks' ) {
207 if ( $showlinkedto ) {
210 if ( $ns != $link_ns ) {
213 $subconds = [
"{$pfx}_to" => $dbkey ];
215 $subconds = [
"{$pfx}_namespace" => $ns,
"{$pfx}_title" => $dbkey ];
217 $subjoin =
"rc_cur_id = {$pfx}_from";
220 $subconds = [
"{$pfx}_from" => $id ];
221 if ( $link_table ==
'imagelinks' || $link_table ==
'categorylinks' ) {
222 $subconds[
"rc_namespace"] = $link_ns;
223 $subjoin =
"rc_title = {$pfx}_to";
225 $subjoin = [
"rc_namespace = {$pfx}_namespace",
"rc_title = {$pfx}_title" ];
229 $query =
$dbr->selectSQLText(
230 array_merge( $tables, [ $link_table ] ),
234 $order + $query_options,
235 $join_conds + [ $link_table => [
'JOIN', $subjoin ] ]
238 if (
$dbr->unionSupportsOrderAndLimit() ) {
239 $query =
$dbr->limitResult( $query, $limit );
245 if ( count( $subsql ) == 0 ) {
248 if ( count( $subsql ) == 1 &&
$dbr->unionSupportsOrderAndLimit() ) {
252 $sql =
$dbr->unionQueries( $subsql, $dbr::UNION_DISTINCT ) .
253 ' ORDER BY rc_timestamp DESC';
254 $sql =
$dbr->limitResult( $sql, $limit,
false );
257 return $dbr->query( $sql, __METHOD__ );
263 $this->
getOutput()->addBacklinkSubtitle( $target );
264 $this->
getSkin()->setRelevantTitle( $target );
275 $extraOpts = parent::getExtraOptions( $opts );
277 $opts->consumeValues( [
'showlinkedto',
'target' ] );
279 $extraOpts[
'target'] = [ $this->
msg(
'recentchangeslinked-page' )->escaped(),
280 Xml::input(
'target', 40, str_replace(
'_',
' ', $opts[
'target'] ) ) .
281 Xml::check(
'showlinkedto', $opts[
'showlinkedto'], [
'id' =>
'showlinkedto' ] ) .
' ' .
282 Xml::label( $this->
msg(
'recentchangeslinked-to' )->text(),
'showlinkedto' ) ];
292 if ( $this->rclTargetTitle ===
null ) {
294 if ( isset( $opts[
'target'] ) && $opts[
'target'] !==
'' ) {
297 $this->rclTargetTitle =
false;
313 return $this->
prefixSearchString( $search, $limit, $offset, $this->searchEngineFactory );
318 if ( $targetTitle ===
false ) {
322 [
'class' =>
'mw-changeslist-empty mw-changeslist-notargetpage' ],
323 $this->
msg(
'recentchanges-notargetpage' )->parse()
326 } elseif ( !$targetTitle || $targetTitle->isExternal() ) {
330 [
'class' =>
'mw-changeslist-empty mw-changeslist-invalidtargetpage' ],
331 $this->
msg(
'allpagesbadtitle' )->parse()
335 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.
UserOptionsLookup $userOptionsLookup
setTopText(FormOptions $opts)
Send the text to be displayed above the options.
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...
Factory class for SearchEngine.
getSkin()
Shortcut to get the skin being used for this instance.
SearchEngineFactory $searchEngineFactory
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.
runMainQueryHook(&$tables, &$fields, &$conds, &$query_options, &$join_conds, $opts)
static check( $name, $checked=false, $attribs=[])
Convenience function to build an HTML checkbox.
static errorBox( $html, $heading='', $className='')
Return an error box.
prefixSearchSubpages( $search, $limit, $offset)
Return an array of subpages beginning with $search that this special page will accept.
__construct(PermissionManager $permissionManager, WatchedItemStoreInterface $watchedItemStore, MessageCache $messageCache, ILoadBalancer $loadBalancer, UserOptionsLookup $userOptionsLookup, SearchEngineFactory $searchEngineFactory)
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...
WatchedItemStoreInterface $watchedItemStore
A special page that lists last changes made to the wiki.
MessageCache $messageCache
PermissionManager $permissionManager
Represents a title within MediaWiki.
getDefaultOptions()
Get a FormOptions object containing the default options.
static rawElement( $element, $attribs=[], $contents='')
Returns an HTML element in a string.
static input( $name, $size=false, $value=false, $attribs=[])
Convenience function to build an HTML text input field.
bool Title $rclTargetTitle
Cache of messages that are defined by MediaWiki namespace pages or by hooks.
getOptions()
Get the current FormOptions for this request.
ILoadBalancer $loadBalancer