MediaWiki REL1_39
SpecialUnwatchedPages.php
Go to the documentation of this file.
1<?php
32
39
41 private $linkBatchFactory;
42
44 private $languageConverter;
45
51 public function __construct(
52 LinkBatchFactory $linkBatchFactory,
53 ILoadBalancer $loadBalancer,
54 LanguageConverterFactory $languageConverterFactory
55 ) {
56 parent::__construct( 'Unwatchedpages', 'unwatchedpages' );
57 $this->linkBatchFactory = $linkBatchFactory;
58 $this->setDBLoadBalancer( $loadBalancer );
59 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
60 }
61
62 public function isExpensive() {
63 return true;
64 }
65
66 public function isSyndicated() {
67 return false;
68 }
69
76 public function preprocessResults( $db, $res ) {
77 if ( !$res->numRows() ) {
78 return;
79 }
80
81 $batch = $this->linkBatchFactory->newLinkBatch();
82 foreach ( $res as $row ) {
83 $batch->add( $row->namespace, $row->title );
84 }
85 $batch->execute();
86
87 $res->seek( 0 );
88 }
89
90 public function getQueryInfo() {
91 $dbr = $this->getDBLoadBalancer()->getConnectionRef( ILoadBalancer::DB_REPLICA );
92 return [
93 'tables' => [ 'page', 'watchlist' ],
94 'fields' => [
95 'namespace' => 'page_namespace',
96 'title' => 'page_title',
97 'value' => 'page_namespace'
98 ],
99 'conds' => [
100 'wl_title IS NULL',
101 'page_is_redirect' => 0,
102 'page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
103 ],
104 'join_conds' => [ 'watchlist' => [
105 'LEFT JOIN', [ 'wl_title = page_title',
106 'wl_namespace = page_namespace' ] ] ]
107 ];
108 }
109
110 protected function sortDescending() {
111 return false;
112 }
113
114 protected function getOrderFields() {
115 return [ 'page_namespace', 'page_title' ];
116 }
117
122 public function execute( $par ) {
123 parent::execute( $par );
124 $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
125 $this->addHelpLink( 'Help:Watchlist' );
126 }
127
133 public function formatResult( $skin, $result ) {
134 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
135 if ( !$nt ) {
136 return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
137 Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
138 }
139
140 $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
141
142 $linkRenderer = $this->getLinkRenderer();
143
144 $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
145 $wlink = $linkRenderer->makeKnownLink(
146 $nt,
147 $this->msg( 'watch' )->text(),
148 [ 'class' => 'mw-watch-link' ],
149 [ 'action' => 'watch' ]
150 );
151
152 return $this->getLanguage()->specialList( $plink, $wlink );
153 }
154
155 protected function getGroupName() {
156 return 'maintenance';
157 }
158}
const NS_MEDIAWIKI
Definition Defines.php:72
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition Linker.php:189
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
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:42
setDBLoadBalancer(ILoadBalancer $loadBalancer)
getDBLoadBalancer()
getOutput()
Get the OutputPage being used for this instance.
getContext()
Gets the context this SpecialPage is executed in.
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
getContentLanguage()
Shortcut to get content language.
A special page that displays a list of pages that are not on anyone's watchlist.
getOrderFields()
Subclasses return an array of fields to order by here.
__construct(LinkBatchFactory $linkBatchFactory, ILoadBalancer $loadBalancer, LanguageConverterFactory $languageConverterFactory)
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
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.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
The shared interface for all language converters.
Basic database interface for live and lazy-loaded relation database handles.
Definition IDatabase.php:39
Create and track the database connections and transactions for a given database cluster.
Result wrapper for grabbing data queried from an IDatabase object.