* Reverting BiDi changes because there were some problems left
[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 * @package MediaWiki
13 * @subpackage SpecialPage
14 */
15 class UnusedimagesPage extends QueryPage {
16
17 function getName() {
18 return 'Unusedimages';
19 }
20
21 function sortDescending() {
22 return false;
23 }
24 function isSyndicated() { return false; }
25
26 function getSQL() {
27 global $wgCountCategorizedImagesAsUsed;
28 $dbr =& wfGetDB( DB_SLAVE );
29
30 if ( $wgCountCategorizedImagesAsUsed ) {
31 extract( $dbr->tableNames( 'page', 'image', 'imagelinks', 'categorylinks' ) );
32
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';
38 } else {
39 extract( $dbr->tableNames( 'image','imagelinks' ) );
40
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 ';
43 }
44 }
45
46 function formatResult( $skin, $result ) {
47 global $wgLang, $wgContLang;
48 $title = Title::makeTitle( NS_IMAGE, $result->title );
49
50 $imageUrl = htmlspecialchars( Image::imageUrl( $result->title ) );
51 $dirmark = $wgContLang->getDirMark(); // To keep text in correct order
52
53 $return =
54 # The 'desc' linking to the image page
55 '('.$skin->makeKnownLinkObj( $title, wfMsg('imgdesc') ).') ' . $dirmark .
56
57 # Link to the image itself
58 '<a href="' . $imageUrl . '">' . htmlspecialchars( $title->getText() ) .
59 '</a> . . ' . $dirmark .
60
61 # Last modified date
62 $wgLang->timeanddate($result->value) . ' . . ' . $dirmark .
63
64 # Link to username
65 $skin->makeLinkObj( Title::makeTitle( NS_USER, $result->img_user_text ),
66 $result->img_user_text) . $dirmark .
67
68 # If there is a description, show it
69 $skin->commentBlock( $wgContLang->convert( $result->img_description ) );
70
71 return $return;
72 }
73
74 function getPageHeader() {
75 return wfMsg( "unusedimagestext" );
76 }
77
78 }
79
80 /**
81 * Entry point
82 */
83 function wfSpecialUnusedimages() {
84 list( $limit, $offset ) = wfCheckLimits();
85 $uip = new UnusedimagesPage();
86
87 return $uip->doQuery( $offset, $limit );
88 }
89 ?>