r24950 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r24949‎ | r24950 | r24951 >
Date:14:32, 20 August 2007
Author:robchurch
Status:old
Tags:
Comment:
* Fix FileRevertForm::getTimestamp() - stupid assumption about archive names :)
* Do date/time adjustments where applicable
* Reverse odd ordering of date/times in messages - time, then date looks cleaner in English
* Remove the commented-out remnants for now
Modified paths:
  • /trunk/phase3/includes/FileRevertForm.php (modified) (history)
  • /trunk/phase3/languages/messages/MessagesEn.php (modified) (history)

Diff [purge]

Index: trunk/phase3/includes/FileRevertForm.php
@@ -68,8 +68,8 @@
6969 $status = $this->file->upload( $source, $comment, $comment );
7070 if( $status->isGood() ) {
7171 $wgOut->addHtml( wfMsgExt( 'filerevert-success', 'parse', $this->title->getText(),
72 - $wgLang->date( $this->getTimestamp() ),
73 - $wgLang->time( $this->getTimestamp() ),
 72+ $wgLang->date( $this->getTimestamp(), true ),
 73+ $wgLang->time( $this->getTimestamp(), true ),
7474 $wgServer . $this->file->getArchiveUrl( $this->oldimage ) ) );
7575 $wgOut->returnToMain( false, $this->title );
7676 } else {
@@ -87,37 +87,13 @@
8888 */
8989 private function showForm() {
9090 global $wgOut, $wgUser, $wgRequest, $wgLang, $wgContLang, $wgServer;
91 -
92 - /*
93 - $cur = wfFindFile( $this->title );
94 - $old = wfFindFile( $this->title, substr( $this->oldimage, 0, 14 ) );
95 - */
9691 $timestamp = $this->getTimestamp();
9792
9893 $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) );
9994 $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) );
10095 $form .= '<fieldset><legend>' . wfMsgHtml( 'filerevert-legend' ) . '</legend>';
10196 $form .= wfMsgExt( 'filerevert-intro', 'parse', $this->title->getText(),
102 - $wgLang->date( $timestamp ), $wgLang->time( $timestamp ), $wgServer . $this->file->getArchiveUrl( $this->oldimage ) );
103 -
104 - /*
105 - * I was going to do a little comparison (current vs. old) here,
106 - * but realised it wasn't too straightforward to do a media transform
107 - * with an *old* file version using the current mechanism. Leaving
108 - * this here in case it becomes possible in the future. -- RC
109 - *
110 - $form .= '<table class="compare-files">';
111 - $form .= '<tr>';
112 - $form .= '<th>' . wfMsgHtml( 'filerevert-current' ) . '</th>';
113 - $form .= '<th>' . wfMsgHtml( 'filerevert-old', $old->getTimestamp() ) . '</th>';
114 - $form .= '</tr><tr>';
115 - // FIXME: Hard-coding magic numbers makes baby Jesus cry...
116 - $form .= '<td>' . $this->getThumbnail( $cur, 180 ) . '</td>';
117 - $form .= '<td>' . $this->getThumbnail( $old, 180 ) . '</td>';
118 - $form .= '</tr>';
119 - $form .= '</table>';
120 - */
121 -
 97+ $wgLang->date( $timestamp, true ), $wgLang->time( $timestamp, true ), $wgServer . $this->file->getArchiveUrl( $this->oldimage ) );
12298 $form .= '<p>' . Xml::inputLabel( wfMsg( 'filerevert-comment' ), 'wpComment', 'wpComment',
12399 60, wfMsgForContent( 'filerevert-defaultcomment',
124100 $wgContLang->date( $timestamp, false, false ), $wgContLang->time( $timestamp, false, false ) ) ) . '</p>';
@@ -177,7 +153,12 @@
178154 * @return string
179155 */
180156 private function getTimestamp() {
181 - return substr( $this->oldimage, 0, 14 );
 157+ static $timestamp = false;
 158+ if( $timestamp === false ) {
 159+ $file = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage );
 160+ $timestamp = $file->getTimestamp();
 161+ }
 162+ return $timestamp;
182163 }
183164
184165 }
\ No newline at end of file
Index: trunk/phase3/languages/messages/MessagesEn.php
@@ -1495,11 +1495,11 @@
14961496 # File reversion
14971497 'filerevert' => 'Revert $1',
14981498 'filerevert-legend' => 'Revert file',
1499 -'filerevert-intro' => "<span class=\"plainlinks\">You are reverting '''[[Media:$1|$1]]''' to the [$4 version as of $2, $3].</span>",
 1499+'filerevert-intro' => "<span class=\"plainlinks\">You are reverting '''[[Media:$1|$1]]''' to the [$4 version as of $3, $2].</span>",
15001500 'filerevert-comment' => 'Comment:',
1501 -'filerevert-defaultcomment' => 'Reverted to version as of $1, $2',
 1501+'filerevert-defaultcomment' => 'Reverted to version as of $2, $1',
15021502 'filerevert-submit' => 'Revert',
1503 -'filerevert-success' => "<span class=\"plainlinks\">'''[[Media:$1|$1]]''' has been reverted to the [$4 version as of $2, $3].</span>",
 1503+'filerevert-success' => "<span class=\"plainlinks\">'''[[Media:$1|$1]]''' has been reverted to the [$4 version as of $3, $2].</span>",
15041504 'filerevert-badversion' => 'There is no previous local version of this file with the provided timestamp.',
15051505
15061506 # File deletion

Follow-up revisions

RevisionCommit summaryAuthorDate
r24951As r24950, but for FileDeleteFormrobchurch14:35, 20 August 2007
r25016Merged revisions 24866-25015 via svnmerge from...david23:06, 21 August 2007

Status & tagging log