Only whitespace changes
[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 switch ($wgDBtype) {
29 case 'mysql':
30 $epoch = 'UNIX_TIMESTAMP(img_timestamp)';
31 break;
32 case 'oracle':
33 $epoch = '((trunc(img_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)';
34 break;
35 default:
36 $epoch = 'EXTRACT(epoch FROM img_timestamp)';
37 }
38
39 if ( $wgCountCategorizedImagesAsUsed ) {
40 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
41
42 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
43 img_user, img_user_text, img_description
44 FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from)
45 LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to)
46 INNER JOIN $image AS G ON I.page_title = G.img_name)
47 WHERE I.page_namespace = ".NS_FILE." AND L.cl_from IS NULL AND P.il_to IS NULL";
48 } else {
49 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
50
51 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value,
52 img_user, img_user_text, img_description
53 FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL ";
54 }
55 }
56
57 function getPageHeader() {
58 return wfMsgExt( 'unusedimagestext', array( 'parse' ) );
59 }
60
61 }
62
63 /**
64 * Entry point
65 */
66 function wfSpecialUnusedimages() {
67 list( $limit, $offset ) = wfCheckLimits();
68 $uip = new UnusedimagesPage();
69
70 return $uip->doQuery( $offset, $limit );
71 }