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 switch ($wgDBtype) { 00029 case 'mysql': 00030 $epoch = 'UNIX_TIMESTAMP(img_timestamp)'; 00031 break; 00032 case 'oracle': 00033 $epoch = '((trunc(img_timestamp) - to_date(\'19700101\',\'YYYYMMDD\')) * 86400)'; 00034 break; 00035 case 'sqlite': 00036 $epoch = 'img_timestamp'; 00037 break; 00038 default: 00039 $epoch = 'EXTRACT(epoch FROM img_timestamp)'; 00040 } 00041 00042 if ( $wgCountCategorizedImagesAsUsed ) { 00043 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' ); 00044 00045 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value, 00046 img_user, img_user_text, img_description 00047 FROM ((($page AS I LEFT JOIN $categorylinks AS L ON I.page_id = L.cl_from) 00048 LEFT JOIN $imagelinks AS P ON I.page_title = P.il_to) 00049 INNER JOIN $image AS G ON I.page_title = G.img_name) 00050 WHERE I.page_namespace = ".NS_FILE." AND L.cl_from IS NULL AND P.il_to IS NULL"; 00051 } else { 00052 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' ); 00053 00054 return "SELECT 'Unusedimages' as type, 6 as namespace, img_name as title, $epoch as value, 00055 img_user, img_user_text, img_description 00056 FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL "; 00057 } 00058 } 00059 00060 function getPageHeader() { 00061 return wfMsgExt( 'unusedimagestext', array( 'parse' ) ); 00062 } 00063 00064 } 00065 00069 function wfSpecialUnusedimages() { 00070 list( $limit, $offset ) = wfCheckLimits(); 00071 $uip = new UnusedimagesPage(); 00072 00073 return $uip->doQuery( $offset, $limit ); 00074 }