From: Bryan Tong Minh Date: Sun, 11 May 2008 19:49:08 +0000 (+0000) Subject: Put code to view redirect page in new method Article::viewRedirect in order to allow... X-Git-Tag: 1.31.0-rc.0~47711 X-Git-Url: http://git.cyclocoop.org/%22%20.%20generer_url_ecrire%28%22articles_versions%22%2C%22id_article=%24id_article%22%29%20.%20%22?a=commitdiff_plain;h=3c9536652a3b27ec97cb2e3f046c5e98849c58a4;p=lhc%2Fweb%2Fwiklou.git Put code to view redirect page in new method Article::viewRedirect in order to allow displaying redirects on foreign file repos. --- diff --git a/includes/Article.php b/includes/Article.php index 1558efdcbc..cef4470b9e 100644 --- a/includes/Article.php +++ b/includes/Article.php @@ -860,18 +860,8 @@ class Article { } elseif ( $rt = Title::newFromRedirect( $text ) ) { - # Display redirect - $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; - $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png'; # Don't overwrite the subtitle if this was an old revision - if( !$wasRedirected && $this->isCurrent() ) { - $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) ); - } - $link = $sk->makeLinkObj( $rt, htmlspecialchars( $rt->getFullText() ) ); - - $wgOut->addHTML( '#REDIRECT ' . - ''.$link.'' ); - + $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText( $parseout ); } else if ( $pcache ) { @@ -933,6 +923,27 @@ class Article { $this->viewUpdates(); wfProfileOut( __METHOD__ ); } + + protected function viewRedirect( $target, $overwriteSubtitle = true, $forceKnown = false ) { + global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser; + + # Display redirect + $imageDir = $wgContLang->isRTL() ? 'rtl' : 'ltr'; + $imageUrl = $wgStylePath.'/common/images/redirect' . $imageDir . '.png'; + + if( $overwriteSubtitle ) { + $wgOut->setSubtitle( wfMsgHtml( 'redirectpagesub' ) ); + } + $sk = $wgUser->getSkin(); + if ( $forceKnown ) + $link = $sk->makeKnownLinkObj( $target, htmlspecialchars( $target->getFullText() ) ); + else + $link = $sk->makeLinkObj( $target, htmlspecialchars( $target->getFullText() ) ); + + $wgOut->addHTML( '#REDIRECT ' . + ''.$link.'' ); + + } function addTrackbacks() { global $wgOut, $wgUser; diff --git a/includes/ImagePage.php b/includes/ImagePage.php index 7579399772..4dacae30d8 100644 --- a/includes/ImagePage.php +++ b/includes/ImagePage.php @@ -44,8 +44,17 @@ class ImagePage extends Article { function view() { global $wgOut, $wgShowEXIF, $wgRequest, $wgUser; - if ( $this->img->getRedirected() ) - return Article::view(); + if ( $this->img->getRedirected() ) { + if ( $this->mTitle->getDBkey() == $this->img->getName() ) { + return Article::view(); + } else { + $wgOut->setPageTitle( $this->mTitle->getPrefixedText() ); + $this->viewRedirect( Title::makeTitle( NS_IMAGE, $this->img->getName() ), + /* $overwriteSubtitle */ true, /* $forceKnown */ true ); + $this->viewUpdates(); + return; + } + } $diff = $wgRequest->getVal( 'diff' ); $diffOnly = $wgRequest->getBool( 'diffonly', $wgUser->getOption( 'diffonly' ) );