MediaWiki 1.44.0
SpecialUnwatchedPages.php
Go to the documentation of this file.
1<?php
23namespace MediaWiki\Specials;
24
33use stdClass;
38
46
47 private LinkBatchFactory $linkBatchFactory;
48 private ILanguageConverter $languageConverter;
49
50 public function __construct(
51 LinkBatchFactory $linkBatchFactory,
52 IConnectionProvider $dbProvider,
53 LanguageConverterFactory $languageConverterFactory
54 ) {
55 parent::__construct( 'Unwatchedpages', 'unwatchedpages' );
56 $this->linkBatchFactory = $linkBatchFactory;
57 $this->setDatabaseProvider( $dbProvider );
58 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
59 }
60
61 public function isExpensive() {
62 return true;
63 }
64
65 public function isSyndicated() {
66 return false;
67 }
68
75 public function preprocessResults( $db, $res ) {
76 if ( !$res->numRows() ) {
77 return;
78 }
79
80 $batch = $this->linkBatchFactory->newLinkBatch()->setCaller( __METHOD__ );
81 foreach ( $res as $row ) {
82 $batch->add( $row->namespace, $row->title );
83 }
84 $batch->execute();
85
86 $res->seek( 0 );
87 }
88
89 public function getQueryInfo() {
90 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
91 return [
92 'tables' => [ 'page', 'watchlist' ],
93 'fields' => [
94 'namespace' => 'page_namespace',
95 'title' => 'page_title',
96 'value' => 'page_namespace'
97 ],
98 'conds' => [
99 'wl_title' => null,
100 'page_is_redirect' => 0,
101 $dbr->expr( 'page_namespace', '!=', NS_MEDIAWIKI ),
102 ],
103 'join_conds' => [ 'watchlist' => [
104 'LEFT JOIN', [ 'wl_title = page_title',
105 'wl_namespace = page_namespace' ] ] ]
106 ];
107 }
108
109 protected function sortDescending() {
110 return false;
111 }
112
113 protected function getOrderFields() {
114 return [ 'page_namespace', 'page_title' ];
115 }
116
121 public function execute( $par ) {
122 parent::execute( $par );
123 $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
124 $this->addHelpLink( 'Help:Watchlist' );
125 }
126
132 public function formatResult( $skin, $result ) {
133 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
134 if ( !$nt ) {
135 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
136 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
137 }
138
139 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
140
141 $linkRenderer = $this->getLinkRenderer();
142
143 $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
144 $wlink = $linkRenderer->makeKnownLink(
145 $nt,
146 $this->msg( 'watch' )->text(),
147 [ 'class' => 'mw-watch-link' ],
148 [ 'action' => 'watch' ]
149 );
150
151 return $this->getLanguage()->specialList( $plink, $wlink );
152 }
153
154 protected function getGroupName() {
155 return 'maintenance';
156 }
157}
158
163class_alias( SpecialUnwatchedPages::class, 'SpecialUnwatchedPages' );
const NS_MEDIAWIKI
Definition Defines.php:73
This class is a collection of static functions that serve two purposes:
Definition Html.php:57
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:61
The base class for all skins.
Definition Skin.php:58
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:87
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
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:32
The shared interface for all language converters.
Provide primary and replica IDatabase connections.
Interface to a relational database.
Definition IDatabase.php:45
Result wrapper for grabbing data queried from an IDatabase object.
element(SerializerNode $parent, SerializerNode $node, $contents)