MediaWiki  master
SpecialUnwatchedPages.php
Go to the documentation of this file.
1 <?php
29 
36 
37  public function __construct( $name = 'Unwatchedpages' ) {
38  parent::__construct( $name, 'unwatchedpages' );
39  }
40 
41  public function isExpensive() {
42  return true;
43  }
44 
45  public function isSyndicated() {
46  return false;
47  }
48 
55  public function preprocessResults( $db, $res ) {
56  if ( !$res->numRows() ) {
57  return;
58  }
59 
60  $batch = new LinkBatch();
61  foreach ( $res as $row ) {
62  $batch->add( $row->namespace, $row->title );
63  }
64  $batch->execute();
65 
66  $res->seek( 0 );
67  }
68 
69  public function getQueryInfo() {
70  $dbr = wfGetDB( DB_REPLICA );
71  return [
72  'tables' => [ 'page', 'watchlist' ],
73  'fields' => [
74  'namespace' => 'page_namespace',
75  'title' => 'page_title',
76  'value' => 'page_namespace'
77  ],
78  'conds' => [
79  'wl_title IS NULL',
80  'page_is_redirect' => 0,
81  'page_namespace != ' . $dbr->addQuotes( NS_MEDIAWIKI ),
82  ],
83  'join_conds' => [ 'watchlist' => [
84  'LEFT JOIN', [ 'wl_title = page_title',
85  'wl_namespace = page_namespace' ] ] ]
86  ];
87  }
88 
89  protected function sortDescending() {
90  return false;
91  }
92 
93  protected function getOrderFields() {
94  return [ 'page_namespace', 'page_title' ];
95  }
96 
101  public function execute( $par ) {
102  parent::execute( $par );
103  $this->getOutput()->addModules( 'mediawiki.special.unwatchedPages' );
104  $this->addHelpLink( 'Help:Watchlist' );
105  }
106 
112  public function formatResult( $skin, $result ) {
113  $nt = Title::makeTitleSafe( $result->namespace, $result->title );
114  if ( !$nt ) {
115  return Html::element( 'span', [ 'class' => 'mw-invalidtitle' ],
116  Linker::getInvalidTitleDescription( $this->getContext(), $result->namespace, $result->title ) );
117  }
118 
119  $text = $this->getLanguageConverter()->convertHtml( $nt->getPrefixedText() );
120 
121  $linkRenderer = $this->getLinkRenderer();
122 
123  $plink = $linkRenderer->makeKnownLink( $nt, new HtmlArmor( $text ) );
124  $wlink = $linkRenderer->makeKnownLink(
125  $nt,
126  $this->msg( 'watch' )->text(),
127  [ 'class' => 'mw-watch-link' ],
128  [ 'action' => 'watch' ]
129  );
130 
131  return $this->getLanguage()->specialList( $plink, $wlink );
132  }
133 
134  protected function getGroupName() {
135  return 'maintenance';
136  }
137 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
SpecialUnwatchedPages
A special page that displays a list of pages that are not on anyones watchlist.
Definition: SpecialUnwatchedPages.php:35
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
LinkBatch
Class representing a list of titles The execute() method checks them all for existence and adds them ...
Definition: LinkBatch.php:35
SpecialPage\getOutput
getOutput()
Get the OutputPage being used for this instance.
Definition: SpecialPage.php:744
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:774
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:188
$res
$res
Definition: testCompression.php:57
QueryPage
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:39
SpecialUnwatchedPages\preprocessResults
preprocessResults( $db, $res)
Pre-cache page existence to speed up link generation.
Definition: SpecialUnwatchedPages.php:55
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
$dbr
$dbr
Definition: testCompression.php:54
SpecialPage\addHelpLink
addHelpLink( $to, $overrideBaseUrl=false)
Adds help link with an icon via page indicators.
Definition: SpecialPage.php:864
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
wfGetDB
wfGetDB( $db, $groups=[], $wiki=false)
Get a Database object.
Definition: GlobalFunctions.php:2467
DB_REPLICA
const DB_REPLICA
Definition: defines.php:25
SpecialUnwatchedPages\execute
execute( $par)
Add the JS.
Definition: SpecialUnwatchedPages.php:101
SpecialUnwatchedPages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialUnwatchedPages.php:134
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
SpecialUnwatchedPages\__construct
__construct( $name='Unwatchedpages')
Definition: SpecialUnwatchedPages.php:37
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
SpecialUnwatchedPages\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialUnwatchedPages.php:45
SpecialUnwatchedPages\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialUnwatchedPages.php:41
SpecialUnwatchedPages\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialUnwatchedPages.php:89
SpecialUnwatchedPages\getOrderFields
getOrderFields()
Subclasses return an array of fields to order by here.
Definition: SpecialUnwatchedPages.php:93
SpecialUnwatchedPages\formatResult
formatResult( $skin, $result)
Definition: SpecialUnwatchedPages.php:112
SpecialPage\getLanguageConverter
getLanguageConverter()
Shortcut to get language's converter.
Definition: SpecialPage.php:784
NS_MEDIAWIKI
const NS_MEDIAWIKI
Definition: Defines.php:77
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:71
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
SpecialUnwatchedPages\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialUnwatchedPages.php:69