Major update! Adding SpecialFilelist.php to replace both SpecialNewimages.php and...
[lhc/web/wiklou.git] / includes / SpecialImagelist.php
1 <?php
2 /**
3 *
4 * @package MediaWiki
5 * @subpackage SpecialPage
6 */
7
8
9 require_once ( "SpecialFilelist.php" ) ;
10
11 function wfSpecialImagelist( $par, $specialPage ) {
12 wfSpecialFilelist ( $par , $specialPage , false ) ;
13 }
14
15 # _____________________________________________
16 # The rest of this file is obsolete
17 # _____________________________________________
18
19
20 /**
21 *
22 */
23 function OLD_wfSpecialImagelist() {
24 global $wgUser, $wgOut, $wgLang, $wgRequest, $wgMiserMode;
25
26 $sort = $wgRequest->getVal( 'sort' );
27 $wpIlMatch = $wgRequest->getText( 'wpIlMatch' );
28 $dbr =& wfGetDB( DB_SLAVE );
29 $image = $dbr->tableName( 'image' );
30 $sql = "SELECT img_size,img_name,img_user,img_user_text," .
31 "img_description,img_timestamp FROM $image";
32
33 $byname = wfMsg( "byname" );
34 $bydate = wfMsg( "bydate" );
35 $bysize = wfMsg( "bysize" );
36
37 if ( !$wgMiserMode && !empty( $wpIlMatch ) ) {
38 $nt = Title::newFromUrl( $wpIlMatch );
39 if($nt ) {
40 $m = $dbr->strencode( strtolower( $nt->getDBkey() ) );
41 $m = str_replace( "%", "\\%", $m );
42 $m = str_replace( "_", "\\_", $m );
43 $sql .= " WHERE LCASE(img_name) LIKE '%{$m}%'";
44 }
45 }
46 if ( "bysize" == $sort ) {
47 $sql .= " ORDER BY img_size DESC";
48 $st = $bysize;
49 } else if ( "byname" == $sort ) {
50 $sql .= " ORDER BY img_name";
51 $st = $byname;
52 } else {
53 $sort = "bydate";
54 $sql .= " ORDER BY img_timestamp DESC";
55 $st = $bydate;
56 }
57 list( $limit, $offset ) = wfCheckLimits( 50 );
58 if ( 0 == $limit ) {
59 $lt = wfMsg( 'imagelistall' );
60 } else {
61 $lt = $wgLang->formatNum( "${limit}" );
62 $sql .= " LIMIT {$limit}";
63 }
64 $wgOut->addHTML( "<p>" . wfMsg( "imglegend" ) . "</p>\n" );
65
66 $text = wfMsg( "imagelisttext",
67 "<strong>{$lt}</strong>", "<strong>{$st}</strong>" );
68 $wgOut->addHTML( "<p>{$text}\n</p>" );
69
70 $sk = $wgUser->getSkin();
71 $sub = wfMsg( "ilsubmit" );
72 $titleObj = Title::makeTitle( NS_SPECIAL, "Imagelist" );
73 $action = $titleObj->escapeLocalURL( "sort={$sort}&limit={$limit}" );
74
75 if ( !$wgMiserMode ) {
76 $wgOut->addHTML( "<form id=\"imagesearch\" method=\"post\" action=\"" .
77 "{$action}\">" .
78 "<input type='text' size='20' name=\"wpIlMatch\" value=\"" .
79 htmlspecialchars( $wpIlMatch ) . "\" /> " .
80 "<input type='submit' name=\"wpIlSubmit\" value=\"{$sub}\" /></form>" );
81 }
82 $nums = array( 50, 100, 250, 500 );
83 $here = Title::makeTitle( NS_SPECIAL, 'Imagelist' );
84
85 $fill = "";
86 $first = true;
87 foreach ( $nums as $num ) {
88 if ( ! $first ) { $fill .= " | "; }
89 $first = false;
90
91 $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
92 "sort=byname&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
93 }
94 $text = wfMsg( "showlast", $fill, $byname );
95 $wgOut->addHTML( "<p>{$text}<br />\n" );
96
97 $fill = "";
98 $first = true;
99 foreach ( $nums as $num ) {
100 if ( ! $first ) { $fill .= " | "; }
101 $first = false;
102
103 $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
104 "sort=bysize&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
105 }
106 $text = wfMsg( "showlast", $fill, $bysize );
107 $wgOut->addHTML( "{$text}<br />\n" );
108
109 $fill = "";
110 $first = true;
111 foreach ( $nums as $num ) {
112 if ( ! $first ) { $fill .= " | "; }
113 $first = false;
114
115 $fill .= $sk->makeKnownLinkObj( $here, $wgLang->formatNum( $num ),
116 "sort=bydate&limit={$num}&wpIlMatch=" . urlencode( $wpIlMatch ) );
117 }
118 $text = wfMsg( "showlast", $fill, $bydate );
119 $wgOut->addHTML( "{$text}</p>\n<p>" );
120
121 $res = $dbr->query( $sql, "wfSpecialImagelist" );
122 while ( $s = $dbr->fetchObject( $res ) ) {
123 $name = $s->img_name;
124 $ut = $s->img_user_text;
125 if ( 0 == $s->img_user ) {
126 $ul = $ut;
127 } else {
128 $ul = $sk->makeLinkObj( Title::makeTitle( NS_USER, $ut ), $ut );
129 }
130
131 $ilink = "<a href=\"" . htmlspecialchars( Image::imageUrl( $name ) ) .
132 "\">" . strtr(htmlspecialchars( $name ), '_', ' ') . "</a>";
133
134 $nb = wfMsg( "nbytes", $wgLang->formatNum( $s->img_size ) );
135 $l = "(" .
136 $sk->makeKnownLinkObj( Title::makeTitle( NS_IMAGE, $name ),
137 wfMsg( "imgdesc" ) ) .
138 ") {$ilink} . . {$nb} . . {$ul} . . " .
139 $wgLang->timeanddate( $s->img_timestamp, true );
140
141 $l .= $sk->commentBlock( $s->img_description );
142 $wgOut->addHTML( "{$l}<br />\n" );
143 }
144 $wgOut->addHTML( "</p>" );
145 $dbr->freeResult( $res );
146 }
147
148 ?>