MediaWiki  master
SpecialFewestRevisions.php
Go to the documentation of this file.
1 <?php
27 
35  public function __construct( $name = 'Fewestrevisions' ) {
36  parent::__construct( $name );
37  }
38 
39  public function isExpensive() {
40  return true;
41  }
42 
43  public function isSyndicated() {
44  return false;
45  }
46 
47  public function getQueryInfo() {
48  return [
49  'tables' => [ 'revision', 'page' ],
50  'fields' => [
51  'namespace' => 'page_namespace',
52  'title' => 'page_title',
53  'value' => 'COUNT(*)',
54  ],
55  'conds' => [
56  'page_namespace' => MediaWikiServices::getInstance()->getNamespaceInfo()->
57  getContentNamespaces(),
58  'page_id = rev_page',
59  'page_is_redirect = 0',
60  ],
61  'options' => [
62  'GROUP BY' => [ 'page_namespace', 'page_title' ]
63  ]
64  ];
65  }
66 
67  protected function sortDescending() {
68  return false;
69  }
70 
76  public function formatResult( $skin, $result ) {
77  $nt = Title::makeTitleSafe( $result->namespace, $result->title );
78  if ( !$nt ) {
79  return Html::element(
80  'span',
81  [ 'class' => 'mw-invalidtitle' ],
83  $this->getContext(),
84  $result->namespace,
85  $result->title
86  )
87  );
88  }
89  $linkRenderer = $this->getLinkRenderer();
90 
91  $text = $this->getLanguageConverter()->convertHtml( $nt->getPrefixedText() );
92  $plink = $linkRenderer->makeLink( $nt, new HtmlArmor( $text ) );
93 
94  $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->text();
95  $redirect = isset( $result->redirect ) && $result->redirect ?
96  ' - ' . $this->msg( 'isredirect' )->escaped() : '';
97  $nlink = $linkRenderer->makeKnownLink(
98  $nt,
99  $nl,
100  [],
101  [ 'action' => 'history' ]
102  ) . $redirect;
103 
104  return $this->getLanguage()->specialList( $plink, $nlink );
105  }
106 
113  protected function preprocessResults( $db, $res ) {
115  }
116 
117  protected function getGroupName() {
118  return 'maintenance';
119  }
120 }
SpecialPage\msg
msg( $key,... $params)
Wrapper around wfMessage that sets the current context.
Definition: SpecialPage.php:828
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:117
SpecialFewestRevisions\formatResult
formatResult( $skin, $result)
Definition: SpecialFewestRevisions.php:76
MediaWiki\MediaWikiServices
MediaWikiServices is the service locator for the application scope of MediaWiki.
Definition: MediaWikiServices.php:154
SpecialPage\getLanguage
getLanguage()
Shortcut to get user's language.
Definition: SpecialPage.php:774
Linker\getInvalidTitleDescription
static getInvalidTitleDescription(IContextSource $context, $namespace, $title)
Get a message saying that an invalid title was encountered.
Definition: Linker.php:188
$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:39
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:823
Wikimedia\Rdbms\IDatabase
Basic database interface for live and lazy-loaded relation database handles.
Definition: IDatabase.php:38
Wikimedia\Rdbms\IResultWrapper
Result wrapper for grabbing data queried from an IDatabase object.
Definition: IResultWrapper.php:24
SpecialFewestRevisions\__construct
__construct( $name='Fewestrevisions')
Definition: SpecialFewestRevisions.php:35
SpecialPage\getContext
getContext()
Gets the context this SpecialPage is executed in.
Definition: SpecialPage.php:717
Title\makeTitleSafe
static makeTitleSafe( $ns, $title, $fragment='', $interwiki='')
Create a new Title from a namespace index and a DB key.
Definition: Title.php:618
SpecialFewestRevisions
Special page for listing the articles with the fewest revisions.
Definition: SpecialFewestRevisions.php:34
SpecialFewestRevisions\sortDescending
sortDescending()
Override to sort by increasing values.
Definition: SpecialFewestRevisions.php:67
SpecialPage\getLinkRenderer
getLinkRenderer()
Definition: SpecialPage.php:944
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:39
SpecialFewestRevisions\isSyndicated
isSyndicated()
Sometime we don't want to build rss / atom feeds.
Definition: SpecialFewestRevisions.php:43
SpecialPage\getLanguageConverter
getLanguageConverter()
Shortcut to get language's converter.
Definition: SpecialPage.php:784
SpecialPage\$linkRenderer
MediaWiki Linker LinkRenderer null $linkRenderer
Definition: SpecialPage.php:71
Html\element
static element( $element, $attribs=[], $contents='')
Identical to rawElement(), but HTML-escapes $contents (like Xml::element()).
Definition: Html.php:231
SpecialFewestRevisions\getQueryInfo
getQueryInfo()
Subclasses return an SQL query here, formatted as an array with the following keys: tables => Table(s...
Definition: SpecialFewestRevisions.php:47
SpecialFewestRevisions\preprocessResults
preprocessResults( $db, $res)
Cache page existence for performance.
Definition: SpecialFewestRevisions.php:113