3 function wfSpecialImagelist()
5 global $wgUser, $wgOut, $wgLang, $sort;
6 global $wpIlMatch, $wpIlSubmit;
7 $sort = $_REQUEST['sort'];
8 $wpIlMatch = $_REQUEST["wpIlMatch"];
9 $wpIlSubmit = $_REQUEST["wpIlSubmit"];
11 $fields = array( 'wpIlMatch' );
12 wfCleanFormFields( $fields );
14 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
15 "img_description,img_timestamp FROM image";
17 $byname = wfMsg( "byname" );
18 $bydate = wfMsg( "bydate" );
19 $bysize = wfMsg( "bysize" );
21 if ( "bysize" == $sort ) {
22 $sql .= " ORDER BY img_size DESC";
24 } else if ( "byname" == $sort ) {
26 $nt = Title
::newFromUrl( $wpIlMatch );
27 $m = wfStrencode( strtolower( $nt->getDBkey() ) );
28 $m = str_replace( "%", "\\%", $m );
29 $m = str_replace( "_", "\\_", $m );
30 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
32 $sql .= " ORDER BY img_name";
35 $sql .= " ORDER BY img_timestamp DESC";
38 list( $limit, $offset ) = wfCheckLimits( 50 );
43 $sql .= " LIMIT {$limit}";
45 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "\n" );
47 $text = wfMsg( "imagelisttext",
48 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
49 $wgOut->addHTML( "<p>{$text}\n<p>" );
51 $sk = $wgUser->getSkin();
52 $cap = wfMsg( "ilshowmatch" );
53 $sub = wfMsg( "ilsubmit" );
54 $action = wfLocalUrlE( $wgLang->specialPage( "Imagelist" ),
55 "sort=byname&limit={$limit}" );
57 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
59 "{$cap}: <input type=text size=8 name=\"wpIlMatch\" value=\"\"> " .
60 "<input type=submit name=\"wpIlSubmit\" value=\"{$sub}\"></form>" );
62 $nums = array( 50, 100, 250, 500 );
63 $here = $wgLang->specialPage( "Imagelist" );
67 foreach ( $nums as $num ) {
68 if ( ! $first ) { $fill .= " | "; }
71 $fill .= $sk->makeKnownLink( $here, "{$num}",
72 "sort=bysize&limit={$num}" );
74 $text = wfMsg( "showlast", $fill, $bysize );
75 $wgOut->addHTML( "{$text}<br>\n" );
79 foreach ( $nums as $num ) {
80 if ( ! $first ) { $fill .= " | "; }
83 $fill .= $sk->makeKnownLink( $here, $num,
84 "sort=bydate&limit={$num}" );
86 $text = wfMsg( "showlast", $fill, $bydate );
87 $wgOut->addHTML( "{$text}<br>\n<p>" );
89 $res = wfQuery( $sql, DB_READ
, "wfSpecialImagelist" );
90 while ( $s = wfFetchObject( $res ) ) {
92 $ut = $s->img_user_text
;
93 if ( 0 == $s->img_user
) { $ul = $ut; }
94 else { $ul = $sk->makeLink( $wgLang->getNsText(
95 Namespace::getUser() ) . ":{$ut}", $ut ); }
97 $ilink = "<a href=\"" . wfImageUrl( $name ) .
100 $nb = wfMsg( "nbytes", $s->img_size
);
102 $sk->makeKnownLink( $wgLang->getNsText(
103 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
104 ") {$ilink} . . {$nb} . . {$ul} . . " .
105 $wgLang->timeanddate( $s->img_timestamp
, true );
107 if ( "" != $s->img_description
) {
108 $l .= " <em>({$s->img_description})</em>";
110 $wgOut->addHTML( "{$l}<br>\n" );
112 wfFreeResult( $res );