MediaWiki master
SpecialUnwatchedPages.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Specials;
10
19use stdClass;
24
32
33 private readonly ILanguageConverter $languageConverter;
34
35 public function __construct(
36 private readonly LinkBatchFactory $linkBatchFactory,
37 IConnectionProvider $dbProvider,
38 LanguageConverterFactory $languageConverterFactory
39 ) {
40 parent::__construct( 'Unwatchedpages', 'unwatchedpages' );
41 $this->setDatabaseProvider( $dbProvider );
42 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
43 }
44
46 public function isExpensive() {
47 return true;
48 }
49
51 public function isSyndicated() {
52 return false;
53 }
54
61 public function preprocessResults( $db, $res ) {
62 if ( !$res->numRows() ) {
63 return;
64 }
65
66 $batch = $this->linkBatchFactory->newLinkBatch()->setCaller( __METHOD__ );
67 foreach ( $res as $row ) {
68 $batch->add( $row->namespace, $row->title );
69 }
70 $batch->execute();
71
72 $res->seek( 0 );
73 }
74
76 public function getQueryInfo() {
77 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
78 return [
79 'tables' => [ 'page', 'watchlist' ],
80 'fields' => [
81 'namespace' => 'page_namespace',
82 'title' => 'page_title',
83 'value' => 'page_namespace'
84 ],
85 'conds' => [
86 'wl_title' => null,
87 'page_is_redirect' => 0,
88 $dbr->expr( 'page_namespace', '!=', NS_MEDIAWIKI ),
89 ],
90 'join_conds' => [ 'watchlist' => [
91 'LEFT JOIN', [ 'wl_title = page_title',
92 'wl_namespace = page_namespace' ] ] ]
93 ];
94 }
95
97 protected function sortDescending() {
98 return false;
99 }
100
102 protected function getOrderFields() {
103 return [ 'page_namespace', 'page_title' ];
104 }
105
110 public function execute( $par ) {
111 parent::execute( $par );
112 $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
113 $this->addHelpLink( 'Help:Watchlist' );
114 }
115
121 public function formatResult( $skin, $result ) {
122 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
123 if ( !$nt ) {
124 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
125 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
126 }
127
128 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
129
130 $linkRenderer = $this->getLinkRenderer();
131
132 $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
133 $wlink = $linkRenderer->makeKnownLink(
134 $nt,
135 $this->msg( 'watch' )->text(),
136 [ 'class' => 'mw-watch-link' ],
137 [ 'action' => 'watch' ]
138 );
139
140 return $this->getLanguage()->specialList( $plink, $wlink );
141 }
142
144 protected function getGroupName() {
145 return 'maintenance';
146 }
147}
148
153class_alias( SpecialUnwatchedPages::class, 'SpecialUnwatchedPages' );
const NS_MEDIAWIKI
Definition Defines.php:59
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
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:47
Factory for LinkBatch objects to batch query page metadata.
The base class for all skins.
Definition Skin.php:52
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:77
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?If the query for this page is considere...
sortDescending()
Override to sort by increasing values.to override bool
__construct(private readonly LinkBatchFactory $linkBatchFactory, IConnectionProvider $dbProvider, LanguageConverterFactory $languageConverterFactory)
getOrderFields()
Subclasses return an array of fields to order by here.Don't append DESC to the field names,...
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
Represents a title within MediaWiki.
Definition Title.php:69
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
A database connection without write operations.
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)