(bug 7918) "Templates used on this page" is now shown for read-only pages.
authorAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Nov 2006 03:32:12 +0000 (03:32 +0000)
committerAryeh Gregor <simetrical@users.mediawiki.org>
Fri, 17 Nov 2006 03:32:12 +0000 (03:32 +0000)
RELEASE-NOTES
includes/EditPage.php
includes/OutputPage.php

index b55523a..558b8cf 100644 (file)
@@ -197,6 +197,7 @@ it from source control: http://www.mediawiki.org/wiki/Download_from_SVN
   and user JS subpages.
 * (bug 7918) "Templates used on this page" changes during preview to reflect
   any added or removed templates.
+* (bug 7918) "Templates used on this page" is now shown for read-only pages.
 
 
 == Languages updated ==
index 76567ea..a98cc60 100644 (file)
@@ -1258,13 +1258,14 @@ END
        }
 
        /**
-        * Prepare a list of templates used by this page. Returns HTML.
+        * Prepare a list of templates used by this page.
+        *
+        * @return string HTML
+        * @todo Merge with OutputPage::formatTemplates()
         */
        function formatTemplates() {
                global $wgUser;
-
-               $fname = 'EditPage::formatTemplates';
-               wfProfileIn( $fname );
+               wfProfileIn( __METHOD__  );
 
                $sk =& $wgUser->getSkin();
 
@@ -1287,7 +1288,7 @@ END
                        }
                        $outText .= '</ul>';
                }
-               wfProfileOut( $fname );
+               wfProfileOut( __METHOD__  );
                return $outText;
        }
 
index a59ff3d..cea0011 100644 (file)
@@ -891,11 +891,12 @@ class OutputPage {
                        }
                        $rows = $wgUser->getIntOption( 'rows' );
                        $cols = $wgUser->getIntOption( 'cols' );
-                       
+
                        $text = "\n<textarea name='wpTextbox1' id='wpTextbox1' cols='$cols' rows='$rows' readonly='readonly'>" .
                                htmlspecialchars( $source ) . "\n</textarea>";
                        $this->addHTML( $text );
                }
+               $this->formatTemplates();
 
                $this->returnToMain( false );
        }
@@ -1135,5 +1136,43 @@ class OutputPage {
                return $this->mNewSectionLink;
        }
 
+       /**
+        * Outputs the "templates used on this page" list.
+        *
+        * Stolen from EditPage::formatTemplates.  Should be merged, but there are
+        * slightly fiddly bits involving previews and so on that will have to be
+        * dealt with, so I'll just copy it for now because I'm lazy.
+        *
+        * @return nothing
+        */
+       function formatTemplates() {
+               global $wgUser, $wgTitle;
+               wfProfileIn( __METHOD__ );
+
+               $sk =& $wgUser->getSkin();
+
+               $outText = '';
+               $article = new Article($wgTitle);
+               $templates = $article->getUsedTemplates();
+               if ( count( $templates ) > 0 ) {
+                       # Do a batch existence check
+                       $batch = new LinkBatch;
+                       foreach( $templates as $title ) {
+                               $batch->addObj( $title );
+                       }
+                       $batch->execute();
+
+                       # Construct the HTML
+                       $outText = '<div class="mw-templatesUsedExplanation">' .
+                               wfMsgExt( 'templatesused', array( 'parse' ) ) .
+                               '</div><ul>';
+                       foreach ( $templates as $titleObj ) {
+                               $outText .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
+                       }
+                       $outText .= '</ul>';
+               }
+               wfProfileOut( __METHOD__  );
+               $this->addHTML($outText);
+       }
 }
 ?>