5 * @subpackage SpecialPage
9 require_once("QueryPage.php");
13 * @subpackage SpecialPage
15 class UnusedimagesPage
extends QueryPage
{
18 return 'Unusedimages';
21 function sortDescending() {
24 function isSyndicated() { return false; }
27 global $wgCountCategorizedImagesAsUsed;
28 $dbr =& wfGetDB( DB_SLAVE
);
30 if ( $wgCountCategorizedImagesAsUsed ) {
31 extract( $dbr->tableNames( 'page', 'image', 'imagelinks', 'categorylinks' ) );
33 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description
34 FROM ((('.$page.' AS I LEFT JOIN '.$categorylinks.' AS L ON I.page_id = L.cl_from)
35 LEFT JOIN '.$imagelinks.' AS P ON I.page_title = P.il_to)
36 INNER JOIN '.$image.' AS G ON I.page_title = G.img_name)
37 WHERE I.page_namespace = '.NS_IMAGE
.' AND L.cl_from IS NULL AND P.il_to IS NULL';
39 extract( $dbr->tableNames( 'image','imagelinks' ) );
41 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description' .
42 ' FROM '.$image.' LEFT JOIN '.$imagelinks.' ON img_name=il_to WHERE il_to IS NULL ';
46 function formatResult( $skin, $result ) {
47 global $wgLang, $wgContLang;
48 $title = Title
::makeTitle( NS_IMAGE
, $result->title
);
50 $imageUrl = htmlspecialchars( Image
::imageUrl( $result->title
) );
51 $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
54 # The 'desc' linking to the image page
55 '('.$skin->makeKnownLinkObj( $title, wfMsg('imgdesc') ).') ' . $dirmark .
57 # Link to the image itself
58 '<a href="' . $imageUrl . '">' . htmlspecialchars( $title->getText() ) .
59 '</a> . . ' . $dirmark .
62 $wgLang->timeanddate($result->value
) . ' . . ' . $dirmark .
65 $skin->makeLinkObj( Title
::makeTitle( NS_USER
, $result->img_user_text
),
66 $result->img_user_text
) . $dirmark .
68 # If there is a description, show it
69 $skin->commentBlock( $wgContLang->convert( $result->img_description
) );
74 function getPageHeader() {
75 return wfMsg( "unusedimagestext" );
83 function wfSpecialUnusedimages() {
84 list( $limit, $offset ) = wfCheckLimits();
85 $uip = new UnusedimagesPage();
87 return $uip->doQuery( $offset, $limit );