Example #1
0
 public function view()
 {
     global $wgShowEXIF;
     $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 || $diff !== null && $diffOnly) {
         parent::view();
         return;
     }
     $this->loadFile();
     if ($this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected()) {
         if ($this->getTitle()->getDBkey() == $this->mPage->getFile()->getName() || $diff !== null) {
             // mTitle is the same as the redirect target so ask Article
             // to perform the redirect for us.
             $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
             $out->setPageTitle($this->getTitle()->getPrefixedText());
             $out->addHTML($this->viewRedirect(Title::makeTitle(NS_FILE, $this->mPage->getFile()->getName()), true, true));
             $this->mPage->doViewUpdates($this->getContext()->getUser(), $this->getOldID());
             return;
         }
     }
     if ($wgShowEXIF && $this->displayImg->exists()) {
         // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
         $formattedMetadata = $this->displayImg->formatMetadata();
         $showmeta = $formattedMetadata !== false;
     } else {
         $showmeta = false;
     }
     if (!$diff && $this->displayImg->exists()) {
         $out->addHTML($this->showTOC($showmeta));
     }
     if (!$diff) {
         $this->openShowImage();
     }
     # No need to display noarticletext, we use our own message, output in openShowImage()
     if ($this->mPage->getID()) {
         # NS_FILE is in the user language, but this section (the actual wikitext)
         # should be in page content language
         $pageLang = $this->getTitle()->getPageViewLanguage();
         $out->addHTML(Xml::openElement('div', array('id' => 'mw-imagepage-content', 'lang' => $pageLang->getHtmlCode(), 'dir' => $pageLang->getDir(), 'class' => 'mw-content-' . $pageLang->getDir())));
         parent::view();
         $out->addHTML(Xml::closeElement('div'));
     } else {
         # Just need to set the right headers
         $out->setArticleFlag(true);
         $out->setPageTitle($this->getTitle()->getPrefixedText());
         $this->mPage->doViewUpdates($this->getContext()->getUser(), $this->getOldID());
     }
     # Show shared description, if needed
     if ($this->mExtraDescription) {
         $fol = wfMessage('shareddescriptionfollows');
         if (!$fol->isDisabled()) {
             $out->addWikiText($fol->plain());
         }
         $out->addHTML('<div id="shared-image-desc">' . $this->mExtraDescription . "</div>\n");
     }
     $this->closeShowImage();
     $this->imageHistory();
     // TODO: Cleanup the following
     $out->addHTML(Xml::element('h2', array('id' => 'filelinks'), wfMessage('imagelinks')->text()) . "\n");
     $this->imageDupes();
     # @todo FIXME: For some freaky reason, we can't redirect to foreign images.
     # Yet we return metadata about the target. Definitely an issue in the FileRepo
     $this->imageLinks();
     # Allow extensions to add something after the image links
     $html = '';
     wfRunHooks('ImagePageAfterImageLinks', array($this, &$html));
     if ($html) {
         $out->addHTML($html);
     }
     if ($showmeta) {
         $out->addHTML(Xml::element('h2', array('id' => 'metadata'), wfMessage('metadata')->text()) . "\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) {
             $out->addStyle($css);
         }
     }
     // always show the local local Filepage.css, bug 29277
     $out->addModuleStyles('filepage');
 }
Example #2
0
 public function view()
 {
     global $wgOut, $wgShowEXIF, $wgRequest, $wgUser, $wgAddNoIndexToFilePages;
     /**
      * Wikia change start
      *
      * https://wikia.fogbugz.com/default.asp?70212#475120
      */
     if (!empty($wgAddNoIndexToFilePages)) {
         $wgOut->addMeta('robots', 'noindex, follow');
     }
     /**
      * wikia change end
      */
     $diff = $wgRequest->getVal('diff');
     $diffOnly = $wgRequest->getBool('diffonly', $wgUser->getGlobalPreference('diffonly'));
     if ($this->getTitle()->getNamespace() != NS_FILE || isset($diff) && $diffOnly) {
         return parent::view();
     }
     $this->loadFile();
     if ($this->getTitle()->getNamespace() == NS_FILE && $this->mPage->getFile()->getRedirected()) {
         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();
         } 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()), true, true));
             $this->mPage->doViewUpdates($this->getContext()->getUser());
             return;
         }
     }
     if ($wgShowEXIF && $this->displayImg->exists()) {
         // @todo FIXME: Bad interface, see note on MediaHandler::formatMetadata().
         $formattedMetadata = $this->displayImg->formatMetadata();
         $showmeta = $formattedMetadata !== false;
     } else {
         $showmeta = false;
     }
     /* Wikia change begin */
     $this->showmeta = $showmeta;
     /* Wikia change end */
     if (!$diff && $this->displayImg->exists()) {
         $wgOut->addHTML($this->showTOC($showmeta));
     }
     if (!$diff) {
         $this->openShowImage();
     }
     $this->imageContent();
     /* Wikia Change - abstracted this out to protected function */
     $this->imageDetails();
     if ($showmeta) {
         $this->imageMetadata($formattedMetadata);
     }
     $this->imageFooter();
     /* End Wikia Change */
     // Add remote Filepage.css
     if (!$this->repo->isLocal()) {
         $css = $this->repo->getDescriptionStylesheetUrl();
         if ($css) {
             $wgOut->addStyle($css);
         }
     }
     // always show the local local Filepage.css, bug 29277
     $wgOut->addModuleStyles('filepage');
 }