X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Fapi%2FApiExpandTemplates.php;h=eea10e9b83414e71b2e0406749285665c95a4a85;hb=a56c35a226fea3a3548a0313ce8fb748cfeb3d5a;hp=b3a9d831219ce5347bf52f1fc72601ce55a298e1;hpb=b88d4628dcde8babb4990fc4f622673e3f275650;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/api/ApiExpandTemplates.php b/includes/api/ApiExpandTemplates.php index b3a9d83121..eea10e9b83 100644 --- a/includes/api/ApiExpandTemplates.php +++ b/includes/api/ApiExpandTemplates.php @@ -42,6 +42,7 @@ class ApiExpandTemplates extends ApiBase { $this->requireMaxOneParameter( $params, 'prop', 'generatexml' ); if ( $params['prop'] === null ) { + $this->logFeatureUsage( 'action=expandtemplates&!prop' ); $this->setWarning( 'Because no values have been specified for the prop parameter, a ' . 'legacy format has been used for the output. This format is deprecated, and in ' . 'the future, a default value will be set for the prop parameter, causing the new' . @@ -70,7 +71,11 @@ class ApiExpandTemplates extends ApiBase { $retval = array(); if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) { - $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS ); + if ( !isset( $prop['parsetree'] ) ) { + $this->logFeatureUsage( 'action=expandtemplates&generatexml' ); + } + + $wgParser->startExternalParse( $title_obj, $options, Parser::OT_PREPROCESS ); $dom = $wgParser->preprocessToDom( $params['text'] ); if ( is_callable( array( $dom, 'saveXML' ) ) ) { $xml = $dom->saveXML(); @@ -91,7 +96,7 @@ class ApiExpandTemplates extends ApiBase { // 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 ) { - $wgParser->startExternalParse( $title_obj, $options, OT_PREPROCESS ); + $wgParser->startExternalParse( $title_obj, $options, Parser::OT_PREPROCESS ); $frame = $wgParser->getPreprocessor()->newFrame(); $wikitext = $wgParser->preprocess( $params['text'], $title_obj, $options, null, $frame ); if ( $params['prop'] === null ) { @@ -154,70 +159,10 @@ class ApiExpandTemplates extends ApiBase { ); } - public function getParamDescription() { - return array( - 'text' => 'Wikitext to convert', - 'title' => 'Title of page', - 'prop' => array( - 'Which pieces of information to get', - ' wikitext - The expanded wikitext', - ' categories - Any categories present in the input that are not represented in ' . - 'the wikitext output', - ' volatile - Whether the output is volatile and should not be reused ' . - 'elsewhere within the page', - ' ttl - The maximum time after which caches of the result should be ' . - 'invalidated', - ' parsetree - The XML parse tree of the input', - 'Note that if no values are selected, the result will contain the wikitext,', - 'but the output will be in a deprecated format.', - ), - 'includecomments' => 'Whether to include HTML comments in the output', - 'generatexml' => 'Generate XML parse tree (replaced by prop=parsetree)', - ); - } - - public function getResultProperties() { - return array( - 'wikitext' => array( - 'wikitext' => 'string', - ), - 'categories' => array( - 'categories' => array( - ApiBase::PROP_TYPE => 'array', - ApiBase::PROP_NULLABLE => true, - ), - ), - 'volatile' => array( - 'volatile' => array( - ApiBase::PROP_TYPE => 'boolean', - ApiBase::PROP_NULLABLE => true, - ), - ), - 'ttl' => array( - 'ttl' => array( - ApiBase::PROP_TYPE => 'integer', - ApiBase::PROP_NULLABLE => true, - ), - ), - 'parsetree' => array( - 'parsetree' => 'string', - ), - ); - } - - public function getDescription() { - return 'Expands all templates in wikitext.'; - } - - public function getPossibleErrors() { - return array_merge( parent::getPossibleErrors(), array( - array( 'invalidtitle', 'title' ), - ) ); - } - - public function getExamples() { + protected function getExamplesMessages() { return array( - 'api.php?action=expandtemplates&text={{Project:Sandbox}}' + 'action=expandtemplates&text={{Project:Sandbox}}' + => 'apihelp-expandtemplates-example-simple', ); }