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.
/* 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";
$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 ) {
}
$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();
}
* @param ImagePage $imagePage
*/
function __construct( $imagePage ) {
- parent::__construct();
+ parent::__construct( $imagePage->getContext() );
$this->mImagePage = $imagePage;
$this->mTitle = clone ( $imagePage->getTitle() );
$this->mTitle->setFragment( '#filehistory' );