* (bug 28010) Passing a non existant user to list=users gives internal error
[lhc/web/wiklou.git] / includes / ImagePage.php
index bf903b7..4cd93ee 100644 (file)
@@ -1,8 +1,5 @@
 <?php
 
-if ( !defined( 'MEDIAWIKI' ) )
-       die( 1 );
-
 /**
  * Special handling for image description pages
  *
@@ -10,10 +7,17 @@ if ( !defined( 'MEDIAWIKI' ) )
  */
 class ImagePage extends Article {
 
-       /* private */ var $img;  // Image object
+       /**
+        * @var File
+        */
+       /* private */ var $img;
+       /**
+        * @var File
+        */
        /* private */ var $displayImg;
        /* private */ var $repo;
        /* private */ var $fileLoaded;
+
        var $mExtraDescription = false;
        var $dupes;
 
@@ -171,6 +175,7 @@ class ImagePage extends Article {
                }
                return $this->mRedirectTarget = Title::makeTitle( NS_FILE, $to );
        }
+
        public function followRedirect() {
                $this->loadFile();
                if ( $this->img->isLocal() ) {
@@ -183,6 +188,7 @@ class ImagePage extends Article {
                }
                return Title::makeTitle( NS_FILE, $to );
        }
+
        public function isRedirect( $text = false ) {
                $this->loadFile();
                if ( $this->img->isLocal() )
@@ -228,7 +234,6 @@ class ImagePage extends Article {
                return $this->dupes = $dupes;
                
        }
-       
 
        /**
         * Create the TOC
@@ -330,7 +335,7 @@ class ImagePage extends Article {
                        $height_orig = $this->displayImg->getHeight( $page );
                        $height = $height_orig;
 
-                       $longDesc = wfMsgExt( 'parentheses', 'parseinline', $this->displayImg->getLongDesc() );
+                       $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() );
 
                        wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) );
 
@@ -498,8 +503,16 @@ EOT
                        {
                                $nofile = 'filepage-nofile';
                        }
+                       // Note, if there is an image description page, but
+                       // no image, then this setRobotPolicy is overriden
+                       // by Article::View().
                        $wgOut->setRobotPolicy( 'noindex,nofollow' );
                        $wgOut->wrapWikiMsg( "<div id='mw-imagepage-nofile' class='plainlinks'>\n$1\n</div>", $nofile );
+                       if ( !$this->getID() ) {
+                               // If there is no image, no shared image, and no description page,
+                               // output a 404, to be consistent with articles.
+                               $wgRequest->response()->header( "HTTP/1.x 404 Not Found" );
+                       }
                }
        }
 
@@ -551,7 +564,9 @@ EOT
        protected function uploadLinksBox() {
                global $wgUser, $wgOut, $wgEnableUploads, $wgUseExternalEditor;
 
-               if ( !$wgEnableUploads ) { return; }
+               if ( !$wgEnableUploads ) {
+                       return;
+               }
 
                $this->loadFile();
                if ( !$this->img->isLocal() )
@@ -709,7 +724,9 @@ EOT
                $this->loadFile();
 
                $dupes = $this->getDuplicates();
-               if ( count( $dupes ) == 0 ) return;
+               if ( count( $dupes ) == 0 ) {
+                       return;
+               }
 
                $wgOut->addHTML( "<div id='mw-imagepage-section-duplicates'>\n" );
                $wgOut->addWikiMsg( 'duplicatesoffile',
@@ -800,7 +817,6 @@ EOT
                $wgOut->addWikiText( $description );
        }
 
-
        /**
         * Callback for usort() to do link sorts by (namespace, title)
         * Function copied from Title::compare()
@@ -825,9 +841,32 @@ EOT
  */
 class ImageHistoryList {
 
-       protected $imagePage, $img, $skin, $title, $repo, $showThumb;
+       /**
+        * @var Title
+        */
+       protected $title;
+
+       /**
+        * @var File
+        */
+       protected $img;
+
+       /**
+        * @var ImagePage
+        */
+       protected $imagePage;
+
+       /**
+        * @var Skin
+        */
+       protected $skin;
+
+       protected $repo, $showThumb;
        protected $preventClickjacking = false;
 
+       /**
+        * @param ImagePage $imagePage
+        */
        public function __construct( $imagePage ) {
                global $wgUser, $wgShowArchiveThumbnails;
                $this->skin = $wgUser->getSkin();
@@ -871,6 +910,11 @@ class ImageHistoryList {
                return "</table>\n$navLinks\n</div>\n";
        }
 
+       /**
+        * @param  $iscur
+        * @param File $file
+        * @return string
+        */
        public function imageHistoryLine( $iscur, $file ) {
                global $wgUser, $wgLang;
 
@@ -1015,6 +1059,10 @@ class ImageHistoryList {
                return "<tr{$classAttr}>{$row}</tr>\n";
        }
 
+       /**
+        * @param File $file
+        * @return string
+        */
        protected function getThumbForLine( $file ) {
                global $wgLang;
 
@@ -1054,6 +1102,19 @@ class ImageHistoryList {
 class ImageHistoryPseudoPager extends ReverseChronologicalPager {
        protected $preventClickjacking = false;
 
+       /**
+        * @var File
+        */
+       protected $mImg;
+
+       /**
+        * @var Title
+        */
+       protected $mTitle;
+
+       /**
+        * @param ImagePage $imagePage
+        */
        function __construct( $imagePage ) {
                parent::__construct();
                $this->mImagePage = $imagePage;