This code has been rotting for a while. It is important missing stylesheets
and critical inline scripts. Consuming these items is quite risky.
One can't safely use it to update an existing document (as some parts are
duplicative or conflicting). One also can't use it to build a new document as
several critical pieces are missing.
* Since ResourceLoader was introduced in 2011, buildCssLinksArray() doesn't have any stylesheets.
For most pages, this will produce an empty array for headitems.
Mark it as deprecated since in favour of 'prop=headhtml' or 'prop=modules'.
Change-Id: I6084e4454e245f59bf3c82d6db830977725f71e5
$titleObj->getPrefixedText();
}
$titleObj->getPrefixedText();
}
- if ( isset( $prop['headitems'] ) || isset( $prop['headhtml'] ) ) {
+ if ( isset( $prop['headitems'] ) ) {
+ $result_array['headitems'] = $this->formatHeadItems( $p_result->getHeadItems() );
+ $this->logFeatureUsage( 'action=parse&prop=headitems' );
+ $this->setWarning( 'headitems is deprecated since MediaWiki 1.28. '
+ . 'Use prop=headhtml when creating new HTML documents, or '
+ . 'prop=modules|jsconfigvars when updating a document client-side.' );
+ }
+
+ if ( isset( $prop['headhtml'] ) ) {
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $titleObj );
$context->setWikiPage( $pageObj );
$context = new DerivativeContext( $this->getContext() );
$context->setTitle( $titleObj );
$context->setWikiPage( $pageObj );
$output = new OutputPage( $context );
$output->addParserOutputMetadata( $p_result );
$output = new OutputPage( $context );
$output->addParserOutputMetadata( $p_result );
- if ( isset( $prop['headitems'] ) ) {
- $headItems = $this->formatHeadItems( $p_result->getHeadItems() );
-
- $css = $this->formatCss( $output->buildCssLinksArray() );
-
- $scripts = [ $output->getHeadScripts() ];
-
- $result_array['headitems'] = array_merge( $headItems, $css, $scripts );
- }
-
- if ( isset( $prop['headhtml'] ) ) {
- $result_array['headhtml'] = $output->headElement( $context->getSkin() );
- $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
- }
+ $result_array['headhtml'] = $output->headElement( $context->getSkin() );
+ $result_array[ApiResult::META_BC_SUBELEMENTS][] = 'headhtml';
}
if ( isset( $prop['modules'] ) ) {
}
if ( isset( $prop['modules'] ) ) {
- private function formatCss( $css ) {
- $result = [];
- foreach ( $css as $file => $link ) {
- $entry = [];
- $entry['file'] = $file;
- ApiResult::setContentValue( $entry, 'link', $link );
- $result[] = $entry;
- }
-
- return $result;
- }
-
private function formatLimitReportData( $limitReportData ) {
$result = [];
private function formatLimitReportData( $limitReportData ) {
$result = [];
"apihelp-parse-paramvalue-prop-sections": "Gives the sections in the parsed wikitext.",
"apihelp-parse-paramvalue-prop-revid": "Adds the revision ID of the parsed page.",
"apihelp-parse-paramvalue-prop-displaytitle": "Adds the title of the parsed wikitext.",
"apihelp-parse-paramvalue-prop-sections": "Gives the sections in the parsed wikitext.",
"apihelp-parse-paramvalue-prop-revid": "Adds the revision ID of the parsed page.",
"apihelp-parse-paramvalue-prop-displaytitle": "Adds the title of the parsed wikitext.",
- "apihelp-parse-paramvalue-prop-headitems": "Gives items to put in the <code><head></code> of the page.",
+ "apihelp-parse-paramvalue-prop-headitems": "<span class=\"apihelp-deprecated\">Deprecated.</span> Gives items to put in the <code><head></code> of the page.",
"apihelp-parse-paramvalue-prop-headhtml": "Gives parsed <code><head></code> of the page.",
"apihelp-parse-paramvalue-prop-headhtml": "Gives parsed <code><head></code> of the page.",
- "apihelp-parse-paramvalue-prop-modules": "Gives the ResourceLoader modules used on the page. Either <kbd>jsconfigvars</kbd> or <kbd>encodedjsconfigvars</kbd> must be requested jointly with <kbd>modules</kbd>.",
- "apihelp-parse-paramvalue-prop-jsconfigvars": "Gives the JavaScript configuration variables specific to the page.",
+ "apihelp-parse-paramvalue-prop-modules": "Gives the ResourceLoader modules used on the page. To load, use <code>mw.loader.using()</code>. Either <kbd>jsconfigvars</kbd> or <kbd>encodedjsconfigvars</kbd> must be requested jointly with <kbd>modules</kbd>.",
+ "apihelp-parse-paramvalue-prop-jsconfigvars": "Gives the JavaScript configuration variables specific to the page. To apply, use <code>mw.config.set()</code>.",
"apihelp-parse-paramvalue-prop-encodedjsconfigvars": "Gives the JavaScript configuration variables specific to the page as a JSON string.",
"apihelp-parse-paramvalue-prop-indicators": "Gives the HTML of page status indicators used on the page.",
"apihelp-parse-paramvalue-prop-iwlinks": "Gives interwiki links in the parsed wikitext.",
"apihelp-parse-paramvalue-prop-encodedjsconfigvars": "Gives the JavaScript configuration variables specific to the page as a JSON string.",
"apihelp-parse-paramvalue-prop-indicators": "Gives the HTML of page status indicators used on the page.",
"apihelp-parse-paramvalue-prop-iwlinks": "Gives interwiki links in the parsed wikitext.",