MediaWiki master
SpecialUnwatchedPages.php
Go to the documentation of this file.
1<?php
9namespace MediaWiki\Specials;
10
11use MediaWiki\Cache\LinkBatchFactory;
14use MediaWiki\Languages\LanguageConverterFactory;
19use stdClass;
24
32
33 private LinkBatchFactory $linkBatchFactory;
34 private ILanguageConverter $languageConverter;
35
36 public function __construct(
37 LinkBatchFactory $linkBatchFactory,
38 IConnectionProvider $dbProvider,
39 LanguageConverterFactory $languageConverterFactory
40 ) {
41 parent::__construct( 'Unwatchedpages', 'unwatchedpages' );
42 $this->linkBatchFactory = $linkBatchFactory;
43 $this->setDatabaseProvider( $dbProvider );
44 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
45 }
46
48 public function isExpensive() {
49 return true;
50 }
51
53 public function isSyndicated() {
54 return false;
55 }
56
63 public function preprocessResults( $db, $res ) {
64 if ( !$res->numRows() ) {
65 return;
66 }
67
68 $batch = $this->linkBatchFactory->newLinkBatch()->setCaller( __METHOD__ );
69 foreach ( $res as $row ) {
70 $batch->add( $row->namespace, $row->title );
71 }
72 $batch->execute();
73
74 $res->seek( 0 );
75 }
76
78 public function getQueryInfo() {
79 $dbr = $this->getDatabaseProvider()->getReplicaDatabase();
80 return [
81 'tables' => [ 'page', 'watchlist' ],
82 'fields' => [
83 'namespace' => 'page_namespace',
84 'title' => 'page_title',
85 'value' => 'page_namespace'
86 ],
87 'conds' => [
88 'wl_title' => null,
89 'page_is_redirect' => 0,
90 $dbr->expr( 'page_namespace', '!=', NS_MEDIAWIKI ),
91 ],
92 'join_conds' => [ 'watchlist' => [
93 'LEFT JOIN', [ 'wl_title = page_title',
94 'wl_namespace = page_namespace' ] ] ]
95 ];
96 }
97
99 protected function sortDescending() {
100 return false;
101 }
102
104 protected function getOrderFields() {
105 return [ 'page_namespace', 'page_title' ];
106 }
107
112 public function execute( $par ) {
113 parent::execute( $par );
114 $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
115 $this->addHelpLink( 'Help:Watchlist' );
116 }
117
123 public function formatResult( $skin, $result ) {
124 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
125 if ( !$nt ) {
126 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
127 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
128 }
129
130 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
131
132 $linkRenderer = $this->getLinkRenderer();
133
134 $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
135 $wlink = $linkRenderer->makeKnownLink(
136 $nt,
137 $this->msg( 'watch' )->text(),
138 [ 'class' => 'mw-watch-link' ],
139 [ 'action' => 'watch' ]
140 );
141
142 return $this->getLanguage()->specialList( $plink, $wlink );
143 }
144
146 protected function getGroupName() {
147 return 'maintenance';
148 }
149}
150
155class_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
Some internal bits split of from Skin.php.
Definition Linker.php:47
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
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.
__construct(LinkBatchFactory $linkBatchFactory, IConnectionProvider $dbProvider, LanguageConverterFactory $languageConverterFactory)
isSyndicated()
Sometimes we don't want to build rss / atom feeds.to override bool
Represents a title within MediaWiki.
Definition Title.php:70
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)