Take Article::viewRedirect() public and have it return a string so it can be used other places, like EditPage for proper rendering of redirects on preview (bug 2333). +Docs here and there.
This commit is contained in:
parent
3c2a85cc65
commit
07d9e2d766
4 changed files with 18 additions and 8 deletions
|
|
@ -52,6 +52,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
|
|||
* Recursion loop check added to Categoryfinder class
|
||||
* Fixed few performance troubles of large job queue processing
|
||||
* Not setting various parameters in Foreign Repos now fails more gracefully
|
||||
* (bug 2333) Redirects are properly rendered when previewing an edit.
|
||||
|
||||
=== API changes in 1.14 ===
|
||||
|
||||
|
|
|
|||
|
|
@ -859,7 +859,7 @@ class Article {
|
|||
}
|
||||
} else if ( $rt = Title::newFromRedirect( $text ) ) {
|
||||
# Don't append the subtitle if this was an old revision
|
||||
$this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() );
|
||||
$wgOut->addHTML( $this->viewRedirect( $rt, !$wasRedirected && $this->isCurrent() ) );
|
||||
$parseout = $wgParser->parse($text, $this->mTitle, ParserOptions::newFromUser($wgUser));
|
||||
$wgOut->addParserOutputNoText( $parseout );
|
||||
} else if ( $pcache ) {
|
||||
|
|
@ -934,7 +934,13 @@ class Article {
|
|||
&& !$this->mTitle->isCssJsSubpage();
|
||||
}
|
||||
|
||||
protected function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
|
||||
/**
|
||||
* View redirect
|
||||
* @param Title $target Title of destination to redirect
|
||||
* @param Bool $appendSubtitle Object[optional]
|
||||
* @param Bool $forceKnown Should the image be shown as a bluelink regardless of existence?
|
||||
*/
|
||||
public function viewRedirect( $target, $appendSubtitle = true, $forceKnown = false ) {
|
||||
global $wgParser, $wgOut, $wgContLang, $wgStylePath, $wgUser;
|
||||
|
||||
# Display redirect
|
||||
|
|
@ -950,8 +956,8 @@ class Article {
|
|||
else
|
||||
$link = $sk->makeLinkObj( $target, htmlspecialchars( $target->getFullText() ) );
|
||||
|
||||
$wgOut->addHTML( '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
|
||||
'<span class="redirectText">'.$link.'</span>' );
|
||||
return '<img src="'.$imageUrl.'" alt="#REDIRECT " />' .
|
||||
'<span class="redirectText">'.$link.'</span>';
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1522,7 +1522,8 @@ END
|
|||
}
|
||||
|
||||
/**
|
||||
* @todo document
|
||||
* Get the rendered text for previewing.
|
||||
* @return string
|
||||
*/
|
||||
function getPreviewText() {
|
||||
global $wgOut, $wgUser, $wgTitle, $wgParser, $wgLang, $wgContLang;
|
||||
|
|
@ -1564,6 +1565,8 @@ END
|
|||
$parserOutput = $wgParser->parse( $previewtext , $this->mTitle, $parserOptions );
|
||||
$wgOut->addHTML( $parserOutput->mText );
|
||||
$previewHTML = '';
|
||||
} else if( $rt = Title::newFromRedirect( $this->textbox1 ) ) {
|
||||
$previewHTML = $this->mArticle->viewRedirect( $rt, false );
|
||||
} else {
|
||||
$toparse = $this->textbox1;
|
||||
|
||||
|
|
@ -1630,7 +1633,7 @@ END
|
|||
} else {
|
||||
$previewfoot = '';
|
||||
}
|
||||
|
||||
|
||||
wfProfileOut( $fname );
|
||||
return $previewhead . $previewHTML . $previewfoot;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,8 +66,8 @@ class ImagePage extends Article {
|
|||
// mTitle is not the same as the redirect target so it is
|
||||
// probably the redirect page itself. Fake the redirect symbol
|
||||
$wgOut->setPageTitle( $this->mTitle->getPrefixedText() );
|
||||
$this->viewRedirect( Title::makeTitle( NS_IMAGE, $this->img->getName() ),
|
||||
/* $appendSubtitle */ true, /* $forceKnown */ true );
|
||||
$wgOut->addHTML( $this->viewRedirect( Title::makeTitle( NS_IMAGE, $this->img->getName() ),
|
||||
/* $appendSubtitle */ true, /* $forceKnown */ true ) );
|
||||
$this->viewUpdates();
|
||||
return;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue