$result_array[ApiResult::META_BC_SUBELEMENTS][] = 'limitreporthtml';
}
- if ( $params['generatexml'] ) {
+ if ( isset( $prop['parsetree'] ) || $params['generatexml'] ) {
+ if ( !isset( $prop['parsetree'] ) ) {
+ $this->logFeatureUsage( 'action=parse&generatexml' );
+ }
if ( $this->content->getModel() != CONTENT_MODEL_WIKITEXT ) {
- $this->dieUsage( "generatexml is only supported for wikitext content", "notwikitext" );
+ $this->dieUsage( "parsetree is only supported for wikitext content", "notwikitext" );
}
$wgParser->startExternalParse( $titleObj, $popts, Parser::OT_PREPROCESS );
'properties',
'limitreportdata',
'limitreporthtml',
+ 'parsetree',
+ ),
+ ApiBase::PARAM_HELP_MSG_PER_VALUE => array(
+ 'parsetree' => array( 'apihelp-parse-paramvalue-prop-parsetree', CONTENT_MODEL_WIKITEXT ),
),
- ApiBase::PARAM_HELP_MSG_PER_VALUE => array(),
),
'pst' => false,
'onlypst' => false,
ApiBase::PARAM_HELP_MSG => array(
'apihelp-parse-param-generatexml', CONTENT_MODEL_WIKITEXT
),
+ ApiBase::PARAM_DEPRECATED => true,
),
'preview' => false,
'sectionpreview' => false,
protected $fld_ids = false, $fld_flags = false, $fld_timestamp = false,
$fld_size = false, $fld_sha1 = false, $fld_comment = false,
$fld_parsedcomment = false, $fld_user = false, $fld_userid = false,
- $fld_content = false, $fld_tags = false, $fld_contentmodel = false;
+ $fld_content = false, $fld_tags = false, $fld_contentmodel = false, $fld_parsetree = false;
public function execute() {
$this->run();
$this->fld_userid = isset( $prop['userid'] );
$this->fld_user = isset( $prop['user'] );
$this->fld_tags = isset( $prop['tags'] );
+ $this->fld_parsetree = isset( $prop['parsetree'] );
if ( !empty( $params['contentformat'] ) ) {
$this->contentFormat = $params['contentformat'];
$this->limit = $params['limit'];
$this->fetchContent = $this->fld_content || !is_null( $this->diffto )
- || !is_null( $this->difftotext );
+ || !is_null( $this->difftotext ) || $this->fld_parsetree;
$smallLimit = false;
if ( $this->fetchContent ) {
$vals['textmissing'] = true;
}
}
- if ( $this->fld_content && $content ) {
- $text = null;
-
- if ( $this->generateXML ) {
+ if ( $this->fld_parsetree || ( $this->fld_content && $this->generateXML ) ) {
+ if ( !$this->fld_parsetree ) {
+ $this->logFeatureUsage( 'action=query&prop=revisions+base&generatexml' );
+ }
+ if ( $content ) {
if ( $content->getModel() === CONTENT_MODEL_WIKITEXT ) {
$t = $content->getNativeData(); # note: don't set $text
" uses content model " . $content->getModel() );
}
}
+ }
+
+ if ( $this->fld_content && $content ) {
+ $text = null;
if ( $this->expandTemplates && !$this->parseContent ) {
#XXX: implement template expansion for all content types in ContentHandler?
'comment',
'parsedcomment',
'content',
- 'tags'
+ 'tags',
+ 'parsetree',
),
ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-prop',
),
),
'generatexml' => array(
ApiBase::PARAM_DFLT => false,
+ ApiBase::PARAM_DEPRECATED => true,
ApiBase::PARAM_HELP_MSG => 'apihelp-query+revisions+base-param-generatexml',
),
'parse' => array(
"apihelp-parse-paramvalue-prop-properties": "Gives various properties defined in the parsed wikitext.",
"apihelp-parse-paramvalue-prop-limitreportdata": "Gives the limit report in a structured way. Gives no data, when <var>$1disablepp</var> is set.",
"apihelp-parse-paramvalue-prop-limitreporthtml": "Gives the HTML version of the limit report. Gives no data, when <var>$1disablepp</var> is set.",
+ "apihelp-parse-paramvalue-prop-parsetree": "The XML parse tree of revision content (requires content model <code>$1</code>)",
"apihelp-parse-param-pst": "Do a pre-save transform on the input before parsing it. Only valid when used with text.",
"apihelp-parse-param-onlypst": "Do a pre-save transform (PST) on the input, but don't parse it. Returns the same wikitext, after a PST has been applied. Only valid when used with <var>$1text</var>.",
"apihelp-parse-param-effectivelanglinks": "Includes language links supplied by extensions (for use with <kbd>$1prop=langlinks</kbd>).",
"apihelp-parse-param-sectiontitle": "New section title when <var>section</var> is <kbd>new</kbd>.\n\nUnlike page editing, this does not fall back to <var>summary</var> when omitted or empty.",
"apihelp-parse-param-disablepp": "Disable the PP Report from the parser output.",
"apihelp-parse-param-disableeditsection": "Disable edit section links from the parser output.",
- "apihelp-parse-param-generatexml": "Generate XML parse tree (requires content model <code>$1</code>).",
+ "apihelp-parse-param-generatexml": "Generate XML parse tree (requires content model <code>$1</code>; replaced by <kbd>$2prop=parsetree</kbd>).",
"apihelp-parse-param-preview": "Parse in preview mode.",
"apihelp-parse-param-sectionpreview": "Parse in section preview mode (enables preview mode too).",
"apihelp-parse-param-disabletoc": "Disable table of contents in output.",
"apihelp-query+revisions-example-first5-after": "Get first 5 revisions of the <kbd>Main Page</kbd> made after 2006-05-01.",
"apihelp-query+revisions-example-first5-not-localhost": "Get first 5 revisions of the <kbd>Main Page</kbd> that were not made by anonymous user <kbd>127.0.0.1</kbd>.",
"apihelp-query+revisions-example-first5-user": "Get first 5 revisions of the <kbd>Main Page</kbd> that were made by the user <kbd>MediaWiki default</kbd>.",
- "apihelp-query+revisions+base-param-prop": "Which properties to get for each revision:\n;ids:The ID of the revision.\n;flags:Revision flags (minor).\n;timestamp:The timestamp of the revision.\n;user:User that made the revision.\n;userid:User ID of the revision creator.\n;size:Length (bytes) of the revision.\n;sha1:SHA-1 (base 16) of the revision.\n;contentmodel:Content model ID of the revision.\n;comment:Comment by the user for the revision.\n;parsedcomment:Parsed comment by the user for the revision.\n;content:Text of the revision.\n;tags:Tags for the revision.",
+ "apihelp-query+revisions+base-param-prop": "Which properties to get for each revision:\n;ids:The ID of the revision.\n;flags:Revision flags (minor).\n;timestamp:The timestamp of the revision.\n;user:User that made the revision.\n;userid:User ID of the revision creator.\n;size:Length (bytes) of the revision.\n;sha1:SHA-1 (base 16) of the revision.\n;contentmodel:Content model ID of the revision.\n;comment:Comment by the user for the revision.\n;parsedcomment:Parsed comment by the user for the revision.\n;content:Text of the revision.\n;tags:Tags for the revision.\n;parsetree:The XML parse tree of revision content.",
"apihelp-query+revisions+base-param-limit": "Limit how many revisions will be returned.",
"apihelp-query+revisions+base-param-expandtemplates": "Expand templates in revision content (requires $1prop=content).",
- "apihelp-query+revisions+base-param-generatexml": "Generate XML parse tree for revision content (requires $1prop=content).",
+ "apihelp-query+revisions+base-param-generatexml": "Generate XML parse tree for revision content (requires $1prop=content; replaced by <kbd>$1prop=parsetree</kbd>).",
"apihelp-query+revisions+base-param-parse": "Parse revision content (requires $1prop=content). For performance reasons, if this option is used, $1limit is enforced to 1.",
"apihelp-query+revisions+base-param-section": "Only retrieve the content of this section number.",
"apihelp-query+revisions+base-param-diffto": "Revision ID to diff each revision to. Use <kbd>prev</kbd>, <kbd>next</kbd> and <kbd>cur</kbd> for the previous, next and current revision respectively.",
"apihelp-parse-paramvalue-prop-properties": "{{doc-apihelp-paramvalue|parse|prop|properties}}",
"apihelp-parse-paramvalue-prop-limitreportdata": "{{doc-apihelp-paramvalue|parse|prop|limitreportdata}}",
"apihelp-parse-paramvalue-prop-limitreporthtml": "{{doc-apihelp-paramvalue|parse|prop|limitreporthtml}}",
+ "apihelp-parse-paramvalue-prop-parsetree": "{{doc-apihelp-paramvalue|parse|prop|parsetree|params=* $1 - Value of the constant CONTENT_MODEL_WIKITEXT|paramstart=2}}",
"apihelp-parse-param-pst": "{{doc-apihelp-param|parse|pst}}",
"apihelp-parse-param-onlypst": "{{doc-apihelp-param|parse|onlypst}}",
"apihelp-parse-param-effectivelanglinks": "{{doc-apihelp-param|parse|effectivelanglinks}}",