* (bug 12938) Fix template expansion and 404 returns for action=raw with section
[lhc/web/wiklou.git] / includes / ImagePage.php
index b722903..8336837 100644 (file)
@@ -19,11 +19,14 @@ class ImagePage extends Article {
        /* private */ var $repo;
        var $mExtraDescription = false;
 
-       function __construct( $title ) {
+       function __construct( $title, $time = false ) {
                parent::__construct( $title );
-               $this->img = wfFindFile( $this->mTitle );
+               $this->img = wfFindFile( $this->mTitle, $time );
                if ( !$this->img ) {
                        $this->img = wfLocalFile( $this->mTitle );
+                       $this->current = $this->img;
+               } else {
+                       $this->current = $time ? wfLocalFile( $this->mTitle ) : $this->img;
                }
                $this->repo = $this->img->repo;
        }
@@ -66,7 +69,7 @@ class ImagePage extends Article {
                } else {
                        # Just need to set the right headers
                        $wgOut->setArticleFlag( true );
-                       $wgOut->setRobotpolicy( 'index,follow' );
+                       $wgOut->setRobotpolicy( 'noindex,nofollow' );
                        $wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
                        $this->viewUpdates();
                }
@@ -411,9 +414,9 @@ EOT
 
                $sk = $wgUser->getSkin();
 
-               if ( $this->img->exists ) {
-                       $list = new ImageHistoryList( $sk, $this->img );
-                       $file = $this->img;
+               if ( $this->img->exists() ) {
+                       $list = new ImageHistoryList( $sk, $this->current );
+                       $file = $this->current;
                        $dims = $file->getDimensionsString();
                        $s = $list->beginImageHistoryList() .
                                $list->imageHistoryLine( true, wfTimestamp(TS_MW, $file->getTimestamp()),
@@ -560,6 +563,19 @@ class ImageHistoryList {
                return "</table>\n";
        }
 
+       /**
+        * Create one row of file history
+        *
+        * @param bool $iscur is this the current file version?
+        * @param string $timestamp timestamp of file version
+        * @param string $img filename
+        * @param int $user ID of uploading user
+        * @param string $usertext username of uploading user
+        * @param int $size size of file version
+        * @param string $description description of file version
+        * @param string $dims dimensions of file version
+        * @return string a HTML formatted table row
+        */
        public function imageHistoryLine( $iscur, $timestamp, $img, $user, $usertext, $size, $description, $dims ) {
                global $wgUser, $wgLang, $wgContLang;
                $local = $this->img->isLocal();
@@ -572,28 +588,28 @@ class ImageHistoryList {
                        $q[] = 'action=delete';
                        if( !$iscur )
                                $q[] = 'oldimage=' . urlencode( $img );
-                       $row .= '(' . $this->skin->makeKnownLinkObj(
+                       $row .= $this->skin->makeKnownLinkObj(
                                $this->title,
                                wfMsgHtml( $iscur ? 'filehist-deleteall' : 'filehist-deleteone' ),
                                implode( '&', $q )
-                       ) . ')';
+                       );
                        $row .= '</td>';
                }
 
                // Reversion link/current indicator
                $row .= '<td>';
                if( $iscur ) {
-                       $row .= '(' . wfMsgHtml( 'filehist-current' ) . ')';
+                       $row .= wfMsgHtml( 'filehist-current' );
                } elseif( $local && $wgUser->isLoggedIn() && $this->title->userCan( 'edit' ) ) {
                        $q = array();
                        $q[] = 'action=revert';
                        $q[] = 'oldimage=' . urlencode( $img );
                        $q[] = 'wpEditToken=' . urlencode( $wgUser->editToken( $img ) );
-                       $row .= '(' . $this->skin->makeKnownLinkObj(
+                       $row .= $this->skin->makeKnownLinkObj(
                                $this->title,
                                wfMsgHtml( 'filehist-revert' ),
                                implode( '&', $q )
-                       ) . ')';
+                       );
                }
                $row .= '</td>';