MediaWiki master
SpecialAncientPages.php
Go to the documentation of this file.
1<?php
7namespace MediaWiki\Specials;
8
9use MediaWiki\Cache\LinkBatchFactory;
11use MediaWiki\Languages\LanguageConverterFactory;
18
25
26 private NamespaceInfo $namespaceInfo;
27 private ILanguageConverter $languageConverter;
28
29 public function __construct(
30 NamespaceInfo $namespaceInfo,
31 IConnectionProvider $dbProvider,
32 LinkBatchFactory $linkBatchFactory,
33 LanguageConverterFactory $languageConverterFactory
34 ) {
35 parent::__construct( 'Ancientpages' );
36 $this->namespaceInfo = $namespaceInfo;
37 $this->setDatabaseProvider( $dbProvider );
38 $this->setLinkBatchFactory( $linkBatchFactory );
39 $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
40 }
41
43 public function isExpensive() {
44 return true;
45 }
46
48 public function isSyndicated() {
49 return false;
50 }
51
53 public function getQueryInfo() {
54 $tables = [ 'page', 'revision' ];
55 $conds = [
56 'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
57 'page_is_redirect' => 0
58 ];
59 $joinConds = [
60 'revision' => [
61 'JOIN', [
62 'page_latest = rev_id'
63 ]
64 ],
65 ];
66
67 // Allow extensions to modify the query
68 $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds );
69
70 return [
71 'tables' => $tables,
72 'fields' => [
73 'namespace' => 'page_namespace',
74 'title' => 'page_title',
75 'value' => 'rev_timestamp'
76 ],
77 'conds' => $conds,
78 'join_conds' => $joinConds
79 ];
80 }
81
83 public function usesTimestamps() {
84 return true;
85 }
86
88 protected function sortDescending() {
89 return false;
90 }
91
93 public function preprocessResults( $db, $res ) {
94 $this->executeLBFromResultWrapper( $res );
95 }
96
102 public function formatResult( $skin, $result ) {
103 $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
104 $title = Title::makeTitle( $result->namespace, $result->title );
105 $linkRenderer = $this->getLinkRenderer();
106
107 $link = $linkRenderer->makeKnownLink(
108 $title,
109 new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) )
110 );
111
112 return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
113 }
114
116 protected function getGroupName() {
117 return 'maintenance';
118 }
119}
120
122class_alias( SpecialAncientPages::class, 'SpecialAncientPages' );
makeTitle( $linkId)
Convert a link ID to a Title.to override Title
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
__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.to override
isExpensive()
Should this query page only be updated offline on large wikis?If the query for this page is considere...
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: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.