Refactored parser output handling slightly, and added a hook function, to allow exten...
[lhc/web/wiklou.git] / includes / SpecialUnusedimages.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /**
9 * @package MediaWiki
10 * @subpackage SpecialPage
11 */
12 class UnusedimagesPage extends QueryPage {
13
14 function getName() {
15 return 'Unusedimages';
16 }
17
18 function sortDescending() {
19 return false;
20 }
21 function isSyndicated() { return false; }
22
23 function getSQL() {
24 global $wgCountCategorizedImagesAsUsed;
25 $dbr =& wfGetDB( DB_SLAVE );
26
27 if ( $wgCountCategorizedImagesAsUsed ) {
28 extract( $dbr->tableNames( 'page', 'image', 'imagelinks', 'categorylinks' ) );
29
30 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description
31 FROM ((('.$page.' AS I LEFT JOIN '.$categorylinks.' AS L ON I.page_id = L.cl_from)
32 LEFT JOIN '.$imagelinks.' AS P ON I.page_title = P.il_to)
33 INNER JOIN '.$image.' AS G ON I.page_title = G.img_name)
34 WHERE I.page_namespace = '.NS_IMAGE.' AND L.cl_from IS NULL AND P.il_to IS NULL';
35 } else {
36 extract( $dbr->tableNames( 'image','imagelinks' ) );
37
38 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description' .
39 ' FROM '.$image.' LEFT JOIN '.$imagelinks.' ON img_name=il_to WHERE il_to IS NULL ';
40 }
41 }
42
43 function formatResult( $skin, $result ) {
44 global $wgLang, $wgContLang;
45 $title = Title::makeTitle( NS_IMAGE, $result->title );
46
47 $imageUrl = htmlspecialchars( Image::imageUrl( $result->title ) );
48 $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
49
50 $return =
51 # The 'desc' linking to the image page
52 '('.$skin->makeKnownLinkObj( $title, wfMsg('imgdesc') ).') ' . $dirmark .
53
54 # Link to the image itself
55 '<a href="' . $imageUrl . '">' . htmlspecialchars( $title->getText() ) .
56 '</a> . . ' . $dirmark .
57
58 # Last modified date
59 $wgLang->timeanddate($result->value) . ' . . ' . $dirmark .
60
61 # Link to username
62 $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ),
63 $result->img_user_text) . $dirmark .
64
65 # If there is a description, show it
66 $skin->commentBlock( $wgContLang->convert( $result->img_description ) );
67
68 return $return;
69 }
70
71 function getPageHeader() {
72 return wfMsg( "unusedimagestext" );
73 }
74
75 }
76
77 /**
78 * Entry point
79 */
80 function wfSpecialUnusedimages() {
81 list( $limit, $offset ) = wfCheckLimits();
82 $uip = new UnusedimagesPage();
83
84 return $uip->doQuery( $offset, $limit );
85 }
86 ?>