(Bug 17970) {{PROTECTIONLEVEL}} should be able to return the status for pages besides...
[lhc/web/wiklou.git] / includes / ImagePage.php
index 316e1c9..c93f38c 100644 (file)
@@ -340,13 +340,13 @@ class ImagePage extends Article {
                                if ( $width > $maxWidth || $height > $maxHeight ) {
                                        # Calculate the thumbnail size.
                                        # First case, the limiting factor is the width, not the height.
-                                       if ( $width / $height >= $maxWidth / $maxHeight ) {
-                                               $height = round( $height * $maxWidth / $width );
+                                       if ( $width / $height >= $maxWidth / $maxHeight ) { // FIXME: Possible divison by 0. bug 36911
+                                               $height = round( $height * $maxWidth / $width ); // FIXME: Possible divison by 0. bug 36911
                                                $width = $maxWidth;
                                                # Note that $height <= $maxHeight now.
                                        } else {
-                                               $newwidth = floor( $width * $maxHeight / $height );
-                                               $height = round( $height * $newwidth / $width );
+                                               $newwidth = floor( $width * $maxHeight / $height ); // FIXME: Possible divison by 0. bug 36911
+                                               $height = round( $height * $newwidth / $width ); // FIXME: Possible divison by 0. bug 36911
                                                $width = $newwidth;
                                                # Note that $height <= $maxHeight now, but might not be identical
                                                # because of rounding.
@@ -614,7 +614,7 @@ EOT
 
                /* Add canonical to head if there is no local page for this shared file */
                if( $descUrl && $this->mPage->getID() == 0 ) {
-                       $out->addLink( array( 'rel' => 'canonical', 'href' => $descUrl ) );
+                       $out->setCanonicalUrl( $descUrl );
                }
 
                $wrap = "<div class=\"sharedUploadNotice\">\n$1\n</div>\n";
@@ -796,9 +796,14 @@ EOT
 
                        $link = Linker::linkKnown( Title::makeTitle( $element->page_namespace, $element->page_title ) );
                        if ( !isset( $redirects[$element->page_title] ) ) {
+                               # No redirects
                                $liContents = $link;
+                       } elseif ( count( $redirects[$element->page_title] ) === 0 ) {
+                               # Redirect without usages
+                               $liContents = wfMessage( 'linkstoimage-redirect' )->rawParams( $link, '' )->parse();
                        } else {
-                               $ul = "<ul class='mw-imagepage-redirectstofile'>\n";
+                               # Redirect with usages
+                               $li = '';
                                foreach ( $redirects[$element->page_title] as $row ) {
                                        $currentCount++;
                                        if ( $currentCount > $limit ) {
@@ -806,13 +811,18 @@ EOT
                                        }
 
                                        $link2 = Linker::linkKnown( Title::makeTitle( $row->page_namespace, $row->page_title ) );
-                                       $ul .= Html::rawElement(
+                                       $li .= Html::rawElement(
                                                'li',
                                                array( 'class' => 'mw-imagepage-linkstoimage-ns' . $element->page_namespace ),
                                                $link2
                                                ) . "\n";
                                }
-                               $ul .= '</ul>';
+
+                               $ul = Html::rawElement(
+                                       'ul',
+                                       array( 'class' => 'mw-imagepage-redirectstofile'),
+                                       $li
+                                       ) . "\n";
                                $liContents = wfMessage( 'linkstoimage-redirect' )->rawParams(
                                        $link, $ul )->parse();
                        }
@@ -1225,7 +1235,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager {
         * @param ImagePage $imagePage
         */
        function __construct( $imagePage ) {
-               parent::__construct();
+               parent::__construct( $imagePage->getContext() );
                $this->mImagePage = $imagePage;
                $this->mTitle = clone ( $imagePage->getTitle() );
                $this->mTitle->setFragment( '#filehistory' );