00001 <?php 00011 class UnusedimagesPage extends ImageQueryPage { 00012 00013 function isExpensive() { return true; } 00014 00015 function getName() { 00016 return 'Unusedimages'; 00017 } 00018 00019 function sortDescending() { 00020 return false; 00021 } 00022 function isSyndicated() { return false; } 00023 00024 function getSQL() { 00025 global $wgCountCategorizedImagesAsUsed, $wgDBtype; 00026 $dbr = wfGetDB( DB_SLAVE ); 00027 00028 $epoch = $wgDBtype == 'mysql' ? 00029 'UNIX_TIMESTAMP(img_timestamp)' : 00030 'EXTRACT(epoch FROM img_timestamp)'; 00031 00032 if ( $wgCountCategorizedImagesAsUsed ) { 00033 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' ); 00034 00035 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value, 00036 img_user, img_user_text, img_description 00037 FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from) 00038 LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to) 00039 INNER JOIN $image AS G ON I.page_title = G.img_name) 00040 WHERE I.page_namespace = ".NS_FILE." AND L.cl_from IS NULL AND P.il_to IS NULL"; 00041 } else { 00042 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' ); 00043 00044 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value, 00045 img_user, img_user_text, img_description 00046 FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL "; 00047 } 00048 } 00049 00050 function getPageHeader() { 00051 return wfMsgExt( 'unusedimagestext', array( 'parse' ) ); 00052 } 00053 00054 } 00055 00059 function wfSpecialUnusedimages() { 00060 list( $limit, $offset ) = wfCheckLimits(); 00061 $uip = new UnusedimagesPage(); 00062 00063 return $uip->doQuery( $offset, $limit ); 00064 }