From: Aryeh Gregor Date: Fri, 17 Nov 2006 03:42:23 +0000 (+0000) Subject: Clean up last commit: OutputPage::formatTemplates + EditPage::formatTemplates ->... X-Git-Tag: 1.31.0-rc.0~55165 X-Git-Url: http://git.cyclocoop.org/%24self?a=commitdiff_plain;h=a14bf886d013814695042444c6930f9101306669;p=lhc%2Fweb%2Fwiklou.git Clean up last commit: OutputPage::formatTemplates + EditPage::formatTemplates -> Linker::formatTemplates. --- diff --git a/includes/EditPage.php b/includes/EditPage.php index a98cc60164..f7ea86831c 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -1035,7 +1035,7 @@ class EditPage { if( !$this->preview && !$this->diff ) { $wgOut->setOnloadHandler( 'document.editform.wpTextbox1.focus()' ); } - $templates = $this->formatTemplates(); + $templates = $sk->formatTemplates( $this->preview ? $this->mPreviewTemplates : $this->mArticle->getUsedTemplates() ); global $wgUseMetadataEdit ; if ( $wgUseMetadataEdit ) { @@ -1257,41 +1257,6 @@ END $wgOut->addHTML( '' ); } - /** - * Prepare a list of templates used by this page. - * - * @return string HTML - * @todo Merge with OutputPage::formatTemplates() - */ - function formatTemplates() { - global $wgUser; - wfProfileIn( __METHOD__ ); - - $sk =& $wgUser->getSkin(); - - $outText = ''; - $templates = ( $this->preview ? $this->mPreviewTemplates : $this->mArticle->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( ( $this->preview ? 'templatesusedpreview' : 'templatesused' ), array( 'parse' ) ) . - '
'; - } - wfProfileOut( __METHOD__ ); - return $outText; - } - /** * Live Preview lets us fetch rendered preview page content and * add it to the page without refreshing the whole page. diff --git a/includes/Linker.php b/includes/Linker.php index ff86912fb2..a1b48ab8de 100644 --- a/includes/Linker.php +++ b/includes/Linker.php @@ -1119,5 +1119,40 @@ class Linker { wfMsg('rollbacklink'), 'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extraRollback ) .']'; } + + /** + * Returns HTML for the "templates used on this page" list. + * + * @param array $templates Array of templates from Article::getUsedTemplate + * or similar + * @return string HTML output + */ + public function formatTemplates($templates) { + global $wgUser; + wfProfileIn( __METHOD__ ); + + $sk =& $wgUser->getSkin(); + + $outText = ''; + 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__ ); + return $outText; + } } ?> diff --git a/includes/OutputPage.php b/includes/OutputPage.php index cea00115ea..b1bc128ecc 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -854,12 +854,12 @@ class OutputPage { */ public function readOnlyPage( $source = null, $protected = false ) { global $wgUser, $wgReadOnlyFile, $wgReadOnly, $wgTitle; + $skin = $wgUser->getSkin(); $this->setRobotpolicy( 'noindex,nofollow' ); $this->setArticleRelated( false ); if( $protected ) { - $skin = $wgUser->getSkin(); $this->setPageTitle( wfMsg( 'viewsource' ) ); $this->setSubtitle( wfMsg( 'viewsourcefor', $skin->makeKnownLinkObj( $wgTitle ) ) ); @@ -896,7 +896,8 @@ class OutputPage { htmlspecialchars( $source ) . "\n"; $this->addHTML( $text ); } - $this->formatTemplates(); + $article = new Article($wgTitle); + $this->addHTML( $skin->formatTemplates($article->getUsedTemplates()) ); $this->returnToMain( false ); } @@ -1135,44 +1136,5 @@ class OutputPage { public function showNewSectionLink() { 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); - } } ?>