diff options
Diffstat (limited to 'includes/api/ApiExpandTemplates.php')
-rw-r--r-- | includes/api/ApiExpandTemplates.php | 32 |
1 files changed, 29 insertions, 3 deletions
diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index 6d064eb2..6112534c 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -111,8 +111,9 @@ class ApiExpandTemplates extends ApiBase { // the old way ApiResult::setContentValue( $retval, 'wikitext', $wikitext ); } else { + $p_output = $wgParser->getOutput(); if ( isset( $prop['categories'] ) ) { - $categories = $wgParser->getOutput()->getCategories(); + $categories = $p_output->getCategories(); if ( $categories ) { $categories_result = array(); foreach ( $categories as $category => $sortkey ) { @@ -126,7 +127,7 @@ class ApiExpandTemplates extends ApiBase { } } if ( isset( $prop['properties'] ) ) { - $properties = $wgParser->getOutput()->getProperties(); + $properties = $p_output->getProperties(); if ( $properties ) { ApiResult::setArrayType( $properties, 'BCkvp', 'name' ); ApiResult::setIndexedTagName( $properties, 'property' ); @@ -142,6 +143,27 @@ class ApiExpandTemplates extends ApiBase { if ( isset( $prop['wikitext'] ) ) { $retval['wikitext'] = $wikitext; } + if ( isset( $prop['modules'] ) ) { + $retval['modules'] = array_values( array_unique( $p_output->getModules() ) ); + $retval['modulescripts'] = array_values( array_unique( $p_output->getModuleScripts() ) ); + $retval['modulestyles'] = array_values( array_unique( $p_output->getModuleStyles() ) ); + } + if ( isset( $prop['jsconfigvars'] ) ) { + $retval['jsconfigvars'] = + ApiResult::addMetadataToResultVars( $p_output->getJsConfigVars() ); + } + if ( isset( $prop['encodedjsconfigvars'] ) ) { + $retval['encodedjsconfigvars'] = FormatJson::encode( + $p_output->getJsConfigVars(), false, FormatJson::ALL_OK + ); + $retval[ApiResult::META_SUBELEMENTS][] = 'encodedjsconfigvars'; + } + if ( isset( $prop['modules'] ) && + !isset( $prop['jsconfigvars'] ) && !isset( $prop['encodedjsconfigvars'] ) ) { + $this->setWarning( "Property 'modules' was set but not 'jsconfigvars' " . + "or 'encodedjsconfigvars'. Configuration variables are necessary " . + "for proper module usage." ); + } } } ApiResult::setSubelementsList( $retval, array( 'wikitext', 'parsetree' ) ); @@ -154,7 +176,7 @@ class ApiExpandTemplates extends ApiBase { ApiBase::PARAM_DFLT => 'API', ), 'text' => array( - ApiBase::PARAM_TYPE => 'string', + ApiBase::PARAM_TYPE => 'text', ApiBase::PARAM_REQUIRED => true, ), 'revid' => array( @@ -167,9 +189,13 @@ class ApiExpandTemplates extends ApiBase { 'properties', 'volatile', 'ttl', + 'modules', + 'jsconfigvars', + 'encodedjsconfigvars', 'parsetree', ), ApiBase::PARAM_ISMULTI => true, + ApiBase::PARAM_HELP_MSG_PER_VALUE => array(), ), 'includecomments' => false, 'generatexml' => array( |