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 }
Marks HTML that shouldn't be escaped.
Definition: HtmlArmor.php:30
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:236
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:187
An interface for creating language converters.
getLanguageConverter( $language=null)
Provide a LanguageConverter for given language.
This is a utility class for dealing with namespaces that encodes all the "magic" behaviors of them ba...
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:42
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:877
setDBLoadBalancer(ILoadBalancer $loadBalancer)
Definition: QueryPage.php:895
LinkBatchFactory null $linkBatchFactory
Definition: QueryPage.php:75
setLinkBatchFactory(LinkBatchFactory $linkBatchFactory)
Definition: QueryPage.php:136
ILoadBalancer null $loadBalancer
Definition: QueryPage.php:72
Special page for listing the articles with the fewest revisions.
sortDescending()
Override to sort by increasing values.
isSyndicated()
Sometimes we don't want to build rss / atom feeds.
ILanguageConverter $languageConverter
__construct(NamespaceInfo $namespaceInfo, ILoadBalancer $loadBalancer, LinkBatchFactory $linkBatchFactory, LanguageConverterFactory $languageConverterFactory)
isExpensive()
Is this query expensive (for some definition of expensive)? Then we don't let it run in miser mode.
getGroupName()
Under which header this special page is listed in Special:SpecialPages See messages 'specialpages-gro...
preprocessResults( $db, $res)
Cache page existence for performance.
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
getContext()
Gets the context this SpecialPage is executed in.
LinkRenderer null $linkRenderer
Definition: SpecialPage.php:81
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
getLanguage()
Shortcut to get user's language.
getContentLanguage()
Shortcut to get content language.
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:663
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:39
Database cluster connection, tracking, load balancing, and transaction manager interface.
Result wrapper for grabbing data queried from an IDatabase object.