(bug 7918) "Templates used on this page" changes during preview to reflect any added...
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Nov 2006 03:16:18 +0000 (03:16 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Nov 2006 03:16:18 +0000 (03:16 +0000)
RELEASE-NOTES
includes/EditPage.php
languages/messages/MessagesEn.php

index e841e8f..b55523a 100644 (file)
@@ -195,6 +195,8 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
 * (bug 4178) MediaWiki:Common.js will now be included for all users if
   $wgUseSiteJs is enabled, in addition to (if applicable) MediaWiki:Monobook.js
   and user JS subpages.
+* (bug 7918) "Templates used on this page" changes during preview to reflect
+  any added or removed templates.
 
 
 == Languages updated ==
index 30cb281..76567ea 100644 (file)
@@ -32,6 +32,7 @@ class EditPage {
        var $allowBlankSummary = false;
        var $autoSumm = '';
        var $hookError = '';
+       var $mPreviewTemplates;
 
        # Form values
        var $save = false, $preview = false, $diff = false;
@@ -1268,7 +1269,7 @@ END
                $sk =& $wgUser->getSkin();
 
                $outText = '';
-               $templates = $this->mArticle->getUsedTemplates();
+               $templates = ( $this->preview ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates() );
                if ( count( $templates ) > 0 ) {
                        # Do a batch existence check
                        $batch = new LinkBatch;
@@ -1279,7 +1280,7 @@ END
 
                        # Construct the HTML
                        $outText = '<div class="mw-templatesUsedExplanation">' .
-                               wfMsgExt( 'templatesused', array( 'parse' ) ) .
+                               wfMsgExt( ( $this->preview ? 'templatesusedpreview' : 'templatesused' ), array( 'parse' ) ) .
                                '</div><ul>';
                        foreach ( $templates as $titleObj ) {
                                $outText .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
@@ -1406,6 +1407,10 @@ END
                        $previewHTML = $parserOutput->getText();
                        $wgOut->addParserOutputNoText( $parserOutput );
 
+                       foreach ( $parserOutput->getTemplates() as $ns => $template)
+                               foreach ( array_keys( $template ) as $dbk)
+                                       $this->mPreviewTemplates[] = Title::makeTitle($ns, $dbk);
+
                        wfProfileOut( $fname );
                        return $previewhead . $previewHTML;
                }
index 5814df1..11e0a1d 100644 (file)
@@ -978,7 +978,7 @@ the text into a text file and save it for later.</strong>',
 'protectedpagewarning' => "<strong>WARNING:  This page has been locked so that only users with sysop privileges can edit it.</strong>",
 'semiprotectedpagewarning' => "'''Note:''' This page has been locked so that only registered users can edit it.",
 'templatesused'        => 'Templates used on this page:',
-'edittools' => '<!-- Text here will be shown below edit and upload forms. -->',
+'templatesusedpreview' => 'Templates used in this preview:',
 'nocreatetitle' => 'Page creation limited',
 'nocreatetext' => 'This site has restricted the ability to create new pages.
 You can go back and edit an existing page, or [[Special:Userlogin|log in or create an account]].',