Merge "Use ParserOptions language instead of RequestContext language"

This commit is contained in:
jenkins-bot 2013-08-02 19:33:21 +00:00 committed by Gerrit Code Review
commit 18663c27eb
2 changed files with 37 additions and 13 deletions

View file

@ -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() );
}
}

View file

@ -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>';