From d9022f63880ce039446fba8364f68e656b7bf4cb Mon Sep 17 00:00:00 2001 From: Pierre Schmitz Date: Thu, 3 May 2012 13:01:35 +0200 Subject: Update to MediaWiki 1.19.0 --- includes/ImagePage.php | 133 ++++++++++++++++++++++++++++++++++++------------- 1 file changed, 98 insertions(+), 35 deletions(-) (limited to 'includes/ImagePage.php') diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 956977e0..dcb09a41 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -18,6 +18,10 @@ class ImagePage extends Article { var $mExtraDescription = false; + /** + * @param $title Title + * @return WikiFilePage + */ protected function newPage( Title $title ) { // Overload mPage with a file-specific page return new WikiFilePage( $title ); @@ -99,13 +103,11 @@ class ImagePage extends Article { $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() ); $wgOut->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(); @@ -136,7 +138,7 @@ class ImagePage extends Article { # Just need to set the right headers $wgOut->setArticleFlag( true ); $wgOut->setPageTitle( $this->getTitle()->getPrefixedText() ); - $this->mPage->viewUpdates(); + $this->mPage->doViewUpdates( $this->getContext()->getUser() ); } # Show shared description, if needed @@ -184,6 +186,9 @@ class ImagePage extends Article { $wgOut->addModuleStyles( 'filepage' ); } + /** + * @return File + */ public function getDisplayedFile() { $this->loadFile(); return $this->displayImg; @@ -243,6 +248,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(); @@ -254,7 +260,7 @@ class ImagePage extends Article { protected function openShowImage() { global $wgOut, $wgUser, $wgImageLimits, $wgRequest, - $wgLang, $wgEnableUploads; + $wgLang, $wgEnableUploads, $wgSend404Code; $this->loadFile(); @@ -322,12 +328,21 @@ class ImagePage extends Article { } $msgsmall = wfMessage( 'show-big-image-preview' )-> rawParams( $this->makeSizeLink( $params, $width, $height ) )-> - parse() . ' ' . - wfMessage( 'show-big-image-other' )-> - rawParams( $wgLang->pipeList( $otherSizes ) )->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 ) )-> + 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 = wfMsgExt( 'file-nohires', array( 'parseinline' ) ); + $msgsmall = wfMessage( 'file-nohires' )->parse(); } $params['width'] = $width; @@ -335,7 +350,7 @@ class ImagePage extends Article { $thumbnail = $this->displayImg->transform( $params ); $showLink = true; - $anchorclose = '
' . $msgsmall; + $anchorclose = Html::rawElement( 'div', array( 'class' => 'mw-filepage-resolutioninfo' ), $msgsmall ); $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; if ( $isMulti ) { @@ -392,7 +407,7 @@ class ImagePage extends Article { 'action' => $wgScript, 'onchange' => 'document.pageselector.submit();', ); - + $options = array(); for ( $i = 1; $i <= $count; $i++ ) { $options[] = Xml::option( $wgLang->formatNum( $i ), $i, $i == $page ); } @@ -407,7 +422,7 @@ class ImagePage extends Article { wfMsgExt( 'imgmultigoto', array( 'parseinline', 'replaceafter' ), $select ) . Xml::submitButton( wfMsg( 'imgmultigo' ) ) . Xml::closeElement( 'form' ) . - "
$thumb1\n$thumb2
" + "
$thumb1\n$thumb2
" ); } } else { @@ -467,7 +482,7 @@ EOT // by Article::View(). $wgOut->setRobotPolicy( 'noindex,nofollow' ); $wgOut->wrapWikiMsg( "", $nofile ); - if ( !$this->getID() ) { + if ( !$this->getID() && $wgSend404Code ) { // If there is no image, no shared image, and no description page, // output a 404, to be consistent with articles. $wgRequest->response()->header( 'HTTP/1.1 404 Not Found' ); @@ -478,9 +493,10 @@ EOT /** * Creates an thumbnail of specified size and returns an HTML link to it - * @param array $params Scaler parameters - * @param int $width - * @param int $height + * @param $params array Scaler parameters + * @param $width int + * @param $height int + * @return string */ private function makeSizeLink( $params, $width, $height ) { $params['width'] = $width; @@ -609,6 +625,11 @@ EOT } } + /** + * @param $target + * @param $limit + * @return ResultWrapper + */ protected function queryImageLinks( $target, $limit ) { $dbr = wfGetDB( DB_SLAVE ); @@ -741,6 +762,9 @@ EOT ); $wgOut->addHTML( "