+ // if they didn't want any output except (probably) the parse tree,
+ // then don't bother actually fully expanding it
+ if ( $prop || $params['prop'] === null ) {
+ $frame = $wgParser->getPreprocessor()->newFrame();
+ $wikitext = $wgParser->preprocess( $params['text'], $title_obj, $options, null, $frame );
+ if ( $params['prop'] === null ) {
+ // the old way
+ ApiResult::setContent( $retval, $wikitext );
+ } else {
+ if ( isset( $prop['categories'] ) ) {
+ $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' );
+ $retval['categories'] = $categories_result;
+ }
+ }
+ if ( isset( $prop['volatile'] ) && $frame->isVolatile() ) {
+ $retval['volatile'] = '';
+ }
+ if ( isset( $prop['ttl'] ) && $frame->getTTL() !== null ) {
+ $retval['ttl'] = $frame->getTTL();
+ }
+ if ( isset( $prop['wikitext'] ) ) {
+ $retval['wikitext'] = $wikitext;
+ }
+ }
+ }
+ $result->setSubelements( $retval, array( 'wikitext', 'parsetree' ) );
+ $result->addValue( null, $this->getModuleName(), $retval );