MediaWiki master
SpecialUnwatchedPages.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Specials;
24
25use HtmlArmor;
33use Skin;
34use stdClass;
38
46
47 private LinkBatchFactory $linkBatchFactory;
48 private ILanguageConverter $languageConverter;
49
55 public function __construct(
56 LinkBatchFactory $linkBatchFactory,
57 IConnectionProvider $dbProvider,
58 LanguageConverterFactory $languageConverterFactory
59 ) {
60 parent::__construct( 'Unwatchedpages', 'unwatchedpages' );
61 $this->linkBatchFactory = $linkBatchFactory;
62 $this->setDatabaseProvider( $dbProvider );
63 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
64 }
65
66 public function isExpensive() {
67 return true;
68 }
69
70 public function isSyndicated() {
71 return false;
72 }
73
80 public function preprocessResults( $db, $res ) {
81 if ( !$res->numRows() ) {
82 return;
83 }
84
85 $batch = $this->linkBatchFactory->newLinkBatch();
86 foreach ( $res as $row ) {
87 $batch->add( $row->namespace, $row->title );
88 }
89 $batch->execute();
90
91 $res->seek( 0 );
92 }
93
94 public function getQueryInfo() {
95 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
96 return [
97 'tables' => [ 'page', 'watchlist' ],
98 'fields' => [
99 'namespace' => 'page_namespace',
100 'title' => 'page_title',
101 'value' => 'page_namespace'
102 ],
103 'conds' => [
104 'wl_title' => null,
105 'page_is_redirect' => 0,
106 $dbr->expr( 'page_namespace', '!=', NS_MEDIAWIKI ),
107 ],
108 'join_conds' => [ 'watchlist' => [
109 'LEFT JOIN', [ 'wl_title = page_title',
110 'wl_namespace = page_namespace' ] ] ]
111 ];
112 }
113
114 protected function sortDescending() {
115 return false;
116 }
117
118 protected function getOrderFields() {
119 return [ 'page_namespace', 'page_title' ];
120 }
121
126 public function execute( $par ) {
127 parent::execute( $par );
128 $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
129 $this->addHelpLink( 'Help:Watchlist' );
130 }
131
137 public function formatResult( $skin, $result ) {
138 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
139 if ( !$nt ) {
140 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
141 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
142 }
143
144 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
145
146 $linkRenderer = $this->getLinkRenderer();
147
148 $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
149 $wlink = $linkRenderer->makeKnownLink(
150 $nt,
151 $this->msg( 'watch' )->text(),
152 [ 'class' => 'mw-watch-link' ],
153 [ 'action' => 'watch' ]
154 );
155
156 return $this->getLanguage()->specialList( $plink, $wlink );
157 }
158
159 protected function getGroupName() {
160 return 'maintenance';
161 }
162}
163
168class_alias( SpecialUnwatchedPages::class, 'SpecialUnwatchedPages' );
const NS_MEDIAWIKI
Definition Defines.php:73
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:63
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:89
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.
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:59
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)