From: Jackmcbarn Date: Thu, 29 May 2014 17:50:27 +0000 (-0400) Subject: Add category output to ApiExpandTemplates X-Git-Tag: 1.31.0-rc.0~15524^2 X-Git-Url: http://git.cyclocoop.org/%22.%20generer_url_ecrire%28%22sites_tous%22%2C%22%22%29.%20%22?a=commitdiff_plain;h=e658bf0402edda6150fc90197211e085f5371fb2;p=lhc%2Fweb%2Fwiklou.git Add category output to ApiExpandTemplates The preprocessor sometimes adds pages to categories itself, which don't have any representation in the output of ApiExpandTemplates. Because of this, add a new field containing these categories. Change-Id: I7ae2eb9daf68e032dcc7a650bd8391d445ee1037 --- diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index b42a30b029..9a472f5318 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -70,6 +70,18 @@ class ApiExpandTemplates extends ApiBase { } $frame = $wgParser->getPreprocessor()->newFrame(); $retval = $wgParser->preprocess( $params['text'], $title_obj, $options, null, $frame ); + $categories = $wgParser->getOutput()->getCategories(); + if ( !empty( $categories ) ) { + $categories_result = array(); + foreach ( $categories as $category => $sortkey ) { + $entry = array(); + $entry['sortkey'] = $sortkey; + ApiResult::setContent( $entry, $category ); + $categories_result[] = $entry; + } + $result->setIndexedTagName( $categories_result, 'category' ); + $result->addValue( null, 'categories', $categories_result ); + } // Return result $retval_array = array();