]> scripts.mit.edu Git - autoinstallsdev/mediawiki.git/blob - includes/specials/SpecialUnusedimages.php
MediaWiki 1.17.1-scripts
[autoinstallsdev/mediawiki.git] / includes / specials / SpecialUnusedimages.php
1 <?php
2 /**
3  * Implements Special:Unusedimages
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18  * http://www.gnu.org/copyleft/gpl.html
19  *
20  * @file
21  * @ingroup SpecialPage
22  */
23
24 /**
25  * A special page that lists unused images
26  *
27  * @ingroup SpecialPage
28  */
29 class UnusedimagesPage extends ImageQueryPage {
30
31         function isExpensive() { return true; }
32
33         function getName() {
34                 return 'Unusedimages';
35         }
36
37         function sortDescending() {
38                 return false;
39         }
40         function isSyndicated() { return false; }
41
42         function getSQL() {
43                 global $wgCountCategorizedImagesAsUsed;
44
45                 $dbr = wfGetDB( DB_SLAVE );
46
47                 $epoch = $dbr->unixTimestamp( 'img_timestamp' );
48
49                 if ( $wgCountCategorizedImagesAsUsed ) {
50                         list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
51
52                         return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
53                                                 img_user, img_user_text,  img_description
54                                         FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from)
55                                                 LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to)
56                                                 INNER JOIN $image AS G ON I.page_title = G.img_name)
57                                         WHERE I.page_namespace = ".NS_FILE." AND L.cl_from IS NULL AND P.il_to IS NULL";
58                 } else {
59                         list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
60
61                         return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
62                                 img_user, img_user_text,  img_description
63                                 FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL ";
64                 }
65         }
66
67         function getPageHeader() {
68                 return wfMsgExt( 'unusedimagestext', array( 'parse' ) );
69         }
70
71 }
72
73 /**
74  * Entry point
75  */
76 function wfSpecialUnusedimages() {
77         list( $limit, $offset ) = wfCheckLimits();
78         $uip = new UnusedimagesPage();
79
80         return $uip->doQuery( $offset, $limit );
81 }