Index: trunk/phase3/includes/SpecialUnusedimages.php |
— | — | @@ -5,56 +5,65 @@ |
6 | 6 | * @subpackage SpecialPage |
7 | 7 | */ |
8 | 8 | |
| 9 | +/** */ |
| 10 | +require_once("QueryPage.php"); |
| 11 | + |
9 | 12 | /** |
10 | 13 | * |
11 | 14 | */ |
12 | | -function wfSpecialUnusedimages() { |
13 | | - global $wgUser, $wgOut, $wgLang, $wgTitle; |
14 | | - $fname = "wfSpecialUnusedimages"; |
| 15 | +class UnusedimagesPage extends QueryPage { |
15 | 16 | |
16 | | - list( $limit, $offset ) = wfCheckLimits(); |
17 | | - $dbr =& wfGetDB( DB_SLAVE ); |
18 | | - extract( $dbr->tableNames( 'image','imagelinks' ) ); |
| 17 | + function getName() { |
| 18 | + return 'Unusedimages'; |
| 19 | + } |
| 20 | + |
| 21 | + function sortDescending() { |
| 22 | + return false; |
| 23 | + } |
19 | 24 | |
20 | | - $sql = "SELECT img_name,img_user,img_user_text,img_timestamp,img_description " . |
21 | | - "FROM $image LEFT JOIN $imagelinks ON img_name=il_to WHERE il_to IS NULL " . |
22 | | - "ORDER BY img_timestamp ".$dbr->limitResult($limit,$offset); |
23 | | - $res = $dbr->query( $sql, $fname ); |
| 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; |
| 35 | + $title = Title::makeTitle( NS_IMAGE, $result->title ); |
| 36 | + $ins = $wgLang->getNsText(NS_IMAGE); |
| 37 | + |
| 38 | + $return = |
| 39 | + # The 'desc' linking to the image page |
| 40 | + '('.$skin->makeKnownLink( $ins.':'.$result->title, wfMsg('imgdesc') ).') ' |
| 41 | + # Link to the image itself |
| 42 | + . '<a href="'.Image::wfImageUrl($title->getText()).'">'.$title->getText().'</a>' |
| 43 | + # Last modified date |
| 44 | + . ' . . '.$wgLang->timeanddate($result->value) |
| 45 | + # Link to username |
| 46 | + . ' . . '.$skin->makeLink($wgLang->getNsText(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 .= ' <em>('.$result->img_description.')</em>'; |
| 51 | + } |
| 52 | + return $return; |
| 53 | + } |
| 54 | + |
| 55 | + function getPageHeader() { |
| 56 | + return wfMsg( "unusedimagestext" ); |
| 57 | + } |
24 | 58 | |
25 | | - $sk = $wgUser->getSkin(); |
| 59 | +} |
26 | 60 | |
27 | | - $wgOut->addHTML( wfMsg( "unusedimagestext" ) ); |
28 | | - $top = wfShowingResults( $offset, $limit ); |
29 | | - $wgOut->addHTML( "<p>{$top}\n" ); |
| 61 | +/** |
| 62 | + * Entry point |
| 63 | + */ |
| 64 | +function wfSpecialUnusedimages() { |
| 65 | + list( $limit, $offset ) = wfCheckLimits(); |
| 66 | + $uip = new UnusedimagesPage(); |
30 | 67 | |
31 | | - $sl = wfViewPrevNext( $offset, $limit, |
32 | | - $wgLang->specialPage( "Unusedimages" ) ); |
33 | | - $wgOut->addHTML( "<br />{$sl}</p>\n" ); |
34 | | - |
35 | | - $ins = $wgLang->getNsText ( 6 ) ; |
36 | | - $s = "<ol start='" . ( $offset + 1 ) . "'>"; |
37 | | - while ( $obj = $dbr->fetchObject( $res ) ) { |
38 | | - $name = $obj->img_name; |
39 | | - $dlink = $sk->makeKnownLink( "{$ins}:{$name}", wfMsg( "imgdesc" ) ); |
40 | | - $ilink = "<a href=\"" . Image::wfImageUrl( $name ) . "\">{$name}</a>"; |
41 | | - |
42 | | - $d = $wgLang->timeanddate( $obj->img_timestamp, true ); |
43 | | - $u = $obj->img_user; |
44 | | - $ut = $obj->img_user_text; |
45 | | - $c = $obj->img_description; |
46 | | - |
47 | | - if ( 0 == $u ) { $ul = $ut; } |
48 | | - else { $ul = $sk->makeLink( $wgLang->getNsText(2).":{$ut}", $ut ); } |
49 | | - |
50 | | - $s .= "<li>({$dlink}) {$ilink} . . {$d} . . {$ul}"; |
51 | | - |
52 | | - if ( "" != $c && "*" != $c ) { $s .= " <em>({$c})</em>"; } |
53 | | - $s .= "</li>\n"; |
54 | | - } |
55 | | - $dbr->freeResult( $res ); |
56 | | - $s .= "</ol>\n\n"; |
57 | | - $wgOut->addHTML( $s ); |
58 | | - $wgOut->addHTML( "<p>{$sl}</p>\n" ); |
| 68 | + return $uip->doQuery( $offset, $limit ); |
59 | 69 | } |
60 | | - |
61 | 70 | ?> |