r24432 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24431‎ | r24432 | r24433 >
Date:18:41, 29 July 2007
Author:robchurch
Status:old
Tags:
Comment:
* Use a table to present file histories
* (bug 10741) Don't show deletion links for non-sysops [in file histories]
Modified paths:
  • /trunk/phase3/RELEASE-NOTES (modified) (history)
  • /trunk/phase3/includes/ImagePage.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)
  • /trunk/phase3/maintenance/language/messages.inc (modified) (history)
  • /trunk/phase3/skins/common/shared.css (modified) (history)
  • /trunk/phase3/skins/monobook/main.css (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/language/messages.inc
@@ -849,12 +849,17 @@
850850 'imgdelete',
851851 'imgdesc',
852852 'imgfile',
853 - 'imglegend',
854 - 'imghistory',
855 - 'revertimg',
856 - 'deleteimg',
857 - 'deleteimgcompletely',
858 - 'imghistlegend',
 853+ 'filehistory',
 854+ 'filehist-help',
 855+ 'filehist-deleteall',
 856+ 'filehist-deleteone',
 857+ 'filehist-revert',
 858+ 'filehist-current',
 859+ 'filehist-datetime',
 860+ 'filehist-user',
 861+ 'filehist-dimensions',
 862+ 'filehist-filesize',
 863+ 'filehist-comment',
859864 'imagelinks',
860865 'linkstoimage',
861866 'nolinkstoimage',
Index: trunk/phase3/skins/monobook/main.css
@@ -1585,3 +1585,19 @@
15861586 vertical-align: middle;
15871587 font-size: 90%;
15881588 }
 1589+
 1590+/**
 1591+ * File histories
 1592+ */
 1593+table.filehistory {
 1594+ border-collapse: collapse;
 1595+}
 1596+table.filehistory,
 1597+table.filehistory th,
 1598+table.filehistory td {
 1599+ border: 1px solid #AAAAAA;
 1600+}
 1601+table.filehistory th,
 1602+table.filehistory tr:hover td {
 1603+ background-color: #EEEEFF;
 1604+}
\ No newline at end of file
Index: trunk/phase3/skins/common/shared.css
@@ -27,3 +27,14 @@
2828 float: right;
2929 margin-left: 5px;
3030 }
 31+
 32+/**
 33+ * File histories
 34+ */
 35+table.filehistory th,
 36+table.filehistory td {
 37+ padding: 0 0.15em 0 0.15em;
 38+}
 39+table.filehistory th {
 40+ text-align: left;
 41+}
\ No newline at end of file
Index: trunk/phase3/includes/ImagePage.php
@@ -693,85 +693,105 @@
694694 }
695695
696696 /**
697 - * @todo document
 697+ * Builds the image revision log shown on image pages
 698+ *
698699 * @addtogroup Media
699700 */
700701 class ImageHistoryList {
701 - var $img, $skin;
702 - function ImageHistoryList( $skin, $img ) {
 702+
 703+ protected $img, $skin, $title;
 704+
 705+ public function __construct( $skin, $img ) {
703706 $this->skin = $skin;
704707 $this->img = $img;
 708+ $this->title = $img->getTitle();
705709 }
706710
707 - function beginImageHistoryList() {
708 - $s = "\n" .
709 - Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'imghistory' ) ) .
710 - "\n<p>" . wfMsg( 'imghistlegend' ) . "</p>\n".'<ul class="special">';
711 - return $s;
 711+ public function beginImageHistoryList() {
 712+ global $wgOut, $wgUser;
 713+ return Xml::element( 'h2', array( 'id' => 'filehistory' ), wfMsg( 'filehist' ) )
 714+ . $wgOut->parse( wfMsgNoTrans( 'filehist-help' ) )
 715+ . Xml::openElement( 'table', array( 'class' => 'filehistory' ) ) . "\n"
 716+ . '<tr><th></th>'
 717+ . ( $this->img->isLocal() && $wgUser->isAllowed( 'delete' ) ? '<th></th>' : '' )
 718+ . '<th>' . wfMsgHtml( 'filehist-datetime' ) . '</th>'
 719+ . '<th>' . wfMsgHtml( 'filehist-user' ) . '</th>'
 720+ . '<th>' . wfMsgHtml( 'filehist-dimensions' ) . '</th>'
 721+ . '<th>' . wfMsgHtml( 'filehist-filesize' ) . '</th>'
 722+ . '<th>' . wfMsgHtml( 'filehist-comment' ) . '</th>'
 723+ . "</tr>\n";
712724 }
713725
714 - function endImageHistoryList() {
715 - $s = "</ul>\n";
716 - return $s;
 726+ public function endImageHistoryList() {
 727+ return "</table>\n";
717728 }
718729
719 - function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
 730+ public function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $width, $height ) {
720731 global $wgUser, $wgLang, $wgTitle, $wgContLang;
721 -
722 - $datetime = $wgLang->timeanddate( $timestamp, true );
723 - $del = wfMsgHtml( 'deleteimg' );
724 - $delall = wfMsgHtml( 'deleteimgcompletely' );
725 - $cur = wfMsgHtml( 'cur' );
726732 $local = $this->img->isLocal();
727 -
728 - if ( $iscur ) {
729 - $url = htmlspecialchars( $this->img->getURL() );
730 - $rlink = $cur;
731 - if ( $local && $wgUser->isAllowed('delete') ) {
732 - $link = $wgTitle->escapeLocalURL( 'image=' . $wgTitle->getPartialURL() .
733 - '&action=delete' );
734 - $style = $this->skin->getInternalLinkAttributes( $link, $delall );
735 -
736 - $dlink = '<a href="'.$link.'"'.$style.'>'.$delall.'</a>';
737 - } else {
738 - $dlink = $del;
739 - }
740 - } else {
741 - $url = htmlspecialchars( $this->img->getArchiveUrl( $img ) );
742 - if( $local && $wgUser->getID() != 0 && $wgTitle->userCan( 'edit' ) ) {
743 - $token = urlencode( $wgUser->editToken( $img ) );
744 - $rlink = $this->skin->makeKnownLinkObj( $wgTitle,
745 - wfMsgHtml( 'revertimg' ), 'action=revert&oldimage=' .
746 - urlencode( $img ) . "&wpEditToken=$token" );
747 - $dlink = $this->skin->makeKnownLinkObj( $wgTitle,
748 - $del, 'action=delete&oldimage=' . urlencode( $img ) .
749 - "&wpEditToken=$token" );
750 - } else {
751 - # Having live active links for non-logged in users
752 - # means that bots and spiders crawling our site can
753 - # inadvertently change content. Baaaad idea.
754 - $rlink = wfMsgHtml( 'revertimg' );
755 - $dlink = $del;
756 - }
 733+ $row = '';
 734+
 735+ // Deletion link
 736+ if( $local && $wgUser->isAllowed( 'delete' ) ) {
 737+ $row .= '<td>';
 738+ $q[] = 'action=delete';
 739+ $q[] = ( $iscur ? 'image=' . $this->title->getPartialUrl() : 'oldimage=' . urlencode( $img ) );
 740+ if( !$iscur )
 741+ $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
 742+ $row .= '(' . $this->skin->makeKnownLinkObj(
 743+ $this->title,
 744+ wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
 745+ implode( '&', $q )
 746+ ) . ')';
 747+ $row .= '</td>';
757748 }
758 -
759 - if ( $local ) {
760 - $userlink = $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext );
 749+
 750+ // Reversion link/current indicator
 751+ $row .= '<td>';
 752+ if( $iscur ) {
 753+ $row .= '(' . wfMsgHtml( 'filehist-current' ) . ')';
 754+ } elseif( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
 755+ $q[] = 'action=revert';
 756+ $q[] = 'oldimage=' . urlencode( $img );
 757+ $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
 758+ $row .= '(' . $this->skin->makeKnownLinkObj(
 759+ $this->title,
 760+ wfMsgHtml( 'filehist-revert' ),
 761+ implode( '&', $q )
 762+ ) . ')';
 763+ }
 764+ $row .= '</td>';
 765+
 766+ // Date/time and image link
 767+ $row .= '<td>';
 768+ $url = $iscur ? $this->img->getUrl() : $this->img->getArchiveUrl( $img );
 769+ $row .= Xml::element(
 770+ 'a',
 771+ array( 'href' => $url ),
 772+ $wgLang->timeAndDate( $timestamp, true )
 773+ );
 774+ $row .= '</td>';
 775+
 776+ // Uploading user
 777+ $row .= '<td>';
 778+ if( $local ) {
 779+ $row .= $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext );
761780 } else {
762 - $userlink = htmlspecialchars( $usertext );
 781+ $row .= htmlspecialchars( $usertext );
763782 }
764 - $nbytes = wfMsgExt( 'nbytes', array( 'parsemag', 'escape' ),
765 - $wgLang->formatNum( $size ) );
766 - $widthheight = wfMsgHtml( 'widthheight', $width, $height );
767 - $style = $this->skin->getInternalLinkAttributes( $url, $datetime );
768 -
769 - $s = "<li> ({$dlink}) ({$rlink}) <a href=\"{$url}\"{$style}>{$datetime}</a> . . {$userlink} . . {$widthheight} ({$nbytes})";
770 -
771 - $s .= $this->skin->commentBlock( $description, $wgTitle );
772 - $s .= "</li>\n";
773 - return $s;
 783+ $row .= '</td>';
 784+
 785+ // Image dimensions
 786+ // FIXME: What about sound files? Should have the duration instead...
 787+ $row .= '<td>' . wfMsgHtml( 'widthheight', $width, $height ) . '</td>';
 788+
 789+ // File size
 790+ $row .= '<td>' . $this->skin->formatSize( $size ) . '</td>';
 791+
 792+ // Comment
 793+ $row .= '<td>' . $this->skin->formatComment( $description, $this->title ) . '</td>';
 794+
 795+ return "<tr>{$row}</tr>\n";
774796 }
775 -}
776797
777 -
778 -
 798+}
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1439,14 +1439,17 @@
14401440 'imgdelete' => 'del',
14411441 'imgdesc' => 'desc',
14421442 'imgfile' => 'file',
1443 -'imglegend' => 'Legend: (desc) = show/edit file description.',
1444 -'imghistory' => 'File history',
1445 -'revertimg' => 'rev',
1446 -'deleteimg' => 'del',
1447 -'deleteimgcompletely' => 'Delete all revisions of this file',
1448 -'imghistlegend' => 'Legend: (cur) = this is the current file, (del) = delete
1449 -this old version, (rev) = revert to this old version.
1450 -<br /><i>Click on date to see the file uploaded on that date</i>.',
 1443+'filehist' => 'File history',
 1444+'filehist-help' => 'Click on a date/time to view the file as it appeared at that time.',
 1445+'filehist-deleteall' => 'delete all',
 1446+'filehist-deleteone' => 'delete this',
 1447+'filehist-revert' => 'revert',
 1448+'filehist-current' => 'current',
 1449+'filehist-datetime' => 'Date/Time',
 1450+'filehist-user' => 'User',
 1451+'filehist-dimensions' => 'Dimensions',
 1452+'filehist-filesize' => 'File size',
 1453+'filehist-comment' => 'Comment',
14511454 'imagelinks' => 'Links',
14521455 'linkstoimage' => 'The following pages link to this file:',
14531456 'nolinkstoimage' => 'There are no pages that link to this file.',
Index: trunk/phase3/RELEASE-NOTES
@@ -159,6 +159,7 @@
160160 * Skip the difference engine cache when 'action=purge' is used while requesting
161161 a difference page, to allow refreshing the cache in case of errors
162162 * (bug 10701) Link to Special:Listusers in default Special:Statistics messages
 163+* Improved file history presentation
163164
164165 == Bugfixes since 1.10 ==
165166
@@ -331,6 +332,7 @@
332333 * Improved speed of file delete by storing the SHA-1 hash in image/oldimage
333334 * Fixed leading zero in base 36 SHA-1 hash
334335 * Protection form no longer produces JavaScript errors
 336+* (bug 10741) File histories show "delete" links for non-sysops
335337
336338 == API changes since 1.10 ==
337339

Follow-up revisions

RevisionCommit summaryAuthorDate
r24454Fix regression: message 'imghistory' was deleted in r24432 but still used in ...raymond08:38, 30 July 2007
r24502Merged revisions 24415-24479 via svnmerge from...david22:31, 31 July 2007

Status & tagging log