Fix bug in prefixing scheme
[lhc/web/wiklou.git] / includes / specials / SpecialWantedfiles.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 * Querypage that lists the most wanted files - implements Special:Wantedfiles
22 *
23 * @file
24 * @ingroup SpecialPage
25 *
26 * @author Soxred93 <soxred93@gmail.com>
27 * @copyright Copyright © 2008, Soxred93
28 * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later
29 */
30 class WantedFilesPage extends WantedQueryPage {
31
32 function getName() {
33 return 'Wantedfiles';
34 }
35
36 function getSQL() {
37 $dbr = wfGetDB( DB_SLAVE );
38 list( $imagelinks, $page ) = $dbr->tableNamesN( 'imagelinks', 'page' );
39 $name = $dbr->addQuotes( $this->getName() );
40 return
41 "
42 SELECT
43 $name as type,
44 " . NS_FILE . " as namespace,
45 il_to as title,
46 COUNT(*) as value
47 FROM $imagelinks
48 LEFT JOIN $page ON il_to = page_title AND page_namespace = ". NS_FILE ."
49 WHERE page_title IS NULL
50 GROUP BY il_to
51 ";
52 }
53 }
54
55 /**
56 * constructor
57 */
58 function wfSpecialWantedFiles() {
59 list( $limit, $offset ) = wfCheckLimits();
60
61 $wpp = new WantedFilesPage();
62
63 $wpp->doQuery( $offset, $limit );
64 }