4 * @addtogroup SpecialPage
8 * @addtogroup SpecialPage
10 class UnusedimagesPage
extends QueryPage
{
13 return 'Unusedimages';
16 function sortDescending() {
19 function isSyndicated() { return false; }
22 global $wgCountCategorizedImagesAsUsed;
23 $dbr = wfGetDB( DB_SLAVE
);
25 if ( $wgCountCategorizedImagesAsUsed ) {
26 list( $page, $image, $imagelinks, $categorylinks ) = $dbr->tableNamesN( 'page', 'image', 'imagelinks', 'categorylinks' );
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';
34 list( $image, $imagelinks ) = $dbr->tableNamesN( 'image','imagelinks' );
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 ';
41 function formatResult( $skin, $result ) {
42 global $wgLang, $wgContLang;
43 $title = Title
::makeTitle( NS_IMAGE
, $result->title
);
45 $imageUrl = htmlspecialchars( Image
::imageUrl( $result->title
) );
46 $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
49 # The 'desc' linking to the image page
50 '('.$skin->makeKnownLinkObj( $title, wfMsg('imgdesc') ).') ' . $dirmark .
52 # Link to the image itself
53 '<a href="' . $imageUrl . '">' . htmlspecialchars( $title->getText() ) .
54 '</a> . . ' . $dirmark .
57 $wgLang->timeanddate($result->value
) . ' . . ' . $dirmark .
60 $skin->makeLinkObj( Title
::makeTitle( NS_USER
, $result->img_user_text
),
61 $result->img_user_text
) . $dirmark .
63 # If there is a description, show it
64 $skin->commentBlock( $wgContLang->convert( $result->img_description
) );
69 function getPageHeader() {
70 return wfMsg( "unusedimagestext" );
78 function wfSpecialUnusedimages() {
79 list( $limit, $offset ) = wfCheckLimits();
80 $uip = new UnusedimagesPage();
82 return $uip->doQuery( $offset, $limit );