API * Optimized backlinking query (still needs an index change)
[mediawiki.git] / includes / SpecialMostrevisions.php
blob676923ae79aca418a1dbde836f6ed8f9dbf09c5f
1 <?php
2 /**
3 * A special page to show pages in the
5 * @package MediaWiki
6 * @subpackage SpecialPage
8 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
9 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
10 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
13 /**
14 * @package MediaWiki
15 * @subpackage SpecialPage
17 class MostrevisionsPage extends QueryPage {
19 function getName() { return 'Mostrevisions'; }
20 function isExpensive() { return true; }
21 function isSyndicated() { return false; }
23 function getSQL() {
24 $dbr =& wfGetDB( DB_SLAVE );
25 extract( $dbr->tableNames( 'revision', 'page' ) );
26 return
28 SELECT
29 'Mostrevisions' as type,
30 page_namespace as namespace,
31 page_title as title,
32 COUNT(*) as value
33 FROM $revision
34 JOIN $page ON page_id = rev_page
35 WHERE page_namespace = " . NS_MAIN . "
36 GROUP BY 1,2,3
37 HAVING COUNT(*) > 1
41 function formatResult( $skin, $result ) {
42 global $wgLang, $wgContLang;
44 $nt = Title::makeTitle( $result->namespace, $result->title );
45 $text = $wgContLang->convert( $nt->getPrefixedText() );
47 $plink = $skin->makeKnownLinkObj( $nt, $text );
49 $nl = wfMsgExt( 'nrevisions', array( 'parsemag', 'escape'),
50 $wgLang->formatNum( $result->value ) );
51 $nlink = $skin->makeKnownLinkObj( $nt, $nl, 'action=history' );
53 return wfSpecialList($plink, $nlink);
57 /**
58 * constructor
60 function wfSpecialMostrevisions() {
61 list( $limit, $offset ) = wfCheckLimits();
63 $wpp = new MostrevisionsPage();
65 $wpp->doQuery( $offset, $limit );