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 ) {
$wgOut->addHTML( '</div>' );
}
- /**
- * 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 = '<div class="mw-templatesUsedExplanation">' .
- wfMsgExt( ( $this->preview ? 'templatesusedpreview' : 'templatesused' ), array( 'parse' ) ) .
- '</div><ul>';
- foreach ( $templates as $titleObj ) {
- $outText .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
- }
- $outText .= '</ul>';
- }
- wfProfileOut( __METHOD__ );
- return $outText;
- }
-
/**
* Live Preview lets us fetch rendered preview page content and
* add it to the page without refreshing the whole page.
wfMsg('rollbacklink'),
'action=rollback&from=' . urlencode( $rev->getUserText() ) . $extraRollback ) .']</span>';
}
+
+ /**
+ * 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 = '<div class="mw-templatesUsedExplanation">' .
+ wfMsgExt( 'templatesused', array( 'parse' ) ) .
+ '</div><ul>';
+ foreach ( $templates as $titleObj ) {
+ $outText .= '<li>' . $sk->makeLinkObj( $titleObj ) . '</li>';
+ }
+ $outText .= '</ul>';
+ }
+ wfProfileOut( __METHOD__ );
+ return $outText;
+ }
}
?>
*/
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 ) ) );
htmlspecialchars( $source ) . "\n</textarea>";
$this->addHTML( $text );
}
- $this->formatTemplates();
+ $article = new Article($wgTitle);
+ $this->addHTML( $skin->formatTemplates($article->getUsedTemplates()) );
$this->returnToMain( false );
}
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 = '<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);
- }
}
?>