MediaWiki master
SpecialAncientPages.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
18
25
26 private readonly ILanguageConverter $languageConverter;
27
28 public function __construct(
29 private readonly NamespaceInfo $namespaceInfo,
30 IConnectionProvider $dbProvider,
31 LinkBatchFactory $linkBatchFactory,
32 LanguageConverterFactory $languageConverterFactory,
33 ) {
34 parent::__construct( 'Ancientpages' );
35 $this->setDatabaseProvider( $dbProvider );
36 $this->setLinkBatchFactory( $linkBatchFactory );
37 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
38 }
39
41 public function isExpensive() {
42 return true;
43 }
44
46 public function isSyndicated() {
47 return false;
48 }
49
51 public function getQueryInfo() {
52 $tables = [ 'page', 'revision' ];
53 $conds = [
54 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
55 'page_is_redirect' => 0
56 ];
57 $joinConds = [
58 'revision' => [
59 'JOIN', [
60 'page_latest = rev_id'
61 ]
62 ],
63 ];
64
65 // Allow extensions to modify the query
66 $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds );
67
68 return [
69 'tables' => $tables,
70 'fields' => [
71 'namespace' => 'page_namespace',
72 'title' => 'page_title',
73 'value' => 'rev_timestamp'
74 ],
75 'conds' => $conds,
76 'join_conds' => $joinConds
77 ];
78 }
79
81 public function usesTimestamps() {
82 return true;
83 }
84
86 protected function sortDescending() {
87 return false;
88 }
89
91 public function preprocessResults( $db, $res ) {
92 $this->executeLBFromResultWrapper( $res );
93 }
94
100 public function formatResult( $skin, $result ) {
101 $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
102 $title = Title::makeTitle( $result->namespace, $result->title );
103 $linkRenderer = $this->getLinkRenderer();
104
105 $link = $linkRenderer->makeKnownLink(
106 $title,
107 new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) )
108 );
109
110 return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
111 }
112
114 protected function getGroupName() {
115 return 'maintenance';
116 }
117}
118
120class_alias( SpecialAncientPages::class, 'SpecialAncientPages' );
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Factory for LinkBatch objects to batch query page metadata.
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)
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.to override bool
sortDescending()
Override to sort by increasing values.to override bool
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.to override
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
__construct(private readonly NamespaceInfo $namespaceInfo, IConnectionProvider $dbProvider, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory,)
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:69
Marks HTML that shouldn't be escaped.
Definition HtmlArmor.php:18
The shared interface for all language converters.
Provide primary and replica IDatabase connections.