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