From d77e4ff0c64b79ba405d3f3327512adcb95be4fe Mon Sep 17 00:00:00 2001 From: Daniel Friesen Date: Sat, 5 Feb 2011 20:16:42 +0000 Subject: [PATCH] Followup comment to r81507. The api is using a legacy langlinks method no modern skin uses. Deprecating this and giving it it's own langlinks generation so that the api will be unaffected by anything we do to legacy skins. --- includes/api/ApiParse.php | 41 +++++++++++++++++++++++++++++++++++---- 1 file changed, 37 insertions(+), 4 deletions(-) diff --git a/includes/api/ApiParse.php b/includes/api/ApiParse.php index 012a83baca..6c3e8d7f16 100644 --- a/includes/api/ApiParse.php +++ b/includes/api/ApiParse.php @@ -378,11 +378,44 @@ class ApiParse extends ApiBase { return $sk->getCategories(); } + /** + * @deprecated No modern skin generates langlinks this way, please use langlinks data to generate your own html + */ private function languagesHtml( $languages ) { - global $wgOut, $wgUser; - $wgOut->setLanguageLinks( $languages ); - $sk = $wgUser->getSkin(); - return $sk->otherLanguages(); + global $wgOut, $wgUser, $wgContLang, $wgHideInterlanguageLinks; + + wfDeprecated( __METHOD__ ); + + if ( $wgHideInterlanguageLinks || count( $languages ) == 0 ) { + return ''; + } + + $sk = $wgUser->getSkin(); // @todo Kill this once we kill getExternalLinkAttributes + + $s = htmlspecialchars( wfMsg( 'otherlanguages' ) . wfMsg( 'colon-separator' ) ); + + $langs = array(); + foreach ( $languages as $l ) { + $nt = Title::newFromText( $l ); + $url = $nt->escapeFullURL(); + $text = $wgContLang->getLanguageName( $nt->getInterwiki() ); + $title = htmlspecialchars( $nt->getText() ); + + if ( $text == '' ) { + $text = $l; + } + + $style = $sk->getExternalLinkAttributes(); // @fixme Linker::getExternalLinkAttributes is best off completely killed + $langs[] = "{$text}"; // @fixme Use Html:: + } + + $s .= implode( htmlspecialchars( wfMsgExt( 'pipe-separator', 'escapenoentities' ) ), $langs ); + + if ( $wgContLang->isRTL() ) { + $s = Html::rawElement( 'span', array( 'dir' => "LTR" ), $s ); + } + + return $s; } private function formatLinks( $links ) { -- 2.20.1