3 function wfSpecialImagelist()
5 global $wgUser, $wgOut, $wgLang, $wgRequest;
7 $sort = $wgRequest->getVal( 'sort' );
8 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
10 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
11 "img_description,img_timestamp FROM image";
13 $byname = wfMsg( "byname" );
14 $bydate = wfMsg( "bydate" );
15 $bysize = wfMsg( "bysize" );
17 if ( "bysize" == $sort ) {
18 $sql .= " ORDER BY img_size DESC";
20 } else if ( "byname" == $sort ) {
22 $nt = Title
::newFromUrl( $wpIlMatch );
23 $m = wfStrencode( strtolower( $nt->getDBkey() ) );
24 $m = str_replace( "%", "\\%", $m );
25 $m = str_replace( "_", "\\_", $m );
26 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
28 $sql .= " ORDER BY img_name";
31 $sql .= " ORDER BY img_timestamp DESC";
34 list( $limit, $offset ) = wfCheckLimits( 50 );
38 $lt = $wgLang->formatNum( "${limit}" );
39 $sql .= " LIMIT {$limit}";
41 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
43 $text = wfMsg( "imagelisttext",
44 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
45 $wgOut->addHTML( "<p>{$text}\n</p>" );
47 $sk = $wgUser->getSkin();
48 $cap = wfMsg( "ilshowmatch" );
49 $sub = wfMsg( "ilsubmit" );
50 $titleObj = Title
::makeTitle( NS_SPECIAL
, "Imagelist" );
51 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
53 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
55 "{$cap}: <input type='text' size='8' name=\"wpIlMatch\" value=\"\" /> " .
56 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
57 $nums = array( 50, 100, 250, 500 );
58 $here = $wgLang->specialPage( "Imagelist" );
62 foreach ( $nums as $num ) {
63 if ( ! $first ) { $fill .= " | "; }
66 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
67 "sort=byname&limit={$num}&wpIlMatch={$wpIlMatch}" );
69 $text = wfMsg( "showlast", $fill, $byname );
70 $wgOut->addHTML( "<p>{$text}<br />\n" );
74 foreach ( $nums as $num ) {
75 if ( ! $first ) { $fill .= " | "; }
78 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
79 "sort=bysize&limit={$num}&wpIlMatch={$wpIlMatch}" );
81 $text = wfMsg( "showlast", $fill, $bysize );
82 $wgOut->addHTML( "{$text}<br />\n" );
86 foreach ( $nums as $num ) {
87 if ( ! $first ) { $fill .= " | "; }
90 $fill .= $sk->makeKnownLink( $here, $wgLang->formatNum( $num ),
91 "sort=bydate&limit={$num}&wpIlMatch={$wpIlMatch}" );
93 $text = wfMsg( "showlast", $fill, $bydate );
94 $wgOut->addHTML( "{$text}</p>\n<p>" );
96 $res = wfQuery( $sql, DB_READ
, "wfSpecialImagelist" );
97 while ( $s = wfFetchObject( $res ) ) {
99 $ut = $s->img_user_text
;
100 if ( 0 == $s->img_user
) { $ul = $ut; }
101 else { $ul = $sk->makeLink( $wgLang->getNsText(
102 Namespace::getUser() ) . ":{$ut}", $ut ); }
104 $ilink = "<a href=\"" . Image
::wfImageUrl( $name ) .
107 $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size
) );
109 $sk->makeKnownLink( $wgLang->getNsText(
110 Namespace::getImage() ) . ":{$name}", wfMsg( "imgdesc" ) ) .
111 ") {$ilink} . . {$nb} . . {$ul} . . " .
112 $wgLang->timeanddate( $s->img_timestamp
, true );
114 if ( "" != $s->img_description
) {
115 $l .= " <em>({$s->img_description})</em>";
117 $wgOut->addHTML( "{$l}<br />\n" );
119 $wgOut->addHTML( "</p>" );
120 wfFreeResult( $res );