Remove "related" searches
[mediawiki.git] / includes / specials / SpecialFewestrevisions.php
blobdc9d57c2ee577b6ff9c1284dad21f9bdcb45ad24
1 <?php
2 /**
3 * Implements Special:Fewestrevisions
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
20 * @file
21 * @ingroup SpecialPage
24 /**
25 * Special page for listing the articles with the fewest revisions.
27 * @ingroup SpecialPage
28 * @author Martin Drashkov
30 class FewestrevisionsPage extends QueryPage {
31 function __construct( $name = 'Fewestrevisions' ) {
32 parent::__construct( $name );
35 function isExpensive() {
36 return true;
39 function isSyndicated() {
40 return false;
43 function getQueryInfo() {
44 return array(
45 'tables' => array( 'revision', 'page' ),
46 'fields' => array(
47 'namespace' => 'page_namespace',
48 'title' => 'page_title',
49 'value' => 'COUNT(*)',
50 'redirect' => 'page_is_redirect'
52 'conds' => array(
53 'page_namespace' => MWNamespace::getContentNamespaces(),
54 'page_id = rev_page' ),
55 'options' => array(
56 'HAVING' => 'COUNT(*) > 1',
57 // ^^^ This was probably here to weed out redirects.
58 // Since we mark them as such now, it might be
59 // useful to remove this. People _do_ create pages
60 // and never revise them, they aren't necessarily
61 // redirects.
62 'GROUP BY' => array( 'page_namespace', 'page_title', 'page_is_redirect' )
67 function sortDescending() {
68 return false;
71 /**
72 * @param Skin $skin
73 * @param object $result Database row
74 * @return string
76 function formatResult( $skin, $result ) {
77 global $wgContLang;
79 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
80 if ( !$nt ) {
81 return Html::element(
82 'span',
83 array( 'class' => 'mw-invalidtitle' ),
84 Linker::getInvalidTitleDescription(
85 $this->getContext(),
86 $result->namespace,
87 $result->title
92 $text = htmlspecialchars( $wgContLang->convert( $nt->getPrefixedText() ) );
93 $plink = Linker::linkKnown( $nt, $text );
95 $nl = $this->msg( 'nrevisions' )->numParams( $result->value )->escaped();
96 $redirect = isset( $result->redirect ) && $result->redirect ?
97 ' - ' . $this->msg( 'isredirect' )->escaped() : '';
98 $nlink = Linker::linkKnown(
99 $nt,
100 $nl,
101 array(),
102 array( 'action' => 'history' )
103 ) . $redirect;
105 return $this->getLanguage()->specialList( $plink, $nlink );
108 protected function getGroupName() {
109 return 'maintenance';