
btongminh at svn
May 11, 2008, 12:49 PM
Post #1 of 1
(11 views)
Permalink
|
|
SVN: [34624] trunk/phase3/includes
|
|
Revision: 34624 Author: btongminh Date: 2008-05-11 19:49:08 +0000 (Sun, 11 May 2008) Log Message: ----------- Put code to view redirect page in new method Article::viewRedirect in order to allow displaying redirects on foreign file repos. Modified Paths: -------------- trunk/phase3/includes/Article.php trunk/phase3/includes/ImagePage.php Modified: trunk/phase3/includes/Article.php =================================================================== --- trunk/phase3/includes/Article.php 2008-05-11 18:44:10 UTC (rev 34623) +++ trunk/phase3/includes/Article.php 2008-05-11 19:49:08 UTC (rev 34624) @@ -860,18 +860,8 @@ } 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( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' . - '<span class="redirectText">'.$link.'</span>' ); - + $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ); $parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser)); $wgOut->addParserOutputNoText( $parseout ); } else if ( $pcache ) { @@ -933,7 +923,28 @@ $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( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' . + '<span class="redirectText">'.$link.'</span>' ); + + } + function addTrackbacks() { global $wgOut, $wgUser; Modified: trunk/phase3/includes/ImagePage.php =================================================================== --- trunk/phase3/includes/ImagePage.php 2008-05-11 18:44:10 UTC (rev 34623) +++ trunk/phase3/includes/ImagePage.php 2008-05-11 19:49:08 UTC (rev 34624) @@ -44,8 +44,17 @@ 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' ) ); _______________________________________________ MediaWiki-CVS mailing list MediaWiki-CVS[at]lists.wikimedia.org https://lists.wikimedia.org/mailman/listinfo/mediawiki-cvs
|