Merge querypage-work2 branch from trunk. The most relevant changes are:
[lhc/web/wiklou.git] / includes / specials / SpecialFewestrevisions.php
1 <?php
2 /**
3 * Implements Special:Fewestrevisions
4 *
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.
9 *
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.
14 *
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
19 *
20 * @file
21 * @ingroup SpecialPage
22 */
23
24 /**
25 * Special page for listing the articles with the fewest revisions.
26 *
27 * @ingroup SpecialPage
28 * @author Martin Drashkov
29 */
30 class FewestrevisionsPage extends QueryPage {
31
32 function __construct( $name = 'Fewestrevisions' ) {
33 parent::__construct( $name );
34 }
35
36 function isExpensive() {
37 return true;
38 }
39
40 function isSyndicated() {
41 return false;
42 }
43
44 function getQueryInfo() {
45 return array (
46 'tables' => array ( 'revision', 'page' ),
47 'fields' => array ( 'page_namespace AS namespace',
48 'page_title AS title',
49 'COUNT(*) AS value',
50 'page_is_redirect AS redirect' ),
51 'conds' => array ( 'page_namespace' => MWNamespace::getContentNamespaces(),
52 'page_id = rev_page' ),
53 'options' => array ( 'HAVING' => 'COUNT(*) > 1',
54 // ^^^ This was probably here to weed out redirects.
55 // Since we mark them as such now, it might be
56 // useful to remove this. People _do_ create pages
57 // and never revise them, they aren't necessarily
58 // redirects.
59 'GROUP BY' => 'page_namespace, page_title, ' .
60 'page_is_redirect' )
61 );
62 }
63
64
65 function sortDescending() {
66 return false;
67 }
68
69 /**
70 * @param $skin Skin object
71 * @param $result Object: database row
72 */
73 function formatResult( $skin, $result ) {
74 global $wgLang, $wgContLang;
75
76 $nt = Title::makeTitleSafe( $result->namespace, $result->title );
77 if( !$nt ) {
78 return '<!-- bad title -->';
79 }
80
81 $text = $wgContLang->convert( $nt->getPrefixedText() );
82
83 $plink = $skin->linkKnown(
84 $nt,
85 $text
86 );
87
88 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape' ),
89 $wgLang->formatNum( $result->value ) );
90 $redirect = $result->redirect ? ' - ' . wfMsgHtml( 'isredirect' ) : '';
91 $nlink = $skin->linkKnown(
92 $nt,
93 $nl,
94 array(),
95 array( 'action' => 'history' )
96 ) . $redirect;
97
98 return wfSpecialList( $plink, $nlink );
99 }
100 }