Live hack: Skip some work on empty category/link sets
[lhc/web/wiklou.git] / includes / SpecialMostimages.php
1 <?php
2 /**
3 * @package MediaWiki
4 * @subpackage SpecialPage
5 *
6 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
7 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
8 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
9 */
10
11 /* */
12 require_once 'QueryPage.php';
13
14 /**
15 * @package MediaWiki
16 * @subpackage SpecialPage
17 */
18 class MostimagesPage extends QueryPage {
19
20 function getName() { return 'Mostimages'; }
21 function isExpensive() { return true; }
22 function isSyndicated() { return false; }
23
24 function getSQL() {
25 $dbr =& wfGetDB( DB_SLAVE );
26 extract( $dbr->tableNames( 'imagelinks' ) );
27 return
28 "
29 SELECT
30 'Mostimages' as type,
31 " . NS_IMAGE . " as namespace,
32 il_to as title,
33 COUNT(*) as value
34 FROM $imagelinks
35 GROUP BY il_to
36 HAVING COUNT(*) > 1
37 ";
38 }
39
40 function formatResult( $skin, $result ) {
41 global $wgContLang;
42
43 $nt = Title::makeTitle( $result->namespace, $result->title );
44 $text = $wgContLang->convert( $nt->getPrefixedText() );
45
46 $plink = $skin->makeKnownLink( $nt->getPrefixedText(), $text );
47
48 $nl = wfMsg( 'nlinks', $result->value );
49 $nlink = $skin->makeKnownLink( $nt->getPrefixedText() . '#filelinks', $nl );
50
51 return "$plink ($nlink)";
52 }
53 }
54
55 /**
56 * Constructor
57 */
58 function wfSpecialMostimages() {
59 list( $limit, $offset ) = wfCheckLimits();
60
61 $wpp = new MostimagesPage();
62
63 $wpp->doQuery( $offset, $limit );
64 }
65
66 ?>