MediaWiki master
SpecialUnwatchedPages.php
Go to the documentation of this file.
1<?php
27namespace MediaWiki\Specials;
28
29use HtmlArmor;
37use Skin;
38use stdClass;
42
49
50 private LinkBatchFactory $linkBatchFactory;
51 private ILanguageConverter $languageConverter;
52
58 public function __construct(
59 LinkBatchFactory $linkBatchFactory,
60 IConnectionProvider $dbProvider,
61 LanguageConverterFactory $languageConverterFactory
62 ) {
63 parent::__construct( 'Unwatchedpages', 'unwatchedpages' );
64 $this->linkBatchFactory = $linkBatchFactory;
65 $this->setDatabaseProvider( $dbProvider );
66 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
67 }
68
69 public function isExpensive() {
70 return true;
71 }
72
73 public function isSyndicated() {
74 return false;
75 }
76
83 public function preprocessResults( $db, $res ) {
84 if ( !$res->numRows() ) {
85 return;
86 }
87
88 $batch = $this->linkBatchFactory->newLinkBatch();
89 foreach ( $res as $row ) {
90 $batch->add( $row->namespace, $row->title );
91 }
92 $batch->execute();
93
94 $res->seek( 0 );
95 }
96
97 public function getQueryInfo() {
98 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
99 return [
100 'tables' => [ 'page', 'watchlist' ],
101 'fields' => [
102 'namespace' => 'page_namespace',
103 'title' => 'page_title',
104 'value' => 'page_namespace'
105 ],
106 'conds' => [
107 'wl_title' => null,
108 'page_is_redirect' => 0,
109 $dbr->expr( 'page_namespace', '!=', NS_MEDIAWIKI ),
110 ],
111 'join_conds' => [ 'watchlist' => [
112 'LEFT JOIN', [ 'wl_title = page_title',
113 'wl_namespace = page_namespace' ] ] ]
114 ];
115 }
116
117 protected function sortDescending() {
118 return false;
119 }
120
121 protected function getOrderFields() {
122 return [ 'page_namespace', 'page_title' ];
123 }
124
129 public function execute( $par ) {
130 parent::execute( $par );
131 $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
132 $this->addHelpLink( 'Help:Watchlist' );
133 }
134
140 public function formatResult( $skin, $result ) {
141 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
142 if ( !$nt ) {
143 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
144 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
145 }
146
147 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
148
149 $linkRenderer = $this->getLinkRenderer();
150
151 $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
152 $wlink = $linkRenderer->makeKnownLink(
153 $nt,
154 $this->msg( 'watch' )->text(),
155 [ 'class' => 'mw-watch-link' ],
156 [ 'action' => 'watch' ]
157 );
158
159 return $this->getLanguage()->specialList( $plink, $wlink );
160 }
161
162 protected function getGroupName() {
163 return 'maintenance';
164 }
165}
166
171class_alias( SpecialUnwatchedPages::class, 'SpecialUnwatchedPages' );
const NS_MEDIAWIKI
Definition Defines.php:72
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
This class is a collection of static functions that serve two purposes:
Definition Html.php:56
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Some internal bits split of from Skin.php.
Definition Linker.php:65
This is a class for doing query pages; since they're almost all the same, we factor out some of the f...
Definition QueryPage.php:88
setDatabaseProvider(IConnectionProvider $databaseProvider)
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getOutput()
Get the OutputPage being used for this instance.
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
A special page that displays a list of pages that are not on anyone's watchlist.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
isExpensive()
Should this query page only be updated offline on large wikis?
sortDescending()
Override to sort by increasing values.
getOrderFields()
Subclasses return an array of fields to order by here.
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
__construct(LinkBatchFactory $linkBatchFactory, IConnectionProvider $dbProvider, LanguageConverterFactory $languageConverterFactory)
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Represents a title within MediaWiki.
Definition Title.php:78
The base class for all skins.
Definition Skin.php:58
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:36
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)
This program is free software; you can redistribute it and/or modify it under the terms of the GNU Ge...