3 function wfSpecialImagelist()
5 global $wgUser, $wgOut, $wgLang, $sort;
6 global $wpIlMatch, $wpIlSubmit;
8 $fields = array( 'wpIlMatch' );
9 wfCleanFormFields( $fields );
11 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
12 "img_description,img_timestamp FROM image";
14 $byname = wfMsg( "byname" );
15 $bydate = wfMsg( "bydate" );
16 $bysize = wfMsg( "bysize" );
18 if ( "bysize" == $sort ) {
19 $sql .= " ORDER BY img_size DESC";
21 } else if ( "byname" == $sort ) {
23 $nt = Title
::newFromUrl( $wpIlMatch );
24 $m = wfStrencode( strtolower( $nt->getDBkey() ) );
25 $m = str_replace( "%", "\\%", $m );
26 $m = str_replace( "_", "\\_", $m );
27 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
29 $sql .= " ORDER BY img_name";
32 $sql .= " ORDER BY img_timestamp DESC";
35 list( $limit, $offset ) = wfCheckLimits( 50 );
40 $sql .= " LIMIT {$limit}";
42 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "\n" );
44 $text = wfMsg( "imagelisttext",
45 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
46 $wgOut->addHTML( "<p>{$text}\n<p>" );
48 $sk = $wgUser->getSkin();
49 $cap = wfMsg( "ilshowmatch" );
50 $sub = wfMsg( "ilsubmit" );
51 $action = wfLocalUrlE( $wgLang->specialPage( "Imagelist" ),
52 "sort=byname&limit={$limit}" );
54 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
56 "{$cap}: <input type=text size=8 name=\"wpIlMatch\" value=\"\"> " .
57 "<input type=submit name=\"wpIlSubmit\" value=\"{$sub}\"></form>" );
59 $nums = array( 50, 100, 250, 500 );
60 $here = $wgLang->specialPage( "Imagelist" );
64 foreach ( $nums as $num ) {
65 if ( ! $first ) { $fill .= " | "; }
68 $fill .= $sk->makeKnownLink( $here, "{$num}",
69 "sort=bysize&limit={$num}" );
71 $text = str_replace( "$1", $fill, wfMsg( "showlast" ) );
72 $text = str_replace( "$2", $bysize, $text );
73 $wgOut->addHTML( "{$text}<br>\n" );
77 foreach ( $nums as $num ) {
78 if ( ! $first ) { $fill .= " | "; }
81 $fill .= $sk->makeKnownLink( $here, $num,
82 "sort=bydate&limit={$num}" );
84 $text = str_replace( "$1", $fill, wfMsg( "showlast" ) );
85 $text = str_replace( "$2", $bydate, $text );
86 $wgOut->addHTML( "{$text}<br>\n<p>" );
88 $res = wfQuery( $sql, "wfSpecialImagelist" );
89 while ( $s = wfFetchObject( $res ) ) {
91 $ut = $s->img_user_text
;
92 if ( 0 == $s->img_user
) { $ul = $ut; }
93 else { $ul = $sk->makeLink( $wgLang->getNsText(
94 Namespace::getUser() ) . ":{$ut}", $ut ); }
96 $ilink = "<a href=\"" . wfImageUrl( $name ) .
99 $nb = str_replace( "$1", $s->img_size
, wfMsg( "nbytes" ) );
101 $sk->makeKnownLink( $wgLang->getNsText(
102 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
103 ") {$ilink} . . {$nb} . . {$ul} . . " .
104 $wgLang->timeanddate( $s->img_timestamp
, true );
106 if ( "" != $s->img_description
) {
107 $l .= " <em>({$s->img_description})</em>";
109 $wgOut->addHTML( "{$l}<br>\n" );
111 wfFreeResult( $res );