r75582 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r75581‎ | r75582 | r75583 >
Date:21:02, 27 October 2010
Author:btongminh
Status:ok (Comments)
Tags:
Comment:
(bug 23194) Special:ListFiles now has thumbnails
Added new message listfiles_thumb
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/specials/SpecialListfiles.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -1354,6 +1354,7 @@
13551355 'listfiles_search_for',
13561356 'imgfile',
13571357 'listfiles',
 1358+ 'listfiles_thumbnail',
13581359 'listfiles_date',
13591360 'listfiles_name',
13601361 'listfiles_user',
Index: trunk/phase3/includes/specials/SpecialListfiles.php
@@ -74,6 +74,7 @@
7575 if ( !$this->mFieldNames ) {
7676 global $wgMiserMode;
7777 $this->mFieldNames = array(
 78+ 'thumb' => wfMsg( 'listfiles_thumb' ),
7879 'img_timestamp' => wfMsg( 'listfiles_date' ),
7980 'img_name' => wfMsg( 'listfiles_name' ),
8081 'img_user_text' => wfMsg( 'listfiles_user' ),
@@ -100,6 +101,7 @@
101102 $tables = array( 'image' );
102103 $fields = array_keys( $this->getFieldNames() );
103104 $fields[] = 'img_user';
 105+ $fields[array_search('thumb', $fields)] = 'img_name as thumb';
104106 $options = $join_conds = array();
105107
106108 # Depends on $wgMiserMode
@@ -107,9 +109,11 @@
108110 $tables[] = 'oldimage';
109111
110112 # Need to rewrite this one
111 - foreach ( $fields as &$field )
112 - if ( $field == 'count' )
 113+ foreach ( $fields as &$field ) {
 114+ if ( $field == 'count' ) {
113115 $field = 'COUNT(oi_archive_name) as count';
 116+ }
 117+ }
114118 unset( $field );
115119
116120 $dbr = wfGetDB( DB_SLAVE );
@@ -153,6 +157,10 @@
154158 function formatValue( $field, $value ) {
155159 global $wgLang;
156160 switch ( $field ) {
 161+ case 'thumb':
 162+ $file = wfLocalFile( $value );
 163+ $thumb = $file->transform( array( 'width' => 180 ) );
 164+ return $thumb->toHtml( array( 'desc-link' => true ) );
157165 case 'img_timestamp':
158166 return htmlspecialchars( $wgLang->timeanddate( $value, true ) );
159167 case 'img_name':
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -2258,6 +2258,7 @@
22592259 'listfiles_search_for' => 'Search for media name:',
22602260 'imgfile' => 'file',
22612261 'listfiles' => 'File list',
 2262+'listfiles_thumb' => 'Thumbnail',
22622263 'listfiles_date' => 'Date',
22632264 'listfiles_name' => 'Name',
22642265 'listfiles_user' => 'User',
Index: trunk/phase3/RELEASE-NOTES
@@ -185,6 +185,7 @@
186186 * Maintenance scripts get a --memory-limit option to override defaults (which
187187 is usually to set it to -1 to disable the limit)
188188 * (bug 25397) Allow uploading (not displaying) of WebP images, disabled by default
 189+* (bug 23194) Special:ListFiles now has thumbnails
189190
190191 === Bug fixes in 1.17 ===
191192 * (bug 17560) Half-broken deletion moved image files to deletion archive

Follow-up revisions

RevisionCommit summaryAuthorDate
r75623Follow-up r75582: Fix wrong message key in maintenance scriptraymond19:49, 28 October 2010

Comments

#Comment by Nikerabbit (talk | contribs)   21:08, 27 October 2010

Yay. I think this is a good addition and is towards making Special:NewFiles obsolete. It makes the table a bit crowded though (it already was).

What I don't understand is why you are renaming img_thumb to thumb?

#Comment by Bryan (talk | contribs)   21:12, 27 October 2010

It basically is a fake table column. The way Special:Listfiles and the underlying TablePager works, is that each column in the HTML table should correspond to a column in the database table. formatValue() will be called for each field, and only with the current field. For a thumbnail we need to know img_name, and as such we need a hack to rename thumb to thumb as img_name.

The table could use a UI designer indeed.

Also I was thinking that this page should be listed in the top navigation bar next to "my contributions" as "my uploads"

#Comment by Nikerabbit (talk | contribs)   21:19, 27 October 2010

That explains it indeed.

I'm not sure if new top-level item is the best option, maybe it should be integrated to my contributions in some way or another.

Status & tagging log