From: Rob Church Date: Sun, 29 Jul 2007 18:41:49 +0000 (+0000) Subject: * Use a table to present file histories X-Git-Tag: 1.31.0-rc.0~51948 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/exercices/journal.php?a=commitdiff_plain;h=6b1f079e79511a104546e255f64c5380b63f5aa5;p=lhc%2Fweb%2Fwiklou.git * Use a table to present file histories * (bug 10741) Don't show deletion links for non-sysops [in file histories] --- diff --git a/RELEASE-NOTES b/RELEASE-NOTES index 695bb289ea..6f66fb7d2a 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 66e8ba68db..aa6a971f57 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -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

" . wfMsg( 'imghistlegend' ) . "

\n".'\n"; - return $s; + public function endImageHistoryList() { + return "\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 = ''.$delall.''; - } 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 .= ''; + $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 .= ''; } - - if ( $local ) { - $userlink = $this->skin->userLink( $user, $usertext ) . $this->skin->userToolLinks( $user, $usertext ); + + // Reversion link/current indicator + $row .= ''; + 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 .= ''; + + // Date/time and image link + $row .= ''; + $url = $iscur ? $this->img->getUrl() : $this->img->getArchiveUrl( $img ); + $row .= Xml::element( + 'a', + array( 'href' => $url ), + $wgLang->timeAndDate( $timestamp, true ) + ); + $row .= ''; + + // Uploading user + $row .= ''; + 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 = "
  • ({$dlink}) ({$rlink}) {$datetime} . . {$userlink} . . {$widthheight} ({$nbytes})"; - - $s .= $this->skin->commentBlock( $description, $wgTitle ); - $s .= "
  • \n"; - return $s; + $row .= ''; + + // Image dimensions + // FIXME: What about sound files? Should have the duration instead... + $row .= '' . wfMsgHtml( 'widthheight', $width, $height ) . ''; + + // File size + $row .= '' . $this->skin->formatSize( $size ) . ''; + + // Comment + $row .= '' . $this->skin->formatComment( $description, $this->title ) . ''; + + return "{$row}\n"; } -} - - +} \ No newline at end of file diff --git a/languages/messages/MessagesEn.php b/languages/messages/MessagesEn.php index 139b3e4e9a..b6bf8b484e 100644 --- a/languages/messages/MessagesEn.php +++ b/languages/messages/MessagesEn.php @@ -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. -
    Click on date to see the file uploaded on that date.', +'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.', diff --git a/maintenance/language/messages.inc b/maintenance/language/messages.inc index 5d763d99bc..4700bd317a 100644 --- a/maintenance/language/messages.inc +++ b/maintenance/language/messages.inc @@ -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', diff --git a/skins/common/shared.css b/skins/common/shared.css index dab7facd7d..063a4fe814 100644 --- a/skins/common/shared.css +++ b/skins/common/shared.css @@ -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 diff --git a/skins/monobook/main.css b/skins/monobook/main.css index 50a3c0ccc1..fe96599688 100644 --- a/skins/monobook/main.css +++ b/skins/monobook/main.css @@ -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