MediaWiki  master
SpecialFewestRevisions.php
Go to the documentation of this file.
1 <?php
29 
37 
39  private $namespaceInfo;
40 
43 
50  public function __construct(
54  LanguageConverterFactory $languageConverterFactory
55  ) {
56  parent::__construct( 'Fewestrevisions' );
57  $this->namespaceInfo = $namespaceInfo;
58  $this->setDBLoadBalancer( $loadBalancer );
59  $this->setLinkBatchFactory( $linkBatchFactory );
60  $this->languageConverter = $languageConverterFactory->getLanguageConverter( $this->getContentLanguage() );
61  }
62 
63  public function isExpensive() {
64  return true;
65  }
66 
67  public function isSyndicated() {
68  return false;
69  }
70 
71  public function getQueryInfo() {
72  return [
73  'tables' => [ 'revision', 'page' ],
74  'fields' => [
75  'namespace' => 'page_namespace',
76  'title' => 'page_title',
77  'value' => 'COUNT(*)',
78  ],
79  'conds' => [
80  'page_namespace' => $this->namespaceInfo->getContentNamespaces(),
81  'page_id = rev_page',
82  'page_is_redirect = 0',
83  ],
84  'options' => [
85  'GROUP BY' => [ 'page_namespace', 'page_title' ]
86  ]
87  ];
88  }
89 
90  protected function sortDescending() {
91  return false;
92  }
93 
99  public function formatResult( $skin, $result ) {
100  $nt = Title::makeTitleSafe( $result->namespace, $result->title );
101  if ( !$nt ) {
102  return Html::element(
103  'span',
104  [ 'class' => 'mw-invalidtitle' ],
106  $this->getContext(),
107  $result->namespace,
108  $result->title
109  )
110  );
111  }
112  $linkRenderer = $this->getLinkRenderer();
113 
114  $text = $this->languageConverter->convertHtml( $nt->getPrefixedText() );
115  $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
116 
117  $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
118  $redirect = isset( $result->redirect ) && $result->redirect ?
119  ' - ' . $this->msg( 'isredirect' )->escaped() : '';
120  $nlink = $linkRenderer->makeKnownLink(
121  $nt,
122  $nl,
123  [],
124  [ 'action' => 'history' ]
125  ) . $redirect;
126 
127  return $this->getLanguage()->specialList( $plink, $nlink );
128  }
129 
136  protected function preprocessResults( $db, $res ) {
138  }
139 
140  protected function getGroupName() {
141  return 'maintenance';
142  }
143 }
SpecialPage\$linkRenderer
LinkRenderer null $linkRenderer
Definition: SpecialPage.php:80
SpecialFewestRevisions\__construct
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
Definition: SpecialFewestRevisions.php:50
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:912
HtmlArmor
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
SpecialFewestRevisions\getGroupName
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
Definition: SpecialFewestRevisions.php:140
SpecialFewestRevisions\formatResult
formatResult( $skin, $result)
Definition: SpecialFewestRevisions.php:99
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:830
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:185
$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
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
QueryPage\setLinkBatchFactory
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:135
MediaWiki\Languages\LanguageConverterFactory\getLanguageConverter
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
Definition: LanguageConverterFactory.php:125
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:26
MediaWiki\Cache\LinkBatchFactory
Definition: LinkBatchFactory.php:39
SpecialFewestRevisions\$namespaceInfo
NamespaceInfo $namespaceInfo
Definition: SpecialFewestRevisions.php:39
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:764
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:689
ILanguageConverter
The shared interface for all language converters.
Definition: ILanguageConverter.php:29
SpecialFewestRevisions
Special page for listing the articles with the fewest revisions.
Definition: SpecialFewestRevisions.php:36
SpecialFewestRevisions\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialFewestRevisions.php:90
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
SpecialFewestRevisions\$languageConverter
ILanguageConverter $languageConverter
Definition: SpecialFewestRevisions.php:42
SpecialFewestRevisions\isExpensive
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
Definition: SpecialFewestRevisions.php:63
SpecialFewestRevisions\isSyndicated
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
Definition: SpecialFewestRevisions.php:67
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
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:232
SpecialFewestRevisions\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialFewestRevisions.php:71
Wikimedia\Rdbms\ILoadBalancer
Database cluster connection, tracking, load balancing, and transaction manager interface.
Definition: ILoadBalancer.php:81
SpecialFewestRevisions\preprocessResults
preprocessResults( $db, $res)
Cache page existence for performance.
Definition: SpecialFewestRevisions.php:136