X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=198d510c90599fdf05e97540c34b55d0bbef5624;hb=02f55026d2360cfed12958690102be32fd0eea95;hp=2e6e94e4d383c6ae0853f93562b3885b96b1514c;hpb=455e77d168c6934b7919e14dc6c38e2961f6bd02;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 2e6e94e4d3..198d510c90 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -10,12 +10,24 @@ if( !defined( 'MEDIAWIKI' ) ) /** * Special handling for image description pages + * + * @addtogroup Media */ class ImagePage extends Article { /* private */ var $img; // Image object this page is shown for + /* private */ var $repo; var $mExtraDescription = false; + function __construct( $title ) { + parent::__construct( $title ); + $this->img = wfFindFile( $this->mTitle ); + if ( !$this->img ) { + $this->img = wfLocalFile( $this->mTitle ); + } + $this->repo = $this->img->repo; + } + /** * Handler for action=render * Include body text only; none of the image extras @@ -29,8 +41,6 @@ class ImagePage extends Article { function view() { global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; - $this->img = new Image( $this->mTitle ); - $diff = $wgRequest->getVal( 'diff' ); $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); @@ -38,10 +48,10 @@ class ImagePage extends Article { return Article::view(); if ($wgShowEXIF && $this->img->exists()) { - $exif = $this->img->getExifData(); - $showmeta = count($exif) ? true : false; + // FIXME: bad interface, see note on MediaHandler::formatMetadata(). + $formattedMetadata = $this->img->formatMetadata(); + $showmeta = $formattedMetadata !== false; } else { - $exif = false; $showmeta = false; } @@ -64,7 +74,7 @@ class ImagePage extends Article { # Show shared description, if needed if ( $this->mExtraDescription ) { $fol = wfMsg( 'shareddescriptionfollows' ); - if( $fol != '-' ) { + if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) { $wgOut->addWikiText( $fol ); } $wgOut->addHTML( '
' ); @@ -74,12 +84,12 @@ class ImagePage extends Article { $this->imageHistory(); $this->imageLinks(); - if ( $exif ) { + if ( $showmeta ) { global $wgStylePath, $wgStyleVersion; $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) ); $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) ); $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ). "\n" ); - $wgOut->addWikiText( $this->makeMetadataTable( $exif ) ); + $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) ); $wgOut->addHTML( "\n" . "\n" ); @@ -98,9 +108,9 @@ class ImagePage extends Article { global $wgLang; $r = '' );
}
- $wgOut->addHTML( ' ' . $anchoropen .
- " ' );
+ if ( $thumbnail ) {
+ $options = array(
+ 'alt' => $this->img->getTitle()->getPrefixedText(),
+ 'file-link' => true,
+ );
+ $wgOut->addHTML( '' .
+ $thumbnail->toHtml( $options ) .
+ $anchorclose . ' ' );
+ }
if ( $this->img->isMultipage() ) {
$count = $this->img->pageCount();
if ( $page > 1 ) {
$label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
- $link = $sk->makeLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
- $this->img->selectPage( $page - 1 );
- $thumb1 = $sk->makeThumbLinkObj( $this->img, $link, $label, 'none' );
+ $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
+ $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
+ array( 'page' => $page - 1 ) );
} else {
$thumb1 = '';
}
if ( $page < $count ) {
$label = wfMsg( 'imgmultipagenext' );
- $this->img->selectPage( $page + 1 );
- $link = $sk->makeLinkObj( $this->mTitle, $label, 'page='. ($page+1) );
- $thumb2 = $sk->makeThumbLinkObj( $this->img, $link, $label, 'none' );
+ $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page+1) );
+ $thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
+ array( 'page' => $page + 1 ) );
} else {
$thumb2 = '';
}
- $select = '';
$wgOut->addHTML( ' |
" . wfMsg( 'imghistlegend' ) . "
\n".'