Fix bug http://bugzilla.wikipedia.org/show_bug.cgi?id=705
[lhc/web/wiklou.git] / includes / SpecialUnusedimages.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8 /** */
9 require_once("QueryPage.php");
10
11 /**
12 *
13 */
14 class UnusedimagesPage extends QueryPage {
15
16 function getName() {
17 return 'Unusedimages';
18 }
19
20 function sortDescending() {
21 return false;
22 }
23 function isSyndicated() { return false; }
24
25 function getSQL() {
26 $dbr =& wfGetDB( DB_SLAVE );
27 extract( $dbr->tableNames( 'image','imagelinks' ) );
28
29 return 'SELECT img_name as title, img_user, img_user_text, img_timestamp as value, img_description' .
30 ' FROM '.$image.' LEFT JOIN '.$imagelinks.' ON img_name=il_to WHERE il_to IS NULL ';
31 }
32
33 function formatResult( $skin, $result ) {
34 global $wgLang, $wgContLang;
35 $title = Title::makeTitle( NS_IMAGE, $result->title );
36
37 $imageUrl = htmlspecialchars( Image::wfImageUrl( $result->title ) );
38 $return =
39 # The 'desc' linking to the image page
40 '('.$skin->makeKnownLinkObj( $title, wfMsg('imgdesc') ).') '
41 # Link to the image itself
42 . '<a href="' . $imageUrl . '">' . htmlspecialchars( $title->getText() ) . '</a>'
43 # Last modified date
44 . ' . . '.$wgLang->timeanddate($result->value)
45 # Link to username
46 . ' . . '.$skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ), $result->img_user_text);
47
48 # If there is a description, show it
49 if($result->img_description != '') {
50 $return .= ' <i>(' . $skin->formatComment( $result->img_description ) . ')</i>';
51 }
52 return $return;
53 }
54
55 function getPageHeader() {
56 return wfMsg( "unusedimagestext" );
57 }
58
59 }
60
61 /**
62 * Entry point
63 */
64 function wfSpecialUnusedimages() {
65 list( $limit, $offset ) = wfCheckLimits();
66 $uip = new UnusedimagesPage();
67
68 return $uip->doQuery( $offset, $limit );
69 }
70 ?>