/**
  * @return string
  */
 function getBody()
 {
     $s = '';
     $this->doQuery();
     if (count($this->mHist)) {
         if ($this->mImg->isLocal()) {
             // Do a batch existence check for user pages and talkpages
             $linkBatch = new LinkBatch();
             for ($i = $this->mRange[0]; $i <= $this->mRange[1]; $i++) {
                 $file = $this->mHist[$i];
                 $user = $file->getUser('text');
                 $linkBatch->add(NS_USER, $user);
                 $linkBatch->add(NS_USER_TALK, $user);
             }
             $linkBatch->execute();
         }
         $list = new ImageHistoryList($this->mImagePage);
         # Generate prev/next links
         $navLink = $this->getNavigationBar();
         $s = $list->beginImageHistoryList($navLink);
         // Skip rows there just for paging links
         for ($i = $this->mRange[0]; $i <= $this->mRange[1]; $i++) {
             $file = $this->mHist[$i];
             $s .= $list->imageHistoryLine(!$file->isOld(), $file);
         }
         $s .= $list->endImageHistoryList($navLink);
         if ($list->getPreventClickjacking()) {
             $this->preventClickjacking();
         }
     }
     return $s;
 }
 /**
  * get video data from file
  * @param File $file
  * @param boolean $premiumOnly
  * @return array|null  $video
  */
 public function getVideoDataByFile($file, $premiumOnly = false)
 {
     $app = F::app();
     $app->wf->ProfileIn(__METHOD__);
     $video = null;
     if ($file instanceof File && $file->exists() && F::build('WikiaFileHelper', array($file), 'isFileTypeVideo')) {
         if (!($premiumOnly && $file->isLocal())) {
             $fileMetadata = $file->getMetadata();
             $userId = $file->getUser('id');
             $addedAt = $file->getTimestamp() ? $file->getTimestamp() : $this->wf->Timestamp(TS_MW);
             $duration = 0;
             $hdfile = 0;
             if ($fileMetadata) {
                 $fileMetadata = unserialize($fileMetadata);
                 if (array_key_exists('duration', $fileMetadata)) {
                     $duration = $fileMetadata['duration'];
                 }
                 if (array_key_exists('hd', $fileMetadata)) {
                     $hdfile = $fileMetadata['hd'] ? 1 : 0;
                 }
             }
             $premium = $file->isLocal() ? 0 : 1;
             $video = array('videoTitle' => $file->getTitle()->getDBKey(), 'addedAt' => $addedAt, 'addedBy' => $userId, 'duration' => $duration, 'premium' => $premium, 'hdfile' => $hdfile);
         }
     }
     $app->wf->ProfileOut(__METHOD__);
     return $video;
 }
Example #3
0
 /**
  * @param $iscur
  * @param $file File
  * @return string
  */
 public function imageHistoryLine($iscur, $file)
 {
     global $wgContLang;
     $user = $this->getUser();
     $lang = $this->getLanguage();
     $timestamp = wfTimestamp(TS_MW, $file->getTimestamp());
     $img = $iscur ? $file->getName() : $file->getArchiveName();
     $userId = $file->getUser('id');
     $userText = $file->getUser('text');
     $description = $file->getDescription(File::FOR_THIS_USER, $user);
     $local = $this->current->isLocal();
     $row = $selected = '';
     // Deletion link
     if ($local && $user->isAllowedAny('delete', 'deletedhistory')) {
         $row .= '<td>';
         # Link to remove from history
         if ($user->isAllowed('delete')) {
             $q = array('action' => 'delete');
             if (!$iscur) {
                 $q['oldimage'] = $img;
             }
             $row .= Linker::linkKnown($this->title, $this->msg($iscur ? 'filehist-deleteall' : 'filehist-deleteone')->escaped(), array(), $q);
         }
         # Link to hide content. Don't show useless link to people who cannot hide revisions.
         $canHide = $user->isAllowed('deleterevision');
         if ($canHide || $user->isAllowed('deletedhistory') && $file->getVisibility()) {
             if ($user->isAllowed('delete')) {
                 $row .= '<br />';
             }
             // If file is top revision or locked from this user, don't link
             if ($iscur || !$file->userCan(File::DELETED_RESTRICTED, $user)) {
                 $del = Linker::revDeleteLinkDisabled($canHide);
             } else {
                 list($ts, ) = explode('!', $img, 2);
                 $query = array('type' => 'oldimage', 'target' => $this->title->getPrefixedText(), 'ids' => $ts);
                 $del = Linker::revDeleteLink($query, $file->isDeleted(File::DELETED_RESTRICTED), $canHide);
             }
             $row .= $del;
         }
         $row .= '</td>';
     }
     // Reversion link/current indicator
     $row .= '<td>';
     if ($iscur) {
         $row .= $this->msg('filehist-current')->escaped();
     } elseif ($local && $this->title->quickUserCan('edit', $user) && $this->title->quickUserCan('upload', $user)) {
         if ($file->isDeleted(File::DELETED_FILE)) {
             $row .= $this->msg('filehist-revert')->escaped();
         } else {
             $row .= Linker::linkKnown($this->title, $this->msg('filehist-revert')->escaped(), array(), array('action' => 'revert', 'oldimage' => $img, 'wpEditToken' => $user->getEditToken($img)));
         }
     }
     $row .= '</td>';
     // Date/time and image link
     if ($file->getTimestamp() === $this->img->getTimestamp()) {
         $selected = "class='filehistory-selected'";
     }
     $row .= "<td {$selected} style='white-space: nowrap;'>";
     if (!$file->userCan(File::DELETED_FILE, $user)) {
         # Don't link to unviewable files
         $row .= '<span class="history-deleted">' . $lang->userTimeAndDate($timestamp, $user) . '</span>';
     } elseif ($file->isDeleted(File::DELETED_FILE)) {
         if ($local) {
             $this->preventClickjacking();
             $revdel = SpecialPage::getTitleFor('Revisiondelete');
             # Make a link to review the image
             $url = Linker::linkKnown($revdel, $lang->userTimeAndDate($timestamp, $user), array(), array('target' => $this->title->getPrefixedText(), 'file' => $img, 'token' => $user->getEditToken($img)));
         } else {
             $url = $lang->userTimeAndDate($timestamp, $user);
         }
         $row .= '<span class="history-deleted">' . $url . '</span>';
     } else {
         $url = $iscur ? $this->current->getUrl() : $this->current->getArchiveUrl($img);
         $row .= Xml::element('a', array('href' => $url), $lang->userTimeAndDate($timestamp, $user));
     }
     $row .= "</td>";
     // Thumbnail
     if ($this->showThumb) {
         $row .= '<td>' . $this->getThumbForLine($file) . '</td>';
     }
     // Image dimensions + size
     $row .= '<td>';
     $row .= htmlspecialchars($file->getDimensionsString());
     $row .= $this->msg('word-separator')->plain();
     $row .= '<span style="white-space: nowrap;">';
     $row .= $this->msg('parentheses')->rawParams(Linker::formatSize($file->getSize()))->plain();
     $row .= '</span>';
     $row .= '</td>';
     // Uploading user
     $row .= '<td>';
     // Hide deleted usernames
     if ($file->isDeleted(File::DELETED_USER)) {
         $row .= '<span class="history-deleted">' . $this->msg('rev-deleted-user')->escaped() . '</span>';
     } else {
         if ($local) {
             $row .= Linker::userLink($userId, $userText);
             $row .= $this->msg('word-separator')->plain();
             $row .= '<span style="white-space: nowrap;">';
             $row .= Linker::userToolLinks($userId, $userText);
             $row .= '</span>';
         } else {
             $row .= htmlspecialchars($userText);
         }
     }
     $row .= '</td>';
     // Don't show deleted descriptions
     if ($file->isDeleted(File::DELETED_COMMENT)) {
         $row .= '<td><span class="history-deleted">' . $this->msg('rev-deleted-comment')->escaped() . '</span></td>';
     } else {
         $row .= '<td dir="' . $wgContLang->getDir() . '">' . Linker::formatComment($description, $this->title) . '</td>';
     }
     $rowClass = null;
     wfRunHooks('ImagePageFileHistoryLine', array($this, $file, &$row, &$rowClass));
     $classAttr = $rowClass ? " class='{$rowClass}'" : '';
     return "<tr{$classAttr}>{$row}</tr>\n";
 }
Example #4
0
 /**
  * @return bool
  */
 public function isLocal()
 {
     $this->loadFile();
     return $this->mFile->isLocal();
 }
 /**
  *
  * @param Skin $skin
  * @param File $result
  * @return string HTML
  */
 function formatResult($skin, $result)
 {
     global $wgContLang;
     $nt = $result->getTitle();
     $text = $wgContLang->convert($nt->getText());
     $plink = Linker::link($nt, htmlspecialchars($text));
     $userText = $result->getUser('text');
     if ($result->isLocal()) {
         $userId = $result->getUser('id');
         $user = Linker::userLink($userId, $userText);
         $user .= '<span style="white-space: nowrap;">';
         $user .= Linker::userToolLinks($userId, $userText);
         $user .= '</span>';
     } else {
         $user = htmlspecialchars($userText);
     }
     $time = htmlspecialchars($this->getLanguage()->userTimeAndDate($result->getTimestamp(), $this->getUser()));
     return "{$plink} . . {$user} . . {$time}";
 }
Example #6
0
 /**
  * Could we delete the file specified? If an `oldimage`
  * value was provided, does it correspond to an
  * existing, local, old version of this file?
  *
  * @param File $file
  * @param File $oldfile
  * @param File $oldimage
  * @return bool
  */
 public static function haveDeletableFile(&$file, &$oldfile, $oldimage)
 {
     return $oldimage ? $oldfile && $oldfile->exists() && $oldfile->isLocal() : $file && $file->exists() && $file->isLocal();
 }
Example #7
0
    protected function openShowImage()
    {
        global $wgEnableUploads, $wgSend404Code, $wgSVGMaxSize;
        $this->loadFile();
        $out = $this->getContext()->getOutput();
        $user = $this->getContext()->getUser();
        $lang = $this->getContext()->getLanguage();
        $dirmark = $lang->getDirMarkEntity();
        $request = $this->getContext()->getRequest();
        $max = $this->getImageLimitsFromOption($user, 'imagesize');
        $maxWidth = $max[0];
        $maxHeight = $max[1];
        if ($this->displayImg->exists()) {
            # image
            $page = $request->getIntOrNull('page');
            if (is_null($page)) {
                $params = array();
                $page = 1;
            } else {
                $params = array('page' => $page);
            }
            $renderLang = $request->getVal('lang');
            if (!is_null($renderLang)) {
                $handler = $this->displayImg->getHandler();
                if ($handler && $handler->validateParam('lang', $renderLang)) {
                    $params['lang'] = $renderLang;
                } else {
                    $renderLang = null;
                }
            }
            $width_orig = $this->displayImg->getWidth($page);
            $width = $width_orig;
            $height_orig = $this->displayImg->getHeight($page);
            $height = $height_orig;
            $filename = wfEscapeWikiText($this->displayImg->getName());
            $linktext = $filename;
            Hooks::run('ImageOpenShowImageInlineBefore', array(&$this, &$out));
            if ($this->displayImg->allowInlineDisplay()) {
                # image
                # "Download high res version" link below the image
                # $msgsize = $this->getContext()->msg( 'file-info-size', $width_orig, $height_orig,
                #   Linker::formatSize( $this->displayImg->getSize() ), $mime )->escaped();
                # We'll show a thumbnail of this image
                if ($width > $maxWidth || $height > $maxHeight || $this->displayImg->isVectorized()) {
                    list($width, $height) = $this->getDisplayWidthHeight($maxWidth, $maxHeight, $width, $height);
                    $linktext = $this->getContext()->msg('show-big-image')->escaped();
                    $thumbSizes = $this->getThumbSizes($width_orig, $height_orig);
                    # Generate thumbnails or thumbnail links as needed...
                    $otherSizes = array();
                    foreach ($thumbSizes as $size) {
                        // We include a thumbnail size in the list, if it is
                        // less than or equal to the original size of the image
                        // asset ($width_orig/$height_orig). We also exclude
                        // the current thumbnail's size ($width/$height)
                        // since that is added to the message separately, so
                        // it can be denoted as the current size being shown.
                        // Vectorized images are limited by $wgSVGMaxSize big,
                        // so all thumbs less than or equal that are shown.
                        if (($size[0] <= $width_orig && $size[1] <= $height_orig || $this->displayImg->isVectorized() && max($size[0], $size[1]) <= $wgSVGMaxSize) && $size[0] != $width && $size[1] != $height) {
                            $sizeLink = $this->makeSizeLink($params, $size[0], $size[1]);
                            if ($sizeLink) {
                                $otherSizes[] = $sizeLink;
                            }
                        }
                    }
                    $otherSizes = array_unique($otherSizes);
                    $sizeLinkBigImagePreview = $this->makeSizeLink($params, $width, $height);
                    $msgsmall = $this->getThumbPrevText($params, $sizeLinkBigImagePreview);
                    if (count($otherSizes)) {
                        $msgsmall .= ' ' . Html::rawElement('span', array('class' => 'mw-filepage-other-resolutions'), $this->getContext()->msg('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 = $this->getContext()->msg('file-nohires')->parse();
                }
                $params['width'] = $width;
                $params['height'] = $height;
                $thumbnail = $this->displayImg->transform($params);
                Linker::processResponsiveImages($this->displayImg, $thumbnail, $params);
                $anchorclose = Html::rawElement('div', array('class' => 'mw-filepage-resolutioninfo'), $msgsmall);
                $isMulti = $this->displayImg->isMultipage() && $this->displayImg->pageCount() > 1;
                if ($isMulti) {
                    $out->addModules('mediawiki.page.image.pagination');
                    $out->addHTML('<table class="multipageimage"><tr><td>');
                }
                if ($thumbnail) {
                    $options = array('alt' => $this->displayImg->getTitle()->getPrefixedText(), 'file-link' => true);
                    $out->addHTML('<div class="fullImageLink" id="file">' . $thumbnail->toHtml($options) . $anchorclose . "</div>\n");
                }
                if ($isMulti) {
                    $count = $this->displayImg->pageCount();
                    if ($page > 1) {
                        $label = $out->parse($this->getContext()->msg('imgmultipageprev')->text(), false);
                        // on the client side, this link is generated in ajaxifyPageNavigation()
                        // in the mediawiki.page.image.pagination module
                        $link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page - 1));
                        $thumb1 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page - 1));
                    } else {
                        $thumb1 = '';
                    }
                    if ($page < $count) {
                        $label = $this->getContext()->msg('imgmultipagenext')->text();
                        $link = Linker::linkKnown($this->getTitle(), $label, array(), array('page' => $page + 1));
                        $thumb2 = Linker::makeThumbLinkObj($this->getTitle(), $this->displayImg, $link, $label, 'none', array('page' => $page + 1));
                    } else {
                        $thumb2 = '';
                    }
                    global $wgScript;
                    $formParams = array('name' => 'pageselector', 'action' => $wgScript);
                    $options = array();
                    for ($i = 1; $i <= $count; $i++) {
                        $options[] = Xml::option($lang->formatNum($i), $i, $i == $page);
                    }
                    $select = Xml::tags('select', array('id' => 'pageselector', 'name' => 'page'), implode("\n", $options));
                    $out->addHTML('</td><td><div class="multipageimagenavbox">' . Xml::openElement('form', $formParams) . Html::hidden('title', $this->getTitle()->getPrefixedDBkey()) . $this->getContext()->msg('imgmultigoto')->rawParams($select)->parse() . Xml::submitButton($this->getContext()->msg('imgmultigo')->text()) . Xml::closeElement('form') . "<hr />{$thumb1}\n{$thumb2}<br style=\"clear: both\" /></div></td></tr></table>");
                }
            } elseif ($this->displayImg->isSafeFile()) {
                # if direct link is allowed but it's not a renderable image, show an icon.
                $icon = $this->displayImg->iconThumb();
                $out->addHTML('<div class="fullImageLink" id="file">' . $icon->toHtml(array('file-link' => true)) . "</div>\n");
            }
            $longDesc = $this->getContext()->msg('parentheses', $this->displayImg->getLongDesc())->text();
            $handler = $this->displayImg->getHandler();
            // If this is a filetype with potential issues, warn the user.
            if ($handler) {
                $warningConfig = $handler->getWarningConfig($this->displayImg);
                if ($warningConfig !== null) {
                    // The warning will be displayed via CSS and JavaScript.
                    // We just need to tell the client side what message to use.
                    $output = $this->getContext()->getOutput();
                    $output->addJsConfigVars('wgFileWarning', $warningConfig);
                    $output->addModules($warningConfig['module']);
                    $output->addModules('mediawiki.filewarning');
                }
            }
            $medialink = "[[Media:{$filename}|{$linktext}]]";
            if (!$this->displayImg->isSafeFile()) {
                $warning = $this->getContext()->msg('mediawarning')->plain();
                // dirmark is needed here to separate the file name, which
                // most likely ends in Latin characters, from the description,
                // which may begin with the file type. In RTL environment
                // this will get messy.
                // The dirmark, however, must not be immediately adjacent
                // to the filename, because it can get copied with it.
                // See bug 25277.
                // @codingStandardsIgnoreStart Ignore long line
                $out->addWikiText(<<<EOT
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span> {$dirmark}<span class="fileInfo">{$longDesc}</span></div>
<div class="mediaWarning">{$warning}</div>
EOT
);
                // @codingStandardsIgnoreEnd
            } else {
                $out->addWikiText(<<<EOT
<div class="fullMedia">{$medialink} {$dirmark}<span class="fileInfo">{$longDesc}</span>
</div>
EOT
);
            }
            $renderLangOptions = $this->displayImg->getAvailableLanguages();
            if (count($renderLangOptions) >= 1) {
                $currentLanguage = $renderLang;
                $defaultLang = $this->displayImg->getDefaultRenderLanguage();
                if (is_null($currentLanguage)) {
                    $currentLanguage = $defaultLang;
                }
                $out->addHtml($this->doRenderLangOpt($renderLangOptions, $currentLanguage, $defaultLang));
            }
            // Add cannot animate thumbnail warning
            if (!$this->displayImg->canAnimateThumbIfAppropriate()) {
                // Include the extension so wiki admins can
                // customize it on a per file-type basis
                // (aka say things like use format X instead).
                // additionally have a specific message for
                // file-no-thumb-animation-gif
                $ext = $this->displayImg->getExtension();
                $noAnimMesg = wfMessageFallback('file-no-thumb-animation-' . $ext, 'file-no-thumb-animation')->plain();
                $out->addWikiText(<<<EOT
<div class="mw-noanimatethumb">{$noAnimMesg}</div>
EOT
);
            }
            if (!$this->displayImg->isLocal()) {
                $this->printSharedImageText();
            }
        } else {
            # Image does not exist
            if (!$this->getID()) {
                # No article exists either
                # Show deletion log to be consistent with normal articles
                LogEventsList::showLogExtract($out, array('delete', 'move'), $this->getTitle()->getPrefixedText(), '', array('lim' => 10, 'conds' => array("log_action != 'revision'"), 'showIfEmpty' => false, 'msgKey' => array('moveddeleted-notice')));
            }
            if ($wgEnableUploads && $user->isAllowed('upload')) {
                // 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 overridden
            // by Article::View().
            $out->setRobotPolicy('noindex,nofollow');
            $out->wrapWikiMsg("<div id='mw-imagepage-nofile' class='plainlinks'>\n\$1\n</div>", $nofile);
            if (!$this->getID() && $wgSend404Code) {
                // If there is no image, no shared image, and no description page,
                // output a 404, to be consistent with Article::showMissingArticle.
                $request->response()->statusHeader(404);
            }
        }
        $out->setFileVersion($this->displayImg);
    }
 /**
  * Check if the premium video is added to the wiki
  * @param File $file
  * @return boolean $isAdded
  */
 public static function isAdded($file)
 {
     $isAdded = true;
     if ($file instanceof File && !$file->isLocal() && F::app()->wg->WikiaVideoRepoDBName == $file->getRepo()->getWiki()) {
         $info = VideoInfo::newFromTitle($file->getTitle()->getDBkey());
         if (empty($info)) {
             $isAdded = false;
         }
     }
     return $isAdded;
 }
    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);
                }
                $medialink = "[[Media:{$filename}|{$linktext}]]";
                if (!$this->displayImg->isSafeFile()) {
                    $warning = wfMsgNoTrans('mediawarning');
                    $wgOut->addWikiText(<<<EOT
<div class="fullMedia"><span class="dangerousLink">{$medialink}</span>{$dirmark} <span class="fileInfo">{$longDesc}</span></div>
<div class="mediaWarning">{$warning}</div>
EOT
);
                } else {
                    $wgOut->addWikiText(<<<EOT
<div class="fullMedia">{$medialink}{$dirmark} <span class="fileInfo">{$longDesc}</span>
</div>
EOT
);
                }
            }
            if (!$this->displayImg->isLocal()) {
                $this->printSharedImageText();
            }
        } else {
            # Image does not exist
            if ($wgEnableUploads && $wgUser->isAllowed('upload')) {
                // 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);
    }
 public static function addToFileHistLine($hist, File $file, &$s, &$rowClass)
 {
     if (!$file->isVisible()) {
         return true;
         // Don't bother showing notice for deleted revs
     }
     # Quality level for old versions selected all at once.
     # Commons queries cannot be done all at once...
     if (!$file->isOld() || !$file->isLocal()) {
         $dbr = wfGetDB(DB_SLAVE);
         $quality = $dbr->selectField('flaggedrevs', 'fr_quality', array('fr_img_sha1' => $file->getSha1(), 'fr_img_timestamp' => $dbr->timestamp($file->getTimestamp())), __METHOD__);
     } else {
         $quality = is_null($file->quality) ? false : $file->quality;
     }
     # If reviewed, class the line
     if ($quality !== false) {
         $rowClass = FlaggedRevsXML::getQualityColor($quality);
     }
     return true;
 }