3 * Implements Special:Unusedimages
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.
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.
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
21 * @ingroup SpecialPage
25 * A special page that lists unused images
27 * @ingroup SpecialPage
29 class UnusedimagesPage
extends ImageQueryPage
{
31 function isExpensive() { return true; }
34 return 'Unusedimages';
37 function sortDescending() {
40 function isSyndicated() { return false; }
43 global $wgCountCategorizedImagesAsUsed;
45 $dbr = wfGetDB( DB_SLAVE
);
47 $epoch = $dbr->unixTimestamp( 'img_timestamp' );
49 if ( $wgCountCategorizedImagesAsUsed ) {
50 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
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";
59 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
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 ";
67 function getPageHeader() {
68 return wfMsgExt( 'unusedimagestext', array( 'parse' ) );
76 function wfSpecialUnusedimages() {
77 list( $limit, $offset ) = wfCheckLimits();
78 $uip = new UnusedimagesPage();
80 return $uip->doQuery( $offset, $limit );