Revert "jquery.textSelection: Remove hardcoded checks for removed WikiEditor iframe...
[lhc/web/wiklou.git] / includes / ImagePage.php
index c73d72c..8444223 100644 (file)
@@ -40,7 +40,7 @@ class ImagePage extends Article {
        var $mExtraDescription = false;
 
        /**
-        * @param $title Title
+        * @param Title $title
         * @return WikiFilePage
         */
        protected function newPage( Title $title ) {
@@ -50,7 +50,7 @@ class ImagePage extends Article {
 
        /**
         * Constructor from a page id
-        * @param int $id article ID to load
+        * @param int $id Article ID to load
         * @return ImagePage|null
         */
        public static function newFromID( $id ) {
@@ -61,7 +61,7 @@ class ImagePage extends Article {
        }
 
        /**
-        * @param $file File:
+        * @param File $file
         * @return void
         */
        public function setFile( $file ) {
@@ -227,8 +227,8 @@ class ImagePage extends Article {
        /**
         * Create the TOC
         *
-        * @param $metadata Boolean: whether or not to show the metadata link
-        * @return String
+        * @param bool $metadata Whether or not to show the metadata link
+        * @return string
         */
        protected function showTOC( $metadata ) {
                $r = array(
@@ -250,8 +250,8 @@ class ImagePage extends Article {
         *
         * @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
         *
-        * @param array $metadata the array containing the Exif data
-        * @return String The metadata table. This is treated as Wikitext (!)
+        * @param array $metadata The array containing the Exif data
+        * @return string The metadata table. This is treated as Wikitext (!)
         */
        protected function makeMetadataTable( $metadata ) {
                $r = "<div class=\"mw-imagepage-section-metadata\">";
@@ -316,7 +316,12 @@ class ImagePage extends Article {
 
                        $renderLang = $request->getVal( 'lang' );
                        if ( !is_null( $renderLang ) ) {
-                               $params['lang'] = $renderLang;
+                               $handler = $this->displayImg->getHandler();
+                               if ( $handler && $handler->validateParam( 'lang', $renderLang ) ) {
+                                       $params['lang'] = $renderLang;
+                               } else {
+                                       $renderLang = null;
+                               }
                        }
 
                        $width_orig = $this->displayImg->getWidth( $page );
@@ -604,8 +609,8 @@ EOT
        /**
         * Creates an thumbnail of specified size and returns an HTML link to it
         * @param array $params Scaler parameters
-        * @param $width int
-        * @param $height int
+        * @param int $width
+        * @param int $height
         * @return string
         */
        private function makeSizeLink( $params, $width, $height ) {
@@ -718,8 +723,8 @@ EOT
        }
 
        /**
-        * @param $target
-        * @param $limit
+        * @param string $target
+        * @param int $limit
         * @return ResultWrapper
         */
        protected function queryImageLinks( $target, $limit ) {
@@ -727,7 +732,7 @@ EOT
 
                return $dbr->select(
                        array( 'imagelinks', 'page' ),
-                       array( 'page_namespace', 'page_title', 'page_is_redirect', 'il_to' ),
+                       array( 'page_namespace', 'page_title', 'il_to' ),
                        array( 'il_to' => $target, 'il_from = page_id' ),
                        __METHOD__,
                        array( 'LIMIT' => $limit + 1, 'ORDER BY' => 'il_from', )
@@ -738,13 +743,19 @@ EOT
                $limit = 100;
 
                $out = $this->getContext()->getOutput();
-               $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 );
+
                $rows = array();
                $redirects = array();
+               foreach ( $this->getTitle()->getRedirectsHere( NS_FILE ) as $redir ) {
+                       $redirects[$redir->getDBkey()] = array();
+                       $rows[] = (object)array(
+                               'page_namespace' => NS_FILE,
+                               'page_title' => $redir->getDBkey(),
+                       );
+               }
+
+               $res = $this->queryImageLinks( $this->getTitle()->getDBkey(), $limit + 1 );
                foreach ( $res as $row ) {
-                       if ( $row->page_is_redirect ) {
-                               $redirects[$row->page_title] = array();
-                       }
                        $rows[] = $row;
                }
                $count = count( $rows );
@@ -905,7 +916,7 @@ EOT
        /**
         * Display an error with a wikitext description
         *
-        * @param $description String
+        * @param string $description
         */
        function showError( $description ) {
                $out = $this->getContext()->getOutput();
@@ -920,9 +931,9 @@ EOT
         * Callback for usort() to do link sorts by (namespace, title)
         * Function copied from Title::compare()
         *
-        * @param $a object page to compare with
-        * @param $b object page to compare with
-        * @return Integer: result of string comparison, or namespace comparison
+        * @param object $a Object page to compare with
+        * @param object $b Object page to compare with
+        * @return int Result of string comparison, or namespace comparison
         */
        protected function compare( $a, $b ) {
                if ( $a->page_namespace == $b->page_namespace ) {
@@ -935,7 +946,7 @@ EOT
        /**
         * Returns the corresponding $wgImageLimits entry for the selected user option
         *
-        * @param $user User
+        * @param User $user
         * @param string $optionName Name of a option to check, typically imagesize or thumbsize
         * @return array
         * @since 1.21
@@ -963,10 +974,10 @@ EOT
        /**
         * Output a drop-down box for language options for the file
         *
-        * @param Array $langChoices Array of string language codes
-        * @param String $curLang Language code file is being viewed in.
-        * @param String $defaultLang Language code that image is rendered in by default
-        * @return String HTML to insert underneath image.
+        * @param array $langChoices Array of string language codes
+        * @param string $curLang Language code file is being viewed in.
+        * @param string $defaultLang Language code that image is rendered in by default
+        * @return string HTML to insert underneath image.
         */
        protected function doRenderLangOpt( array $langChoices, $curLang, $defaultLang ) {
                global $wgScript;
@@ -1002,7 +1013,7 @@ EOT
                if ( !$haveDefaultLang ) {
                        // Its hard to know if the content is really in the default language, or
                        // if its just unmarked content that could be in any language.
-                       $opts = Xml::option( wfMessage( 'img-lang-default' )->text(), '', $defaultLang === $curLang ) . $opts;
+                       $opts = Xml::option( wfMessage( 'img-lang-default' )->text(), $defaultLang, $defaultLang === $curLang ) . $opts;
                }
                if ( !$haveCurrentLang && $defaultLang !== $curLang ) {
                        $name = Language::fetchLanguageName( $curLang, $this->getContext()->getLanguage()->getCode() );
@@ -1085,7 +1096,7 @@ class ImageHistoryList extends ContextSource {
        }
 
        /**
-        * @param $navLinks string
+        * @param string $navLinks
         * @return string
         */
        public function beginImageHistoryList( $navLinks = '' ) {
@@ -1105,7 +1116,7 @@ class ImageHistoryList extends ContextSource {
        }
 
        /**
-        * @param $navLinks string
+        * @param string $navLinks
         * @return string
         */
        public function endImageHistoryList( $navLinks = '' ) {
@@ -1113,8 +1124,8 @@ class ImageHistoryList extends ContextSource {
        }
 
        /**
-        * @param $iscur
-        * @param $file File
+        * @param bool $iscur
+        * @param File $file
         * @return string
         */
        public function imageHistoryLine( $iscur, $file ) {
@@ -1274,7 +1285,7 @@ class ImageHistoryList extends ContextSource {
        }
 
        /**
-        * @param $file File
+        * @param File $file
         * @return string
         */
        protected function getThumbForLine( $file ) {
@@ -1309,7 +1320,7 @@ class ImageHistoryList extends ContextSource {
        }
 
        /**
-        * @param $enable bool
+        * @param bool $enable
         */
        protected function preventClickjacking( $enable = true ) {
                $this->preventClickjacking = $enable;
@@ -1368,7 +1379,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
        }
 
        /**
-        * @param $row object
+        * @param object $row
         * @return string
         */
        function formatRow( $row ) {
@@ -1482,7 +1493,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
        }
 
        /**
-        * @param $enable bool
+        * @param bool $enable
         */
        protected function preventClickjacking( $enable = true ) {
                $this->preventClickjacking = $enable;