protected function openShowImage() { global $wgOut, $wgUser, $wgImageLimits, $wgRequest, $wgLang, $wgEnableUploads; $this->loadFile(); $sizeSel = intval($wgUser->getOption('imagesize')); if (!isset($wgImageLimits[$sizeSel])) { $sizeSel = User::getDefaultOption('imagesize'); // The user offset might still be incorrect, specially if // $wgImageLimits got changed (see bug #8858). if (!isset($wgImageLimits[$sizeSel])) { // Default to the first offset in $wgImageLimits $sizeSel = 0; } } $max = $wgImageLimits[$sizeSel]; $maxWidth = $max[0]; $maxHeight = $max[1]; $dirmark = $wgLang->getDirMark(); if ($this->displayImg->exists()) { # image $page = $wgRequest->getIntOrNull('page'); if (is_null($page)) { $params = array(); $page = 1; } else { $params = array('page' => $page); } $width_orig = $this->displayImg->getWidth($page); $width = $width_orig; $height_orig = $this->displayImg->getHeight($page); $height = $height_orig; $longDesc = wfMsg('parentheses', $this->displayImg->getLongDesc()); wfRunHooks('ImageOpenShowImageInlineBefore', array(&$this, &$wgOut)); if ($this->displayImg->allowInlineDisplay()) { # image # "Download high res version" link below the image # $msgsize = wfMsgHtml( 'file-info-size', $width_orig, $height_orig, Linker::formatSize( $this->displayImg->getSize() ), $mime ); # We'll show a thumbnail of this image if ($width > $maxWidth || $height > $maxHeight) { # Calculate the thumbnail size. # First case, the limiting factor is the width, not the height. if ($width / $height >= $maxWidth / $maxHeight) { $height = round($height * $maxWidth / $width); $width = $maxWidth; # Note that $height <= $maxHeight now. } else { $newwidth = floor($width * $maxHeight / $height); $height = round($height * $newwidth / $width); $width = $newwidth; # Note that $height <= $maxHeight now, but might not be identical # because of rounding. } $msgbig = wfMsgHtml('show-big-image'); $otherSizes = array(); foreach ($wgImageLimits as $size) { if ($size[0] < $width_orig && $size[1] < $height_orig && $size[0] != $width && $size[1] != $height) { $otherSizes[] = $this->makeSizeLink($params, $size[0], $size[1]); } } $msgsmall = wfMessage('show-big-image-preview')->rawParams($this->makeSizeLink($params, $width, $height))->parse() . ' ' . wfMessage('show-big-image-other')->rawParams($wgLang->pipeList($otherSizes))->parse(); } else { # Image is small enough to show full size on image page $msgsmall = wfMsgExt('file-nohires', array('parseinline')); } $params['width'] = $width; $params['height'] = $height; $thumbnail = $this->displayImg->transform($params); $showLink = true; $anchorclose = '<br />' . $msgsmall; $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1; if ($isMulti) { $wgOut->addHTML('<table class="multipageimage"><tr><td>'); } if ($thumbnail) { $options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true); $wgOut->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n"); } if ($isMulti) { $count = $this->displayImg->pageCount(); if ($page > 1) { $label = $wgOut->parse(wfMsg('imgmultipageprev'), false); $link = Linker::link($this->getTitle(), $label, array(), array('page' => $page - 1), array('known', 'noclasses')); $thumb1 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page - 1)); } else { $thumb1 = ''; } if ($page < $count) { $label = wfMsg('imgmultipagenext'); $link = Linker::link($this->getTitle(), $label, array(), array('page' => $page + 1), array('known', 'noclasses')); $thumb2 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page + 1)); } else { $thumb2 = ''; } global $wgScript; $formParams = array('name' => 'pageselector', 'action' => $wgScript, 'onchange' => 'document.pageselector.submit();'); for ($i = 1; $i <= $count; $i++) { $options[] = Xml::option($wgLang->formatNum($i), $i, $i == $page); } $select = Xml::tags('select', array('id' => 'pageselector', 'name' => 'page'), implode("\n", $options)); $wgOut->addHTML('</td><td><div class="multipageimagenavbox">' . Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . wfMsgExt('imgmultigoto', array('parseinline', 'replaceafter'), $select) . Xml::submitButton(wfMsg('imgmultigo')) . Xml::closeElement('form') . "<hr />{$thumb1}\n{$thumb2}<br clear=\"all\" /></div></td></tr></table>"); } } else { # if direct link is allowed but it's not a renderable image, show an icon. if ($this->displayImg->isSafeFile()) { $icon = $this->displayImg->iconThumb(); $wgOut->addHTML('<div class="fullImageLink" id="file">' . $icon->toHtml(array('file-link' => true)) . "</div>\n"); } $showLink = true; } if ($showLink) { $filename = wfEscapeWikiText($this->displayImg->getName()); $linktext = $filename; if (isset($msgbig)) { $linktext = wfEscapeWikiText($msgbig); } $url = $this->displayImg->getFullUrl(); $medialink = Html::rawElement('a', array('href' => $url, 'class' => 'medialink'), $linktext); $mediafield = Xml::inputLabel(wfMessage('fileurl')->text(), 'fileurl', 'fileurl', null, $url); $mediafield = Html::rawElement('div', array('class' => 'mediafield'), $mediafield); if (!$this->displayImg->isSafeFile()) { $warning = wfMessage('mediawarning')->parse(); $wgOut->addHtml('<div class="fullMedia"><span class="dangerousLink">' . $medialink . '</span><span class="fileInfo">' . $longDesc . '</span>' . $mediafield . '</div> <div class="mediaWarning">' . $warning . '</div>'); } else { $wgOut->addHtml('<div class="fullMedia">' . $medialink . '<span class="fileInfo">' . $longDesc . '</span>' . $mediafield . '</div>'); } } if (!$this->displayImg->isLocal()) { $this->printSharedImageText(); } } else { # Image does not exist # PATCH FOR SEIZAM if ($wgEnableUploads && $this->getTitle()->userCan('upload')) { # /PATCH FOR SEIZAM // Only show an upload link if the user can upload $uploadTitle = SpecialPage::getTitleFor('Upload'); $nofile = array('filepage-nofile-link', $uploadTitle->getFullURL(array('wpDestFile' => $this->mPage->getFile()->getName()))); } else { $nofile = 'filepage-nofile'; } // Note, if there is an image description page, but // no image, then this setRobotPolicy is overriden // by Article::View(). $wgOut->setRobotPolicy('noindex,nofollow'); $wgOut->wrapWikiMsg("<div id='mw-imagepage-nofile' class='plainlinks'>\n\$1\n</div>", $nofile); if (!$this->getID()) { // 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'); } } $wgOut->setFileVersion($this->displayImg); }