MediaWiki master
SpecialAncientPages.php
Go to the documentation of this file.
1<?php
21namespace MediaWiki\Specials;
22
23use HtmlArmor;
30use Skin;
32
39
40 private NamespaceInfo $namespaceInfo;
41 private ILanguageConverter $languageConverter;
42
49 public function __construct(
50 NamespaceInfo $namespaceInfo,
51 IConnectionProvider $dbProvider,
52 LinkBatchFactory $linkBatchFactory,
53 LanguageConverterFactory $languageConverterFactory
54 ) {
55 parent::__construct( 'Ancientpages' );
56 $this->namespaceInfo = $namespaceInfo;
57 $this->setDatabaseProvider( $dbProvider );
58 $this->setLinkBatchFactory( $linkBatchFactory );
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
70 public function getQueryInfo() {
71 $tables = [ 'page', 'revision' ];
72 $conds = [
73 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
74 'page_is_redirect' => 0
75 ];
76 $joinConds = [
77 'revision' => [
78 'JOIN', [
79 'page_latest = rev_id'
80 ]
81 ],
82 ];
83
84 // Allow extensions to modify the query
85 $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds );
86
87 return [
88 'tables' => $tables,
89 'fields' => [
90 'namespace' => 'page_namespace',
91 'title' => 'page_title',
92 'value' => 'rev_timestamp'
93 ],
94 'conds' => $conds,
95 'join_conds' => $joinConds
96 ];
97 }
98
99 public function usesTimestamps() {
100 return true;
101 }
102
103 protected function sortDescending() {
104 return false;
105 }
106
107 public function preprocessResults( $db, $res ) {
108 $this->executeLBFromResultWrapper( $res );
109 }
110
116 public function formatResult( $skin, $result ) {
117 $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
118 $title = Title::makeTitle( $result->namespace, $result->title );
119 $linkRenderer = $this->getLinkRenderer();
120
121 $link = $linkRenderer->makeKnownLink(
122 $title,
123 new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) )
124 );
125
126 return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
127 }
128
129 protected function getGroupName() {
130 return 'maintenance';
131 }
132}
133
135class_alias( SpecialAncientPages::class, 'SpecialAncientPages' );
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:30
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:89
setDatabaseProvider(IConnectionProvider $databaseProvider)
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
getContentLanguage()
Shortcut to get content language.
getLanguage()
Shortcut to get user's language.
Implements Special:Ancientpages.
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
sortDescending()
Override to sort by increasing values.
__construct(NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
isExpensive()
Should this query page only be updated offline on large wikis?
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Represents a title within MediaWiki.
Definition Title.php:78
The base class for all skins.
Definition Skin.php:59
The shared interface for all language converters.
Provide primary and replica IDatabase connections.