X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fpage%2FImagePage.php;h=3638aedb7f9b431bc0d7e85776638d1039f98986;hb=9ab6887c8c93014a17afd6ab81f6bac3bf5effd6;hp=9b9e3cbdc75a5013de6bc9679cbc9c6dae2575e6;hpb=c7e903369cf6d91f1ccf6e783a8de2d258087fed;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/page/ImagePage.php b/includes/page/ImagePage.php index 9b9e3cbdc7..3638aedb7f 100644 --- a/includes/page/ImagePage.php +++ b/includes/page/ImagePage.php @@ -248,7 +248,9 @@ class ImagePage extends Article { Hooks::run( 'ImagePageShowTOC', array( $this, &$r ) ); if ( $metadata ) { - $r[] = '
  • ' . $this->getContext()->msg( 'metadata' )->escaped() . '
  • '; + $r[] = '
  • ' . + $this->getContext()->msg( 'metadata' )->escaped() . + '
  • '; } return ''; @@ -380,18 +382,17 @@ class ImagePage extends Article { } $otherSizes = array_unique( $otherSizes ); - $msgsmall = ''; $sizeLinkBigImagePreview = $this->makeSizeLink( $params, $width, $height ); - if ( $sizeLinkBigImagePreview ) { - $msgsmall .= $this->getContext()->msg( 'show-big-image-preview' )-> - rawParams( $sizeLinkBigImagePreview )-> - parse(); - } + $msgsmall = $this->getThumbPrevText( $params, $sizeLinkBigImagePreview ); if ( count( $otherSizes ) ) { $msgsmall .= ' ' . - Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ), - $this->getContext()->msg( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )-> - params( count( $otherSizes ) )->parse() + Html::rawElement( + 'span', + array( 'class' => 'mw-filepage-other-resolutions' ), + $this->getContext()->msg( 'show-big-image-other' ) + ->rawParams( $lang->pipeList( $otherSizes ) ) + ->params( count( $otherSizes ) ) + ->parse() ); } } elseif ( $width == 0 && $height == 0 ) { @@ -626,6 +627,44 @@ EOT $out->setFileVersion( $this->displayImg ); } + /** + * Make the text under the image to say what size preview + * + * @param $params Array parameters for thumbnail + * @param $sizeLinkBigImagePreview HTML for the current size + * @return string HTML output + */ + private function getThumbPrevText( $params, $sizeLinkBigImagePreview ) { + if ( $sizeLinkBigImagePreview ) { + // Show a different message of preview is different format from original. + $previewTypeDiffers = false; + $origExt = $thumbExt = $this->displayImg->getExtension(); + if ( $this->displayImg->getHandler() ) { + $origMime = $this->displayImg->getMimeType(); + $typeParams = $params; + $this->displayImg->getHandler()->normaliseParams( $this->displayImg, $typeParams ); + list( $thumbExt, $thumbMime ) = $this->displayImg->getHandler()->getThumbType( + $origExt, $origMime, $typeParams ); + if ( $thumbMime !== $origMime ) { + $previewTypeDiffers = true; + } + } + if ( $previewTypeDiffers ) { + return $this->getContext()->msg( 'show-big-image-preview-differ' )-> + rawParams( $sizeLinkBigImagePreview )-> + params( strtoupper( $origExt ) )-> + params( strtoupper( $thumbExt ) )-> + parse(); + } else { + return $this->getContext()->msg( 'show-big-image-preview' )-> + rawParams( $sizeLinkBigImagePreview )-> + parse(); + } + } else { + return ''; + } + } + /** * Creates an thumbnail of specified size and returns an HTML link to it * @param array $params Scaler parameters @@ -667,9 +706,14 @@ EOT $wrap = "
    \n$1\n
    \n"; $repo = $this->mPage->getFile()->getRepo()->getDisplayName(); - if ( $descUrl && $descText && $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-' ) { + if ( $descUrl && + $descText && + $this->getContext()->msg( 'sharedupload-desc-here' )->plain() !== '-' + ) { $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-here', $repo, $descUrl ) ); - } elseif ( $descUrl && $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-' ) { + } elseif ( $descUrl && + $this->getContext()->msg( 'sharedupload-desc-there' )->plain() !== '-' + ) { $out->wrapWikiMsg( $wrap, array( 'sharedupload-desc-there', $repo, $descUrl ) ); } else { $out->wrapWikiMsg( $wrap, array( 'sharedupload', $repo ), ''/*BACKCOMPAT*/ ); @@ -854,7 +898,9 @@ EOT $liContents = $link; } elseif ( count( $redirects[$element->page_title] ) === 0 ) { # Redirect without usages - $liContents = $this->getContext()->msg( 'linkstoimage-redirect' )->rawParams( $link, '' )->parse(); + $liContents = $this->getContext()->msg( 'linkstoimage-redirect' ) + ->rawParams( $link, '' ) + ->parse(); } else { # Redirect with usages $li = ''; @@ -923,7 +969,10 @@ EOT } else { $link = Linker::makeExternalLink( $file->getDescriptionUrl(), $file->getTitle()->getPrefixedText() ); - $fromSrc = $this->getContext()->msg( 'shared-repo-from', $file->getRepo()->getDisplayName() )->text(); + $fromSrc = $this->getContext()->msg( + 'shared-repo-from', + $file->getRepo()->getDisplayName() + )->text(); } $out->addHTML( "
  • {$link} {$fromSrc}
  • \n" ); } @@ -1068,8 +1117,10 @@ EOT ); $submit = Xml::submitButton( $this->getContext()->msg( 'img-lang-go' )->text() ); - $formContents = $this->getContext()->msg( 'img-lang-info' )->rawParams( $select, $submit )->parse() - . Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ); + $formContents = $this->getContext()->msg( 'img-lang-info' ) + ->rawParams( $select, $submit ) + ->parse(); + $formContents .= Html::hidden( 'title', $this->getTitle()->getPrefixedDBkey() ); $langSelectLine = Html::rawElement( 'div', array( 'id' => 'mw-imglangselector-line' ), Html::rawElement( 'form', array( 'action' => $wgScript ), $formContents ) @@ -1141,7 +1192,9 @@ EOT } else { # Creating thumb links triggers thumbnail generation. # Just generate the thumb for the current users prefs. - $thumbSizes = array( $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' ) ); + $thumbSizes = array( + $this->getImageLimitsFromOption( $this->getContext()->getUser(), 'thumbsize' ) + ); if ( !$this->displayImg->mustRender() ) { // We can safely include a link to the "full-size" preview, // without actually rendering. @@ -1480,7 +1533,7 @@ class ImageHistoryPseudoPager extends ReverseChronologicalPager { function __construct( $imagePage ) { parent::__construct( $imagePage->getContext() ); $this->mImagePage = $imagePage; - $this->mTitle = clone ( $imagePage->getTitle() ); + $this->mTitle = clone $imagePage->getTitle(); $this->mTitle->setFragment( '#filehistory' ); $this->mImg = null; $this->mHist = array();