r49942 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r49941‎ | r49942 | r49943 >
Date:11:18, 27 April 2009
Author:nikerabbit
Status:ok
Tags:
Comment:
And some cleanup for image page
Modified paths:
  • /trunk/phase3/includes/ImagePage.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/ImagePage.php
@@ -780,9 +780,7 @@
781781 $img = $iscur ? $file->getName() : $file->getArchiveName();
782782 $user = $file->getUser('id');
783783 $usertext = $file->getUser('text');
784 - $size = $file->getSize();
785784 $description = $file->getDescription();
786 - $dims = $file->getDimensionsString();
787785 $sha1 = $file->getSha1();
788786
789787 $local = $this->current->isLocal();
@@ -868,35 +866,19 @@
869867 $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl( $img );
870868 $row .= Xml::element( 'a', array( 'href' => $url ), $wgLang->timeAndDate( $timestamp, true ) );
871869 }
 870+ $row .= "</td>";
872871
873872 // Thumbnail
874 - if( $file->isMissing() ) {
875 - $row .= '</td><td><strong class="error">' . wfMsgHtml( 'filehist-missing' ) . '</strong>';
876 - } elseif( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
877 - $params = array(
878 - 'width' => '120',
879 - 'height' => '120',
880 - );
881 - $thumbnail = $file->transform( $params );
882 - $options = array(
883 - 'alt' => wfMsg( 'filehist-thumbtext', $wgLang->timeAndDate( $timestamp, true ) ),
884 - 'file-link' => true,
885 - );
886 - $row .= '</td><td>' . ( $thumbnail ? $thumbnail->toHtml( $options ) :
887 - wfMsgHtml( 'filehist-nothumb' ) );
888 - } else {
889 - $row .= '</td><td>' . wfMsgHtml( 'filehist-nothumb' );
890 - }
891 - $row .= "</td><td>";
 873+ $row .= '<td>' . $this->getThumbForLine( $file ) . '</td>';
892874
893 - // Image dimensions
894 - $row .= htmlspecialchars( $dims );
 875+ // Image dimensions + size
 876+ $row .= '<td>';
 877+ $row .= htmlspecialchars( $file->getDimensionsString() );
 878+ $row .= " <span style='white-space: nowrap;'>(" . $this->skin->formatSize( $file->getSize() ) . ')</span>';
 879+ $row .= '</td>';
895880
896 - // File size
897 - $row .= " <span style='white-space: nowrap;'>(" . $this->skin->formatSize( $size ) . ')</span>';
898 -
899881 // Uploading user
900 - $row .= '</td><td>';
 882+ $row .= '<td>';
901883 if( $local ) {
902884 // Hide deleted usernames
903885 if( $file->isDeleted(File::DELETED_USER) ) {
@@ -923,6 +905,32 @@
924906
925907 return "<tr{$classAttr}>{$row}</tr>\n";
926908 }
 909+
 910+ protected function getThumbForLine( $file ) {
 911+ global $wgLang;
 912+
 913+ if( $file->isMissing() ) {
 914+ return '<strong class="error">' . wfMsgHtml( 'filehist-missing' ) . '</strong>';
 915+ } elseif( $file->allowInlineDisplay() && $file->userCan( File::DELETED_FILE ) && !$file->isDeleted( File::DELETED_FILE ) ) {
 916+ $params = array(
 917+ 'width' => '120',
 918+ 'height' => '120',
 919+ );
 920+ $timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
 921+
 922+ $thumbnail = $file->transform( $params );
 923+ $options = array(
 924+ 'alt' => wfMsg( 'filehist-thumbtext', $wgLang->timeAndDate( $timestamp, true ) ),
 925+ 'file-link' => true,
 926+ );
 927+
 928+ if ( !$thumbnail ) return wfMsgHtml( 'filehist-nothumb' );
 929+
 930+ return $thumbnail->toHtml( $options );
 931+ } else {
 932+ return wfMsgHtml( 'filehist-nothumb' );
 933+ }
 934+ }
927935 }
928936
929937 class ImageHistoryPseudoPager extends ReverseChronologicalPager {
@@ -958,12 +966,7 @@
959967 if( count($this->mHist) ) {
960968 $list = new ImageHistoryList( $this->mImagePage );
961969 # Generate prev/next links
962 - $navLink = '';
963 -
964 - # Only add navigation links when needed
965 - if ( !$this->mIsFirst && !$this->mIsLast ) {
966 - $navLink = $this->getNavigationBar();
967 - }
 970+ $navLink = $this->getNavigationBar();
968971 $s = $list->beginImageHistoryList($navLink);
969972 // Skip rows there just for paging links
970973 for( $i = $this->mRange[0]; $i <= $this->mRange[1]; $i++ ) {

Status & tagging log