X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=e31ca15658c9b67c4cfeef2eefea6eac608ae307;hb=91d263ecdf97b51855208dfb4dc3d34e7d814d22;hp=8d58285ee1be4f802b43f5314522d15168acd658;hpb=a26d5a49d755ff4b8039b11d1f26abb5d7bc7e8c;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 8d58285ee1..e31ca15658 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -1,83 +1,96 @@ img = wfFindFile( $this->mTitle ); + if ( !$this->img ) { + $this->img = wfLocalFile( $this->mTitle ); + } + } + + /** + * Handler for action=render + * Include body text only; none of the image extras + */ function render() { global $wgOut; - $wgOut->setArticleBodyOnly(true); - $wgOut->addWikitext($this->getContent(true)); + $wgOut->setArticleBodyOnly( true ); + $wgOut->addSecondaryWikitext( $this->getContent() ); } function view() { - global $wgOut, $wgShowEXIF; + global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; - $this->img = new Image( $this->mTitle ); + $diff = $wgRequest->getVal( 'diff' ); + $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); - if( $this->mTitle->getNamespace() == NS_IMAGE ) { - if ($wgShowEXIF && $this->img->exists()) { - $exif = $this->img->getExifData(); - $showmeta = count($exif) ? true : false; - } else { - $exif = false; - $showmeta = false; - } + if ( $this->mTitle->getNamespace() != NS_IMAGE || ( isset( $diff ) && $diffOnly ) ) + return Article::view(); - if ($this->img->exists()) - $wgOut->addHTML($this->showTOC($showmeta)); + if ($wgShowEXIF && $this->img->exists()) { + $exif = $this->img->getExifData(); + $showmeta = count($exif) ? true : false; + } else { + $exif = false; + $showmeta = false; + } - $this->openShowImage(); + if ($this->img->exists()) + $wgOut->addHTML($this->showTOC($showmeta)); - # No need to display noarticletext, we use our own message, output in openShowImage() - if( $this->getID() ) { - Article::view(); - } else { - # Just need to set the right headers - $wgOut->setArticleFlag( true ); - $wgOut->setRobotpolicy( 'index,follow' ); - $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); - $this->viewUpdates(); - } + $this->openShowImage(); - if ($this->mExtraDescription) { - $fol = wfMsg('shareddescriptionfollows'); - if ($fol != '-') - $wgOut->addWikiText(wfMsg('shareddescriptionfollows')); - $wgOut->addHTML($this->mExtraDescription); + # No need to display noarticletext, we use our own message, output in openShowImage() + if ( $this->getID() ) { + Article::view(); + } else { + # Just need to set the right headers + $wgOut->setArticleFlag( true ); + $wgOut->setRobotpolicy( 'index,follow' ); + $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); + $this->viewUpdates(); + } + + # Show shared description, if needed + if ( $this->mExtraDescription ) { + $fol = wfMsg( 'shareddescriptionfollows' ); + if( $fol != '-' && !wfEmptyMsg( 'shareddescriptionfollows', $fol ) ) { + $wgOut->addWikiText( $fol ); } + $wgOut->addHTML( '
' ); + } - $this->closeShowImage(); - $this->imageHistory(); - $this->imageLinks(); - if( $exif ) { - global $wgStylePath; - $expand = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-expand' ) ) ); - $collapse = htmlspecialchars( wfEscapeJsString( wfMsg( 'metadata-collapse' ) ) ); - $wgOut->addHTML( "' );
+ }
- if( $wgUseImageResize ) {
- $thumbnail = $this->img->getThumbnail( $width );
- if ( $thumbnail == null ) {
- $url = $this->img->getViewURL();
- } else {
- $url = $thumbnail->getURL();
- }
+ $imgAttribs = array(
+ 'border' => 0,
+ 'alt' => $this->img->getTitle()->getPrefixedText()
+ );
+
+ if ( $thumbnail ) {
+ $wgOut->addHTML( ' ' .
+ $thumbnail->toHtml( $imgAttribs, $linkAttribs ) .
+ $anchorclose . ' ' );
+ }
+
+ if ( $this->img->isMultipage() ) {
+ $count = $this->img->pageCount();
+
+ if ( $page > 1 ) {
+ $label = $wgOut->parse( wfMsg( 'imgmultipageprev' ), false );
+ $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page-1) );
+ $thumb1 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none',
+ array( 'page' => $page - 1 ) );
} else {
- # No resize ability? Show the full image, but scale
- # it down in the browser so it fits on the page.
- $url = $this->img->getViewURL();
+ $thumb1 = '';
}
- $anchoropen = "";
- $anchorclose = ""; - if( $this->img->mustRender() ) { - $showLink = true; + + if ( $page < $count ) { + $label = wfMsg( 'imgmultipagenext' ); + $link = $sk->makeKnownLinkObj( $this->mTitle, $label, 'page='. ($page+1) ); + $thumb2 = $sk->makeThumbLinkObj( $this->mTitle, $this->img, $link, $label, 'none', + array( 'page' => $page + 1 ) ); } else { - $anchorclose .= "\n$anchoropen{$msg}"; + $thumb2 = ''; } - } else { - $url = $this->img->getViewURL(); - $showLink = true; + + global $wgScript; + $select = ''; + + $wgOut->addHTML( ' |
" . wfMsg( 'imghistlegend' ) . "
\n".'" . wfMsg( 'imghistlegend' ) . "
\n".'