9a4269ffb0ab2966e5d3d344d67f266d7f6d6a54
[lhc/web/wiklou.git] / includes / specials / SpecialMostrevisions.php
1 <?php
2 /**
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
18 */
19
20 /**
21 * A special page to show pages in the
22 *
23 * @ingroup SpecialPage
24 *
25 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
26 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
27 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
28 */
29
30 /**
31 * @ingroup SpecialPage
32 */
33 class MostrevisionsPage extends QueryPage {
34
35 function getName() { return 'Mostrevisions'; }
36 function isExpensive() { return true; }
37 function isSyndicated() { return false; }
38
39 function getSQL() {
40 $dbr = wfGetDB( DB_SLAVE );
41 list( $revision, $page ) = $dbr->tableNamesN( 'revision', 'page' );
42 return
43 "
44 SELECT
45 'Mostrevisions' as type,
46 page_namespace as namespace,
47 page_title as title,
48 COUNT(*) as value
49 FROM $revision
50 JOIN $page ON page_id = rev_page
51 WHERE page_namespace = " . NS_MAIN . "
52 GROUP BY page_namespace, page_title
53 HAVING COUNT(*) > 1
54 ";
55 }
56
57 function formatResult( $skin, $result ) {
58 global $wgLang, $wgContLang;
59
60 $nt = Title::makeTitle( $result->namespace, $result->title );
61 $text = $wgContLang->convert( $nt->getPrefixedText() );
62
63 $plink = $skin->linkKnown( $nt, $text );
64
65 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
66 $wgLang->formatNum( $result->value ) );
67 $nlink = $skin->linkKnown(
68 $nt,
69 $nl,
70 array(),
71 array( 'action' => 'history' )
72 );
73
74 return wfSpecialList($plink, $nlink);
75 }
76 }
77
78 /**
79 * constructor
80 */
81 function wfSpecialMostrevisions() {
82 list( $limit, $offset ) = wfCheckLimits();
83
84 $wpp = new MostrevisionsPage();
85
86 $wpp->doQuery( $offset, $limit );
87 }