X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FImagePage.php;h=fc3bdff5e82cfbf5a535e24c78102875aa03c5c0;hb=843738b4cd68d2e3121430237de085a6dd9df8eb;hp=8bd94eeaf384dcbd08b72e0da8318e98b044fab1;hpb=b212bace90bf0c6e34308b8805c127350467c981;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 8bd94eeaf3..fc3bdff5e8 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -1,4 +1,25 @@ fileLoaded ) { - return true; + return; } $this->fileLoaded = true; @@ -74,19 +96,21 @@ class ImagePage extends Article { * Include body text only; none of the image extras */ public function render() { - global $wgOut; - $wgOut->setArticleBodyOnly( true ); + $this->getContext()->setArticleBodyOnly( true ); parent::view(); } public function view() { - global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; + global $wgShowEXIF; - $diff = $wgRequest->getVal( 'diff' ); - $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) ); + $out = $this->getContext()->getOutput(); + $request = $this->getContext()->getRequest(); + $diff = $request->getVal( 'diff' ); + $diffOnly = $request->getBool( 'diffonly', $this->getContext()->getUser()->getOption( 'diffonly' ) ); if ( $this->getTitle()->getNamespace() != NS_FILE || ( isset( $diff ) && $diffOnly ) ) { - return parent::view(); + parent::view(); + return; } $this->loadFile(); @@ -95,21 +119,20 @@ class ImagePage extends Article { if ( $this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || isset( $diff ) ) { // mTitle is the same as the redirect target so ask Article // to perform the redirect for us. - $wgRequest->setVal( 'diffonly', 'true' ); - return parent::view(); + $request->setVal( 'diffonly', 'true' ); + parent::view(); + return; } else { // mTitle is not the same as the redirect target so it is // probably the redirect page itself. Fake the redirect symbol - $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() ); - $wgOut->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ), + $out->setPageTitle( $this->getTitle()->getPrefixedText() ); + $out->addHTML( $this->viewRedirect( Title::makeTitle( NS_FILE, $this->mPage->getFile()->getName() ), /* $appendSubtitle */ true, /* $forceKnown */ true ) ); - $this->mPage->viewUpdates(); + $this->mPage->doViewUpdates( $this->getContext()->getUser() ); return; } } - $this->showRedirectedFromHeader(); - if ( $wgShowEXIF && $this->displayImg->exists() ) { // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata(). $formattedMetadata = $this->displayImg->formatMetadata(); @@ -119,7 +142,7 @@ class ImagePage extends Article { } if ( !$diff && $this->displayImg->exists() ) { - $wgOut->addHTML( $this->showTOC( $showmeta ) ); + $out->addHTML( $this->showTOC( $showmeta ) ); } if ( !$diff ) { @@ -131,32 +154,32 @@ class ImagePage extends Article { # NS_FILE is in the user language, but this section (the actual wikitext) # should be in page content language $pageLang = $this->getTitle()->getPageLanguage(); - $wgOut->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content', + $out->addHTML( Xml::openElement( 'div', array( 'id' => 'mw-imagepage-content', 'lang' => $pageLang->getCode(), 'dir' => $pageLang->getDir(), 'class' => 'mw-content-'.$pageLang->getDir() ) ) ); parent::view(); - $wgOut->addHTML( Xml::closeElement( 'div' ) ); + $out->addHTML( Xml::closeElement( 'div' ) ); } else { # Just need to set the right headers - $wgOut->setArticleFlag( true ); - $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() ); - $this->mPage->viewUpdates(); + $out->setArticleFlag( true ); + $out->setPageTitle( $this->getTitle()->getPrefixedText() ); + $this->mPage->doViewUpdates( $this->getContext()->getUser() ); } # Show shared description, if needed if ( $this->mExtraDescription ) { $fol = wfMessage( 'shareddescriptionfollows' ); if ( !$fol->isDisabled() ) { - $wgOut->addWikiText( $fol->plain() ); + $out->addWikiText( $fol->plain() ); } - $wgOut->addHTML( '
\n" ); + $out->addHTML( ' \n" ); } $this->closeShowImage(); $this->imageHistory(); // TODO: Cleanup the following - $wgOut->addHTML( Xml::element( 'h2', + $out->addHTML( Xml::element( 'h2', array( 'id' => 'filelinks' ), wfMsg( 'imagelinks' ) ) . "\n" ); $this->imageDupes(); @@ -168,26 +191,29 @@ class ImagePage extends Article { $html = ''; wfRunHooks( 'ImagePageAfterImageLinks', array( $this, &$html ) ); if ( $html ) { - $wgOut->addHTML( $html ); + $out->addHTML( $html ); } if ( $showmeta ) { - $wgOut->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" ); - $wgOut->addWikiText( $this->makeMetadataTable( $formattedMetadata ) ); - $wgOut->addModules( array( 'mediawiki.action.view.metadata' ) ); + $out->addHTML( Xml::element( 'h2', array( 'id' => 'metadata' ), wfMsg( 'metadata' ) ) . "\n" ); + $out->addWikiText( $this->makeMetadataTable( $formattedMetadata ) ); + $out->addModules( array( 'mediawiki.action.view.metadata' ) ); } // Add remote Filepage.css if( !$this->repo->isLocal() ) { $css = $this->repo->getDescriptionStylesheetUrl(); if ( $css ) { - $wgOut->addStyle( $css ); + $out->addStyle( $css ); } } // always show the local local Filepage.css, bug 29277 - $wgOut->addModuleStyles( 'filepage' ); + $out->addModuleStyles( 'filepage' ); } + /** + * @return File + */ public function getDisplayedFile() { $this->loadFile(); return $this->displayImg; @@ -247,6 +273,7 @@ class ImagePage extends Article { * * Omit noarticletext if sharedupload; text will be fetched from the * shared upload server if possible. + * @return string */ public function getContent() { $this->loadFile(); @@ -257,12 +284,16 @@ class ImagePage extends Article { } protected function openShowImage() { - global $wgOut, $wgUser, $wgImageLimits, $wgRequest, - $wgLang, $wgEnableUploads; + global $wgImageLimits, $wgEnableUploads, $wgSend404Code; $this->loadFile(); + $out = $this->getContext()->getOutput(); + $user = $this->getContext()->getUser(); + $lang = $this->getContext()->getLanguage(); + $dirmark = $lang->getDirMarkEntity(); + $request = $this->getContext()->getRequest(); - $sizeSel = intval( $wgUser->getOption( 'imagesize' ) ); + $sizeSel = intval( $user->getOption( 'imagesize' ) ); if ( !isset( $wgImageLimits[$sizeSel] ) ) { $sizeSel = User::getDefaultOption( 'imagesize' ); @@ -276,11 +307,10 @@ class ImagePage extends Article { $max = $wgImageLimits[$sizeSel]; $maxWidth = $max[0]; $maxHeight = $max[1]; - $dirmark = $wgLang->getDirMark(); if ( $this->displayImg->exists() ) { # image - $page = $wgRequest->getIntOrNull( 'page' ); + $page = $request->getIntOrNull( 'page' ); if ( is_null( $page ) ) { $params = array(); $page = 1; @@ -294,7 +324,7 @@ class ImagePage extends Article { $longDesc = wfMsg( 'parentheses', $this->displayImg->getLongDesc() ); - wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$wgOut ) ); + wfRunHooks( 'ImageOpenShowImageInlineBefore', array( &$this, &$out ) ); if ( $this->displayImg->allowInlineDisplay() ) { # image @@ -326,11 +356,18 @@ class ImagePage extends Article { } $msgsmall = wfMessage( 'show-big-image-preview' )-> rawParams( $this->makeSizeLink( $params, $width, $height ) )-> - parse() . ' ' . + parse(); + if ( count( $otherSizes ) && $this->displayImg->getRepo()->canTransformVia404() ) { + $msgsmall .= ' ' . Html::rawElement( 'span', array( 'class' => 'mw-filepage-other-resolutions' ), - wfMessage( 'show-big-image-other' )-> - rawParams( $wgLang->pipeList( $otherSizes ), count( $otherSizes ) )->parse() + wfMessage( 'show-big-image-other' )->rawParams( $lang->pipeList( $otherSizes ) )-> + params( count( $otherSizes ) )->parse() ); + } + } elseif ( $width == 0 && $height == 0 ){ + # Some sort of audio file that doesn't have dimensions + # Don't output a no hi res message for such a file + $msgsmall = ''; } else { # Image is small enough to show full size on image page $msgsmall = wfMessage( 'file-nohires' )->parse(); @@ -345,7 +382,7 @@ class ImagePage extends Article { $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; if ( $isMulti ) { - $wgOut->addHTML( '' );
+ $out->addHTML( '
$thumb1\n$thumb2 |