X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FFileRevertForm.php;h=55f21fffbfcf489cbb32bf918e05c79c127cb82d;hb=37c14c19a90667081b8c10f895b242e141192fdf;hp=d72654b05ac63fb7a0c0e15ac90a44a2f5f8e84a;hpb=23767188c91dedc315356be019c5e5daadc6d65f;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/FileRevertForm.php b/includes/FileRevertForm.php index d72654b05a..55f21fffbf 100644 --- a/includes/FileRevertForm.php +++ b/includes/FileRevertForm.php @@ -11,6 +11,7 @@ class FileRevertForm { private $title = null; private $file = null; private $oldimage = ''; + private $timestamp = false; /** * Constructor @@ -68,8 +69,8 @@ class FileRevertForm { $status = $this->file->upload( $source, $comment, $comment ); if( $status->isGood() ) { $wgOut->addHtml( wfMsgExt( 'filerevert-success', 'parse', $this->title->getText(), - $wgLang->date( $this->getTimestamp() ), - $wgLang->time( $this->getTimestamp() ), + $wgLang->date( $this->getTimestamp(), true ), + $wgLang->time( $this->getTimestamp(), true ), $wgServer . $this->file->getArchiveUrl( $this->oldimage ) ) ); $wgOut->returnToMain( false, $this->title ); } else { @@ -87,37 +88,13 @@ class FileRevertForm { */ private function showForm() { global $wgOut, $wgUser, $wgRequest, $wgLang, $wgContLang, $wgServer; - - /* - $cur = wfFindFile( $this->title ); - $old = wfFindFile( $this->title, substr( $this->oldimage, 0, 14 ) ); - */ $timestamp = $this->getTimestamp(); $form = Xml::openElement( 'form', array( 'method' => 'post', 'action' => $this->getAction() ) ); $form .= Xml::hidden( 'wpEditToken', $wgUser->editToken( $this->oldimage ) ); $form .= '
' . wfMsgHtml( 'filerevert-legend' ) . ''; $form .= wfMsgExt( 'filerevert-intro', 'parse', $this->title->getText(), - $wgLang->date( $timestamp ), $wgLang->time( $timestamp ), $wgServer . $this->file->getArchiveUrl( $this->oldimage ) ); - - /* - * I was going to do a little comparison (current vs. old) here, - * but realised it wasn't too straightforward to do a media transform - * with an *old* file version using the current mechanism. Leaving - * this here in case it becomes possible in the future. -- RC - * - $form .= ''; - $form .= ''; - $form .= ''; - $form .= ''; - $form .= ''; - // FIXME: Hard-coding magic numbers makes baby Jesus cry... - $form .= ''; - $form .= ''; - $form .= ''; - $form .= '
' . wfMsgHtml( 'filerevert-current' ) . '' . wfMsgHtml( 'filerevert-old', $old->getTimestamp() ) . '
' . $this->getThumbnail( $cur, 180 ) . '' . $this->getThumbnail( $old, 180 ) . '
'; - */ - + $wgLang->date( $timestamp, true ), $wgLang->time( $timestamp, true ), $wgServer . $this->file->getArchiveUrl( $this->oldimage ) ); $form .= '

' . Xml::inputLabel( wfMsg( 'filerevert-comment' ), 'wpComment', 'wpComment', 60, wfMsgForContent( 'filerevert-defaultcomment', $wgContLang->date( $timestamp, false, false ), $wgContLang->time( $timestamp, false, false ) ) ) . '

'; @@ -132,9 +109,10 @@ class FileRevertForm { * Set headers, titles and other bits */ private function setHeaders() { - global $wgOut; + global $wgOut, $wgUser; $wgOut->setPageTitle( wfMsg( 'filerevert', $this->title->getText() ) ); $wgOut->setRobotPolicy( 'noindex,nofollow' ); + $wgOut->setSubtitle( wfMsg( 'filerevert-backlink', $wgUser->getSkin()->makeKnownLinkObj( $this->title ) ) ); } /** @@ -177,7 +155,11 @@ class FileRevertForm { * @return string */ private function getTimestamp() { - return substr( $this->oldimage, 0, 14 ); + if( $this->timestamp === false ) { + $file = RepoGroup::singleton()->getLocalRepo()->newFromArchiveName( $this->title, $this->oldimage ); + $this->timestamp = $file->getTimestamp(); + } + return $this->timestamp; } } \ No newline at end of file