MediaWiki  master
SpecialAncientPages.php
Go to the documentation of this file.
1 <?php
27 
34 
36  private $namespaceInfo;
37 
40 
47  public function __construct(
51  LanguageConverterFactory $languageConverterFactory
52  ) {
53  parent::__construct( 'Ancientpages' );
54  $this->namespaceInfo = $namespaceInfo;
55  $this->setDBLoadBalancer( $loadBalancer );
56  $this->setLinkBatchFactory( $linkBatchFactory );
57  $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
58  }
59 
60  public function isExpensive() {
61  return true;
62  }
63 
64  public function isSyndicated() {
65  return false;
66  }
67 
68  public function getQueryInfo() {
69  $tables = [ 'page', 'revision' ];
70  $conds = [
71  'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
72  'page_is_redirect' => 0
73  ];
74  $joinConds = [
75  'revision' => [
76  'JOIN', [
77  'page_latest = rev_id'
78  ]
79  ],
80  ];
81 
82  // Allow extensions to modify the query
83  $this->getHookRunner()->onAncientPagesQuery( $tables, $conds, $joinConds );
84 
85  return [
86  'tables' => $tables,
87  'fields' => [
88  'namespace' => 'page_namespace',
89  'title' => 'page_title',
90  'value' => 'rev_timestamp'
91  ],
92  'conds' => $conds,
93  'join_conds' => $joinConds
94  ];
95  }
96 
97  public function usesTimestamps() {
98  return true;
99  }
100 
101  protected function sortDescending() {
102  return false;
103  }
104 
105  public function preprocessResults( $db, $res ) {
107  }
108 
114  public function formatResult( $skin, $result ) {
115  $d = $this->getLanguage()->userTimeAndDate( $result->value, $this->getUser() );
116  $title = Title::makeTitle( $result->namespace, $result->title );
117  $linkRenderer = $this->getLinkRenderer();
118 
119  $link = $linkRenderer->makeKnownLink(
120  $title,
121  new HtmlArmor( $this->languageConverter->convertHtml( $title->getPrefixedText() ) )
122  );
123 
124  return $this->getLanguage()->specialList( $link, htmlspecialchars( $d ) );
125  }
126 
127  protected function getGroupName() {
128  return 'maintenance';
129  }
130 }
SpecialPage\$linkRenderer
LinkRenderer null $linkRenderer
Definition: SpecialPage.php:80
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
SpecialAncientPages\formatResult
formatResult( $skin, $result)
Definition: SpecialAncientPages.php:114
SpecialAncientPages\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialAncientPages.php:36
SpecialAncientPages\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialAncientPages.php:127
SpecialAncientPages\__construct
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
Definition: SpecialAncientPages.php:47
SpecialAncientPages
Implements Special:Ancientpages.
Definition: SpecialAncientPages.php:33
SpecialAncientPages\preprocessResults
preprocessResults( $db, $res)
Do any necessary preprocessing of the result object.
Definition: SpecialAncientPages.php:105
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:830
$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:41
MediaWiki\Languages\LanguageConverterFactory
An interface for creating language converters.
Definition: LanguageConverterFactory.php:46
QueryPage\executeLBFromResultWrapper
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:874
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:135
SpecialAncientPages\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialAncientPages.php:101
SpecialPage\getHookRunner
getHookRunner()
Definition: SpecialPage.php:1095
MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Definition: LanguageConverterFactory.php:125
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
SpecialAncientPages\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialAncientPages.php:68
$title
$title
Definition: testCompression.php:38
Title\makeTitle
static makeTitle( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:663
SpecialAncientPages\isSyndicated
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Definition: SpecialAncientPages.php:64
SpecialAncientPages\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialAncientPages.php:60
ILanguageConverter
The shared interface for all language converters.
Definition: ILanguageConverter.php:29
SpecialAncientPages\$languageConverter
ILanguageConverter $languageConverter
Definition: SpecialAncientPages.php:39
QueryPage\setDBLoadBalancer
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:892
QueryPage\$linkBatchFactory
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:74
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:1028
QueryPage\$loadBalancer
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:71
NamespaceInfo
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
Definition: NamespaceInfo.php:35
SpecialPage\getContentLanguage
getContentLanguage()
Shortcut to get content language.
Definition: SpecialPage.php:840
SpecialAncientPages\usesTimestamps
usesTimestamps()
Does this query return timestamps rather than integers in its 'value' field? If true,...
Definition: SpecialAncientPages.php:97
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81