* (bug 11795) Be more paranoid about confirming accept-encoding header is present
[lhc/web/wiklou.git] / includes / SpecialUnusedimages.php
1 <?php
2 /**
3 *
4 * @addtogroup SpecialPage
5 */
6
7 /**
8 * implements Special:Unusedimages
9 * @addtogroup SpecialPage
10 */
11 class UnusedimagesPage extends ImageQueryPage {
12
13 function getName() {
14 return 'Unusedimages';
15 }
16
17 function sortDescending() {
18 return false;
19 }
20 function isSyndicated() { return false; }
21
22 function getSQL() {
23 global $wgCountCategorizedImagesAsUsed;
24 $dbr = wfGetDB( DB_SLAVE );
25
26 if ( $wgCountCategorizedImagesAsUsed ) {
27 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
28
29 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description
30 FROM ((('.$page.' AS I LEFT JOIN '.$categorylinks.' AS L ON I.page_id = L.cl_from)
31 LEFT JOIN '.$imagelinks.' AS P ON I.page_title = P.il_to)
32 INNER JOIN '.$image.' AS G ON I.page_title = G.img_name)
33 WHERE I.page_namespace = '.NS_IMAGE.' AND L.cl_from IS NULL AND P.il_to IS NULL';
34 } else {
35 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
36
37 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description' .
38 ' FROM '.$image.' LEFT JOIN '.$imagelinks.' ON img_name=il_to WHERE il_to IS NULL ';
39 }
40 }
41
42 function getPageHeader() {
43 return wfMsg( "unusedimagestext" );
44 }
45
46 }
47
48 /**
49 * Entry point
50 */
51 function wfSpecialUnusedimages() {
52 list( $limit, $offset ) = wfCheckLimits();
53 $uip = new UnusedimagesPage();
54
55 return $uip->doQuery( $offset, $limit );
56 }
57