9 function wfSpecialImagelist() {
10 global $wgUser, $wgOut, $wgLang, $wgRequest;
12 $sort = $wgRequest->getVal( 'sort' );
13 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
14 $dbr =& wfGetDB( DB_SLAVE
);
15 $image = $dbr->tableName( 'image' );
16 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
17 "img_description,img_timestamp FROM $image";
19 $byname = wfMsg( "byname" );
20 $bydate = wfMsg( "bydate" );
21 $bysize = wfMsg( "bysize" );
23 if ( !empty( $wpIlMatch ) ) {
24 $nt = Title
::newFromUrl( $wpIlMatch );
26 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
27 $m = str_replace( "%", "\\%", $m );
28 $m = str_replace( "_", "\\_", $m );
29 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
32 if ( "bysize" == $sort ) {
33 $sql .= " ORDER BY img_size DESC";
35 } else if ( "byname" == $sort ) {
36 $sql .= " ORDER BY img_name";
40 $sql .= " ORDER BY img_timestamp DESC";
43 list( $limit, $offset ) = wfCheckLimits( 50 );
47 $lt = $wgLang->formatNum( "${limit}" );
48 $sql .= " LIMIT {$limit}";
50 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
52 $text = wfMsg( "imagelisttext",
53 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
54 $wgOut->addHTML( "<p>{$text}\n</p>" );
56 $sk = $wgUser->getSkin();
57 $cap = wfMsg( "ilshowmatch" );
58 $sub = wfMsg( "ilsubmit" );
59 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Imagelist" );
60 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
62 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
64 "{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"" .
65 htmlspecialchars( $wpIlMatch ) . "\" /> " .
66 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
67 $nums = array( 50, 100, 250, 500 );
68 $here = $wgLang->specialPage( "Imagelist" );
72 foreach ( $nums as $num ) {
73 if ( ! $first ) { $fill .= " | "; }
76 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
77 "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
79 $text = wfMsg( "showlast", $fill, $byname );
80 $wgOut->addHTML( "<p>{$text}<br />\n" );
84 foreach ( $nums as $num ) {
85 if ( ! $first ) { $fill .= " | "; }
88 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
89 "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
91 $text = wfMsg( "showlast", $fill, $bysize );
92 $wgOut->addHTML( "{$text}<br />\n" );
96 foreach ( $nums as $num ) {
97 if ( ! $first ) { $fill .= " | "; }
100 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
101 "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
103 $text = wfMsg( "showlast", $fill, $bydate );
104 $wgOut->addHTML( "{$text}</p>\n<p>" );
106 $res = $dbr->query( $sql, "wfSpecialImagelist" );
107 while ( $s = $dbr->fetchObject( $res ) ) {
108 $name = $s->img_name
;
109 $ut = $s->img_user_text
;
110 if ( 0 == $s->img_user
) { $ul = $ut; }
111 else { $ul = $sk->makeLink( $wgLang->getNsText(
112 Namespace::getUser() ) . ":{$ut}", $ut ); }
114 $ilink = "<a href=\"" . Image
::wfImageUrl( $name ) .
117 $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size
) );
119 $sk->makeKnownLink( $wgLang->getNsText(
120 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
121 ") {$ilink} . . {$nb} . . {$ul} . . " .
122 $wgLang->timeanddate( $s->img_timestamp
, true );
124 if ( "" != $s->img_description
) {
125 $l .= " <em>({$s->img_description})</em>";
127 $wgOut->addHTML( "{$l}<br />\n" );
129 $wgOut->addHTML( "</p>" );
130 $dbr->freeResult( $res );