MediaWiki  master
SpecialAncientPages.php
Go to the documentation of this file.
1 <?php
24 namespace MediaWiki\Specials;
25 
26 use HtmlArmor;
33 use Skin;
35 
42 
43  private NamespaceInfo $namespaceInfo;
44  private ILanguageConverter $languageConverter;
45 
52  public function __construct(
53  NamespaceInfo $namespaceInfo,
54  IConnectionProvider $dbProvider,
55  LinkBatchFactory $linkBatchFactory,
56  LanguageConverterFactory $languageConverterFactory
57  ) {
58  parent::__construct( 'Ancientpages' );
59  $this->namespaceInfo = $namespaceInfo;
60  $this->setDatabaseProvider( $dbProvider );
61  $this->setLinkBatchFactory( $linkBatchFactory );
62  $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
63  }
64 
65  public function isExpensive() {
66  return true;
67  }
68 
69  public function isSyndicated() {
70  return false;
71  }
72 
73  public function getQueryInfo() {
74  $tables = [ 'page', 'revision' ];
75  $conds = [
76  'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
77  'page_is_redirect' => 0
78  ];
79  $joinConds = [
80  'revision' => [
81  'JOIN', [
82  'page_latest = rev_id'
83  ]
84  ],
85  ];
86 
87  // Allow extensions to modify the query
88  $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds );
89 
90  return [
91  'tables' => $tables,
92  'fields' => [
93  'namespace' => 'page_namespace',
94  'title' => 'page_title',
95  'value' => 'rev_timestamp'
96  ],
97  'conds' => $conds,
98  'join_conds' => $joinConds
99  ];
100  }
101 
102  public function usesTimestamps() {
103  return true;
104  }
105 
106  protected function sortDescending() {
107  return false;
108  }
109 
110  public function preprocessResults( $db, $res ) {
111  $this->executeLBFromResultWrapper( $res );
112  }
113 
119  public function formatResult( $skin, $result ) {
120  $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
121  $title = Title::makeTitle( $result->namespace, $result->title );
122  $linkRenderer = $this->getLinkRenderer();
123 
124  $link = $linkRenderer->makeKnownLink(
125  $title,
126  new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) )
127  );
128 
129  return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
130  }
131 
132  protected function getGroupName() {
133  return 'maintenance';
134  }
135 }
136 
140 class_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:88
setDatabaseProvider(IConnectionProvider $databaseProvider)
Definition: QueryPage.php:985
executeLBFromResultWrapper(IResultWrapper $res, $ns=null)
Creates a new LinkBatch object, adds all pages from the passed result wrapper (MUST include title and...
Definition: QueryPage.php:946
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:185
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:76
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:624
The base class for all skins.
Definition: Skin.php:60
The shared interface for all language converters.
Provide primary and replica IDatabase connections.