mirror of
https://gerrit.wikimedia.org/r/mediawiki/extensions/TemplateData
synced 2024-11-24 07:53:37 +00:00
Merge "Use ParserOptions language instead of RequestContext language"
This commit is contained in:
commit
18663c27eb
|
@ -78,8 +78,6 @@ class TemplateDataHooks {
|
|||
*/
|
||||
public static function render( $input, $args, $parser, $frame ) {
|
||||
$ti = TemplateDataBlob::newFromJSON( $input );
|
||||
// TODO: Is there a better context?
|
||||
$context = RequestContext::getMain();
|
||||
|
||||
$status = $ti->getStatus();
|
||||
if ( !$status->isOK() ) {
|
||||
|
@ -91,6 +89,6 @@ class TemplateDataHooks {
|
|||
|
||||
$parser->getOutput()->addModules( 'ext.templateData' );
|
||||
|
||||
return $ti->getHtml( $context );
|
||||
return $ti->getHtml( $parser->getOptions()->getUserLangObj() );
|
||||
}
|
||||
}
|
||||
|
|
|
@ -344,23 +344,49 @@ class TemplateDataBlob {
|
|||
return json_encode( $this->data );
|
||||
}
|
||||
|
||||
public function getHtml( IContextSource $context ) {
|
||||
public function getHtml( Language $lang ) {
|
||||
global $wgContLang;
|
||||
$langCode = $wgContLang->getCode();
|
||||
$data = $this->data;
|
||||
$html =
|
||||
Html::openElement( 'div', array( 'class' => 'mw-templatedata-doc-wrap' ) )
|
||||
. Html::element( 'p', array(
|
||||
'class' => 'mw-templatedata-doc-desc'
|
||||
), $data->description->$langCode )
|
||||
. Html::element(
|
||||
'p',
|
||||
array( 'class' => 'mw-templatedata-doc-desc' ),
|
||||
$data->description->$langCode
|
||||
)
|
||||
. '<table class="wikitable mw-templatedata-doc-params">'
|
||||
. Html::element( 'caption', array(), $context->msg( 'templatedata-doc-params' ) )
|
||||
. Html::element(
|
||||
'caption',
|
||||
array(),
|
||||
wfMessage( 'templatedata-doc-params' )->inLanguage( $lang )
|
||||
)
|
||||
. '<thead><tr>'
|
||||
. Html::element( 'th', array( 'colspan' => 2 ), $context->msg( 'templatedata-doc-param-name' ) )
|
||||
. Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-desc' ) )
|
||||
. Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-type' ) )
|
||||
. Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-default' ) )
|
||||
. Html::element( 'th', array(), $context->msg( 'templatedata-doc-param-status' ) )
|
||||
. Html::element(
|
||||
'th',
|
||||
array( 'colspan' => 2 ),
|
||||
wfMessage( 'templatedata-doc-param-name' )->inLanguage( $lang )
|
||||
)
|
||||
. Html::element(
|
||||
'th',
|
||||
array(),
|
||||
wfMessage( 'templatedata-doc-param-desc' )->inLanguage( $lang )
|
||||
)
|
||||
. Html::element(
|
||||
'th',
|
||||
array(),
|
||||
wfMessage( 'templatedata-doc-param-type' )->inLanguage( $lang )
|
||||
)
|
||||
. Html::element(
|
||||
'th',
|
||||
array(),
|
||||
wfMessage( 'templatedata-doc-param-default' )->inLanguage( $lang )
|
||||
)
|
||||
. Html::element(
|
||||
'th',
|
||||
array(),
|
||||
wfMessage( 'templatedata-doc-param-status' )->inLanguage( $lang )
|
||||
)
|
||||
. '</tr></thead>'
|
||||
. '<tbody>';
|
||||
|
||||
|
|
Loading…
Reference in a new issue