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