5 * @subpackage SpecialPage
11 function wfSpecialImagelist() {
12 global $wgUser, $wgOut, $wgLang, $wgContLang, $wgRequest;
14 $sort = $wgRequest->getVal( 'sort' );
15 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
16 $dbr =& wfGetDB( DB_SLAVE
);
17 $image = $dbr->tableName( 'image' );
18 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
19 "img_description,img_timestamp FROM $image";
21 $byname = wfMsg( "byname" );
22 $bydate = wfMsg( "bydate" );
23 $bysize = wfMsg( "bysize" );
25 if ( !empty( $wpIlMatch ) ) {
26 $nt = Title
::newFromUrl( $wpIlMatch );
28 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
29 $m = str_replace( "%", "\\%", $m );
30 $m = str_replace( "_", "\\_", $m );
31 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
34 if ( "bysize" == $sort ) {
35 $sql .= " ORDER BY img_size DESC";
37 } else if ( "byname" == $sort ) {
38 $sql .= " ORDER BY img_name";
42 $sql .= " ORDER BY img_timestamp DESC";
45 list( $limit, $offset ) = wfCheckLimits( 50 );
49 $lt = $wgLang->formatNum( "${limit}" );
50 $sql .= " LIMIT {$limit}";
52 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
54 $text = wfMsg( "imagelisttext",
55 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
56 $wgOut->addHTML( "<p>{$text}\n</p>" );
58 $sk = $wgUser->getSkin();
59 $cap = wfMsg( "ilshowmatch" );
60 $sub = wfMsg( "ilsubmit" );
61 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Imagelist" );
62 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
64 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
66 "{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"" .
67 htmlspecialchars( $wpIlMatch ) . "\" /> " .
68 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
69 $nums = array( 50, 100, 250, 500 );
70 $here = $wgContLang->specialPage( "Imagelist" );
74 foreach ( $nums as $num ) {
75 if ( ! $first ) { $fill .= " | "; }
78 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
79 "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
81 $text = wfMsg( "showlast", $fill, $byname );
82 $wgOut->addHTML( "<p>{$text}<br />\n" );
86 foreach ( $nums as $num ) {
87 if ( ! $first ) { $fill .= " | "; }
90 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
91 "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
93 $text = wfMsg( "showlast", $fill, $bysize );
94 $wgOut->addHTML( "{$text}<br />\n" );
98 foreach ( $nums as $num ) {
99 if ( ! $first ) { $fill .= " | "; }
102 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
103 "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
105 $text = wfMsg( "showlast", $fill, $bydate );
106 $wgOut->addHTML( "{$text}</p>\n<p>" );
108 $res = $dbr->query( $sql, "wfSpecialImagelist" );
109 while ( $s = $dbr->fetchObject( $res ) ) {
110 $name = $s->img_name
;
111 $ut = $s->img_user_text
;
112 if ( 0 == $s->img_user
) { $ul = $ut; }
113 else { $ul = $sk->makeLink( $wgContLang->getNsText(
114 Namespace::getUser() ) . ":{$ut}", $ut ); }
116 $ilink = "<a href=\"" . htmlspecialchars( Image
::wfImageUrl( $name ) ) .
117 "\">" . htmlspecialchars( $name ) . "</a>";
119 $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size
) );
121 $sk->makeKnownLink( $wgContLang->getNsText(
122 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
123 ") {$ilink} . . {$nb} . . {$ul} . . " .
124 $wgLang->timeanddate( $s->img_timestamp
, true );
126 if ( "" != $s->img_description
) {
127 $l .= ' <i>(' . $sk->formatComment( $s->img_description
) . ')</i>';
129 $wgOut->addHTML( "{$l}<br />\n" );
131 $wgOut->addHTML( "</p>" );
132 $dbr->freeResult( $res );