From 4f08c1e6555f69db4e51260d3d3588b0e93b8c0b Mon Sep 17 00:00:00 2001 From: Aryeh Gregor Date: Fri, 17 Nov 2006 03:32:12 +0000 Subject: [PATCH] (bug 7918) "Templates used on this page" is now shown for read-only pages. --- RELEASE-NOTES | 1 + includes/EditPage.php | 11 ++++++----- includes/OutputPage.php | 41 ++++++++++++++++++++++++++++++++++++++++- 3 files changed, 47 insertions(+), 6 deletions(-) diff --git a/RELEASE-NOTES b/RELEASE-NOTES index b55523a3a0..558b8cfaa3 100644 --- a/RELEASE-NOTES +++ b/RELEASE-NOTES @@ -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 == diff --git a/includes/EditPage.php b/includes/EditPage.php index 76567eaf5b..a98cc60164 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -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 .= ''; } - wfProfileOut( $fname ); + wfProfileOut( __METHOD__ ); return $outText; } diff --git a/includes/OutputPage.php b/includes/OutputPage.php index a59ff3d357..cea00115ea 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -891,11 +891,12 @@ class OutputPage { } $rows = $wgUser->getIntOption( 'rows' ); $cols = $wgUser->getIntOption( 'cols' ); - + $text = "\n"; $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 = '
' . + wfMsgExt( 'templatesused', array( 'parse' ) ) . + '
'; + } + wfProfileOut( __METHOD__ ); + $this->addHTML($outText); + } } ?> -- 2.20.1