* Use a table to present file histories
authorRob Church <robchurch@users.mediawiki.org>
Sun, 29 Jul 2007 18:41:49 +0000 (18:41 +0000)
committerRob Church <robchurch@users.mediawiki.org>
Sun, 29 Jul 2007 18:41:49 +0000 (18:41 +0000)
* (bug 10741) Don't show deletion links for non-sysops [in file histories]

RELEASE-NOTES
includes/ImagePage.php
languages/messages/MessagesEn.php
maintenance/language/messages.inc
skins/common/shared.css
skins/monobook/main.css

index 695bb28..6f66fb7 100644 (file)
@@ -159,6 +159,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Skip the difference engine cache when 'action=purge' is used while requesting
   a difference page, to allow refreshing the cache in case of errors
 * (bug 10701) Link to Special:Listusers in default Special:Statistics messages
+* Improved file history presentation
 
 == Bugfixes since 1.10 ==
 
@@ -331,6 +332,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * Improved speed of file delete by storing the SHA-1 hash in image/oldimage
 * Fixed leading zero in base 36 SHA-1 hash
 * Protection form no longer produces JavaScript errors
+* (bug 10741) File histories show "delete" links for non-sysops
 
 == API changes since 1.10 ==
 
index 66e8ba6..aa6a971 100644 (file)
@@ -693,85 +693,105 @@ EOT
 }
 
 /**
- * @todo document
+ * Builds the image revision log shown on image pages
+ *
  * @addtogroup Media
  */
 class ImageHistoryList {
-       var $img, $skin;
-       function ImageHistoryList( $skin, $img ) {
+
+       protected $img, $skin, $title;
+
+       public function __construct( $skin, $img ) {
                $this->skin = $skin;
                $this->img = $img;
+               $this->title = $img->getTitle();
        }
 
-       function beginImageHistoryList() {
-               $s = "\n" .
-                       Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'imghistory' ) ) .
-                       "\n<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
-               return $s;
+       public function beginImageHistoryList() {
+               global $wgOut, $wgUser;
+               return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
+                       . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
+                       . Xml::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
+                       . '<tr><th></th>'
+                       . ( $this->img->isLocal() && $wgUser->isAllowed( 'delete' ) ? '<th></th>' : '' )
+                       . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
+                       . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
+                       . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
+                       . '<th>' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
+                       . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
+                       . "</tr>\n";
        }
 
-       function endImageHistoryList() {
-               $s = "</ul>\n";
-               return $s;
+       public function endImageHistoryList() {
+               return "</table>\n";
        }
 
-       function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
+       public function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
                global $wgUser, $wgLang, $wgTitle, $wgContLang;
-
-               $datetime = $wgLang->timeanddate( $timestamp, true );
-               $del = wfMsgHtml( 'deleteimg' );
-               $delall = wfMsgHtml( 'deleteimgcompletely' );
-               $cur = wfMsgHtml( 'cur' );
                $local = $this->img->isLocal();
-
-               if ( $iscur ) {
-                       $url = htmlspecialchars( $this->img->getURL() );
-                       $rlink = $cur;
-                       if ( $local && $wgUser->isAllowed('delete') ) {
-                               $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
-                                 '&action=delete' );
-                               $style = $this->skin->getInternalLinkAttributes( $link, $delall );
-
-                               $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
-                       } else {
-                               $dlink = $del;
-                       }
-               } else {
-                       $url = htmlspecialchars( $this->img->getArchiveUrl( $img ) );
-                       if( $local && $wgUser->getID() != 0 && $wgTitle->userCan( 'edit' ) ) {
-                               $token = urlencode( $wgUser->editToken( $img ) );
-                               $rlink = $this->skin->makeKnownLinkObj( $wgTitle,
-                                          wfMsgHtml( 'revertimg' ), 'action=revert&oldimage=' .
-                                          urlencode( $img ) . "&wpEditToken=$token" );
-                               $dlink = $this->skin->makeKnownLinkObj( $wgTitle,
-                                          $del, 'action=delete&oldimage=' . urlencode( $img ) .
-                                          "&wpEditToken=$token" );
-                       } else {
-                               # Having live active links for non-logged in users
-                               # means that bots and spiders crawling our site can
-                               # inadvertently change content. Baaaad idea.
-                               $rlink = wfMsgHtml( 'revertimg' );
-                               $dlink = $del;
-                       }
+               $row = '';
+               
+               // Deletion link
+               if( $local && $wgUser->isAllowed( 'delete' ) ) {
+                       $row .= '<td>';
+                       $q[] = 'action=delete';
+                       $q[] = ( $iscur ? 'image=' . $this->title->getPartialUrl() : 'oldimage=' . urlencode( $img ) );
+                       if( !$iscur )
+                               $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
+                       $row .= '(' . $this->skin->makeKnownLinkObj(
+                               $this->title,
+                               wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
+                               implode( '&', $q )
+                       ) . ')';
+                       $row .= '</td>';
                }
-
-               if ( $local ) {
-                       $userlink = $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext );
+               
+               // Reversion link/current indicator
+               $row .= '<td>';
+               if( $iscur ) {
+                       $row .= '(' . wfMsgHtml( 'filehist-current' ) . ')';
+               } elseif( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
+                       $q[] = 'action=revert';
+                       $q[] = 'oldimage=' . urlencode( $img );
+                       $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
+                       $row .= '(' . $this->skin->makeKnownLinkObj(
+                               $this->title,
+                               wfMsgHtml( 'filehist-revert' ),
+                               implode( '&', $q )
+                       ) . ')';
+               }
+               $row .= '</td>';
+               
+               // Date/time and image link
+               $row .= '<td>';
+               $url = $iscur ? $this->img->getUrl() : $this->img->getArchiveUrl( $img );
+               $row .= Xml::element(
+                       'a',
+                       array( 'href' => $url ),
+                       $wgLang->timeAndDate( $timestamp, true )
+               );
+               $row .= '</td>';
+               
+               // Uploading user
+               $row .= '<td>';
+               if( $local ) {
+                       $row .= $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext );
                } else {
-                       $userlink = htmlspecialchars( $usertext );
+                       $row .= htmlspecialchars( $usertext );
                }
-               $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
-                       $wgLang->formatNum( $size ) );
-               $widthheight = wfMsgHtml( 'widthheight', $width, $height );
-               $style = $this->skin->getInternalLinkAttributes( $url, $datetime );
-
-               $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userlink} . . {$widthheight} ({$nbytes})";
-
-               $s .= $this->skin->commentBlock( $description, $wgTitle );
-               $s .= "</li>\n";
-               return $s;
+               $row .= '</td>';
+               
+               // Image dimensions
+               // FIXME: What about sound files? Should have the duration instead...
+               $row .= '<td>' . wfMsgHtml( 'widthheight', $width, $height ) . '</td>';
+               
+               // File size
+               $row .= '<td>' . $this->skin->formatSize( $size ) . '</td>';
+               
+               // Comment
+               $row .= '<td>' . $this->skin->formatComment( $description, $this->title ) . '</td>';
+               
+               return "<tr>{$row}</tr>\n";
        }
-}
-
-
 
+}
\ No newline at end of file
index 139b3e4..b6bf8b4 100644 (file)
@@ -1439,14 +1439,17 @@ If you have this image in full resolution upload this one, otherwise change the
 'imgdelete'                 => 'del',
 'imgdesc'                   => 'desc',
 'imgfile'                   => 'file',
-'imglegend'                 => 'Legend: (desc) = show/edit file description.',
-'imghistory'                => 'File history',
-'revertimg'                 => 'rev',
-'deleteimg'                 => 'del',
-'deleteimgcompletely'       => 'Delete all revisions of this file',
-'imghistlegend'             => 'Legend: (cur) = this is the current file, (del) = delete
-this old version, (rev) = revert to this old version.
-<br /><i>Click on date to see the file uploaded on that date</i>.',
+'filehist' => 'File history',
+'filehist-help' => 'Click on a date/time to view the file as it appeared at that time.',
+'filehist-deleteall' => 'delete all',
+'filehist-deleteone' => 'delete this',
+'filehist-revert' => 'revert',
+'filehist-current' => 'current',
+'filehist-datetime' => 'Date/Time',
+'filehist-user' => 'User',
+'filehist-dimensions' => 'Dimensions',
+'filehist-filesize' => 'File size',
+'filehist-comment' => 'Comment',
 'imagelinks'                => 'Links',
 'linkstoimage'              => 'The following pages link to this file:',
 'nolinkstoimage'            => 'There are no pages that link to this file.',
index 5d763d9..4700bd3 100644 (file)
@@ -849,12 +849,17 @@ $wgMessageStructure = array(
                'imgdelete',
                'imgdesc',
                'imgfile',
-               'imglegend',
-               'imghistory',
-               'revertimg',
-               'deleteimg',
-               'deleteimgcompletely',
-               'imghistlegend',
+               'filehistory',
+               'filehist-help',
+               'filehist-deleteall',
+               'filehist-deleteone',
+               'filehist-revert',
+               'filehist-current',
+               'filehist-datetime',
+               'filehist-user',
+               'filehist-dimensions',
+               'filehist-filesize',
+               'filehist-comment',
                'imagelinks',
                'linkstoimage',
                'nolinkstoimage',
index dab7fac..063a4fe 100644 (file)
@@ -27,3 +27,14 @@ div#mw-js-message {
        float: right;
        margin-left: 5px;
 }
+
+/**
+ * File histories
+ */
+table.filehistory th,
+table.filehistory td {
+       padding: 0 0.15em 0 0.15em;
+}
+table.filehistory th {
+       text-align: left;
+}
\ No newline at end of file
index 50a3c0c..fe96599 100644 (file)
@@ -1585,3 +1585,19 @@ div#mw-recreate-deleted-warn ul li {
        vertical-align: middle;
        font-size: 90%;
 }
+
+/**
+ * File histories
+ */
+table.filehistory {
+       border-collapse: collapse;
+} 
+table.filehistory,
+table.filehistory th,
+table.filehistory td {
+       border: 1px solid #AAAAAA;
+}
+table.filehistory th,
+table.filehistory tr:hover td {
+       background-color: #EEEEFF;
+}
\ No newline at end of file