X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2FLinker.php;h=8682991bf83a9410335f5c7246e36d25604d5f40;hb=711fad668b86ff837a31808fe71056b9257e4d80;hp=21d87d8a974a097d60ff971fea8808eef8ab108f;hpb=b6ac6ab899cd9baaadfc41dc82b7c9bd8dd2d1bc;p=lhc%2Fweb%2Fwiklou.git
diff --git a/includes/Linker.php b/includes/Linker.php
index 21d87d8a97..8682991bf8 100644
--- a/includes/Linker.php
+++ b/includes/Linker.php
@@ -1919,6 +1919,8 @@ class Linker {
}
/**
+ * @deprecated since 1.28, use TemplatesOnThisPageFormatter directly
+ *
* Returns HTML for the "templates used on this page" list.
*
* Make an HTML list of templates, and then add a "More..." link at
@@ -1937,87 +1939,24 @@ class Linker {
public static function formatTemplates( $templates, $preview = false,
$section = false, $more = null
) {
- global $wgLang;
-
- $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 = '
';
- if ( $preview ) {
- $outText .= wfMessage( 'templatesusedpreview' )->numParams( count( $templates ) )
- ->parseAsBlock();
- } elseif ( $section ) {
- $outText .= wfMessage( 'templatesusedsection' )->numParams( count( $templates ) )
- ->parseAsBlock();
- } else {
- $outText .= wfMessage( 'templatesused' )->numParams( count( $templates ) )
- ->parseAsBlock();
- }
- $outText .= "
\n";
-
- usort( $templates, 'Title::compare' );
- foreach ( $templates as $titleObj ) {
- $protected = '';
- $restrictions = $titleObj->getRestrictions( 'edit' );
- if ( $restrictions ) {
- // Check backwards-compatible messages
- $msg = null;
- if ( $restrictions === [ 'sysop' ] ) {
- $msg = wfMessage( 'template-protected' );
- } elseif ( $restrictions === [ 'autoconfirmed' ] ) {
- $msg = wfMessage( 'template-semiprotected' );
- }
- if ( $msg && !$msg->isDisabled() ) {
- $protected = $msg->parse();
- } else {
- // Construct the message from restriction-level-*
- // e.g. restriction-level-sysop, restriction-level-autoconfirmed
- $msgs = [];
- foreach ( $restrictions as $r ) {
- $msgs[] = wfMessage( "restriction-level-$r" )->parse();
- }
- $protected = wfMessage( 'parentheses' )
- ->rawParams( $wgLang->commaList( $msgs ) )->escaped();
- }
- }
- if ( $titleObj->quickUserCan( 'edit' ) ) {
- $editLink = self::link(
- $titleObj,
- wfMessage( 'editlink' )->escaped(),
- [],
- [ 'action' => 'edit' ]
- );
- } else {
- $editLink = self::link(
- $titleObj,
- wfMessage( 'viewsourcelink' )->escaped(),
- [],
- [ 'action' => 'edit' ]
- );
- }
- $outText .= '- ' . self::link( $titleObj )
- . wfMessage( 'word-separator' )->escaped()
- . wfMessage( 'parentheses' )->rawParams( $editLink )->escaped()
- . wfMessage( 'word-separator' )->escaped()
- . $protected . '
';
- }
+ wfDeprecated( __METHOD__, '1.28' );
- if ( $more instanceof Title ) {
- $outText .= '- ' . self::link( $more, wfMessage( 'moredotdotdot' ) ) . '
';
- } elseif ( $more ) {
- $outText .= "- $more
";
- }
+ $type = false;
+ if ( $preview ) {
+ $type = 'preview';
+ } elseif ( $section ) {
+ $type = 'section';
+ }
- $outText .= '
';
+ if ( $more instanceof Message ) {
+ $more = $more->toString();
}
- return $outText;
+
+ $formatter = new TemplatesOnThisPageFormatter(
+ RequestContext::getMain(),
+ MediaWikiServices::getInstance()->getLinkRenderer()
+ );
+ return $formatter->format( $templates, $type, $more );
}
/**