5de29d9f9b3e397bb39768eea6e3827148fa76a5
[lhc/web/wiklou.git] / includes / specials / SpecialMostimages.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 * @file
22 * @ingroup SpecialPage
23 *
24 * @author Ævar Arnfjörð Bjarmason <avarab@gmail.com>
25 * @copyright Copyright © 2005, Ævar Arnfjörð Bjarmason
26 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
27 */
28
29 /**
30 * implements Special:Mostimages
31 * @ingroup SpecialPage
32 */
33 class MostimagesPage extends ImageQueryPage {
34
35 function getName() { return 'Mostimages'; }
36 function isExpensive() { return true; }
37 function isSyndicated() { return false; }
38
39 function getSQL() {
40 $dbr = wfGetDB( DB_SLAVE );
41 $imagelinks = $dbr->tableName( 'imagelinks' );
42 return
43 "
44 SELECT
45 'Mostimages' as type,
46 " . NS_FILE . " as namespace,
47 il_to as title,
48 COUNT(*) as value
49 FROM $imagelinks
50 GROUP BY il_to
51 HAVING COUNT(*) > 1
52 ";
53 }
54
55 function getCellHtml( $row ) {
56 global $wgLang;
57 return wfMsgExt( 'nlinks', array( 'parsemag', 'escape' ),
58 $wgLang->formatNum( $row->value ) ) . '<br />';
59 }
60
61 }
62
63 /**
64 * Constructor
65 */
66 function wfSpecialMostimages() {
67 list( $limit, $offset ) = wfCheckLimits();
68
69 $wpp = new MostimagesPage();
70
71 $wpp->doQuery( $offset, $limit );
72 }