Take Article::viewRedirect() public and have it return a string so it can be used...
authorChad Horohoe <demon@users.mediawiki.org>
Sat, 2 Aug 2008 02:39:09 +0000 (02:39 +0000)
committerChad Horohoe <demon@users.mediawiki.org>
Sat, 2 Aug 2008 02:39:09 +0000 (02:39 +0000)
RELEASE-NOTES
includes/Article.php
includes/EditPage.php
includes/ImagePage.php

index 7178060..cbadeff 100644 (file)
@@ -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 ===
 
index a01469d..70e423d 100644 (file)
@@ -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>';
                
        }
 
index 585e156..160e0f1 100644 (file)
@@ -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;
        }
index 4c7eff1..a526ba9 100644 (file)
@@ -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;
                        }