From: Aaron Schulz Date: Fri, 5 Aug 2016 21:41:40 +0000 (-0700) Subject: Show wgPageParseReport on page previews too X-Git-Tag: 1.31.0-rc.0~6148^2 X-Git-Url: https://git.cyclocoop.org/%7B%24www_url%7Dadmin/compta/banques/%7B%7B%20url_for%28%27admin_users%27%29%20%7D%7D?a=commitdiff_plain;h=1255654ed5a89ed57491bda38f544ed87e3bc601;p=lhc%2Fweb%2Fwiklou.git Show wgPageParseReport on page previews too Also make EditPage::getPreviewLimitReport return the same output instead of using copy-pasted code from the old hook. Bug: T142210 Bug: T142214 Change-Id: I16c3c2da067fd24bf7ae564cb1d61beaa3be58c1 --- diff --git a/includes/EditPage.php b/includes/EditPage.php index 674cf2874e..ee0699383f 100644 --- a/includes/EditPage.php +++ b/includes/EditPage.php @@ -2714,8 +2714,9 @@ class EditPage { $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'hiddencats' ], Linker::formatHiddenCategories( $this->page->getHiddenCategories() ) ) ); - $wgOut->addHTML( Html::rawElement( 'div', [ 'class' => 'limitreport' ], - self::getPreviewLimitReport( $this->mParserOutput ) ) ); + if ( $this->mParserOutput ) { + $wgOut->setLimitReportData( $this->mParserOutput->getLimitReportData() ); + } $wgOut->addModules( 'mediawiki.action.edit.collapsibleFooter' ); @@ -3442,41 +3443,12 @@ HTML return ''; } - $limitReport = Html::rawElement( 'div', [ 'class' => 'mw-limitReportExplanation' ], - wfMessage( 'limitreport-title' )->parseAsBlock() + return ResourceLoader::makeInlineScript( + ResourceLoader::makeConfigSetScript( + [ 'wgPageParseReport' => $output->getLimitReportData() ], + true + ) ); - - // Show/hide animation doesn't work correctly on a table, so wrap it in a div. - $limitReport .= Html::openElement( 'div', [ 'class' => 'preview-limit-report-wrapper' ] ); - - $limitReport .= Html::openElement( 'table', [ - 'class' => 'preview-limit-report wikitable' - ] ) . - Html::openElement( 'tbody' ); - - foreach ( $output->getLimitReportData() as $key => $value ) { - if ( Hooks::run( 'ParserLimitReportFormat', - [ $key, &$value, &$limitReport, true, true ] - ) ) { - $keyMsg = wfMessage( $key ); - $valueMsg = wfMessage( [ "$key-value-html", "$key-value" ] ); - if ( !$valueMsg->exists() ) { - $valueMsg = new RawMessage( '$1' ); - } - if ( !$keyMsg->isDisabled() && !$valueMsg->isDisabled() ) { - $limitReport .= Html::openElement( 'tr' ) . - Html::rawElement( 'th', null, $keyMsg->parse() ) . - Html::rawElement( 'td', null, $valueMsg->params( $value )->parse() ) . - Html::closeElement( 'tr' ); - } - } - } - - $limitReport .= Html::closeElement( 'tbody' ) . - Html::closeElement( 'table' ) . - Html::closeElement( 'div' ); - - return $limitReport; } protected function showStandardInputs( &$tabindex = 2 ) { diff --git a/includes/OutputPage.php b/includes/OutputPage.php index b6c48abba2..b88db920d0 100644 --- a/includes/OutputPage.php +++ b/includes/OutputPage.php @@ -1773,7 +1773,7 @@ class OutputPage extends ContextSource { } // Include profiling data - $this->limitReportData = $parserOutput->getLimitReportData(); + $this->setLimitReportData( $parserOutput->getLimitReportData() ); // Link flags are ignored for now, but may in the future be // used to mark individual language links. @@ -4051,4 +4051,12 @@ class OutputPage extends ContextSource { // public API or you'll be severely disappointed when T87871 is fixed and it disappears. $this->addMeta( 'X-OOUI-PHP', '1' ); } + + /** + * @param array $data Data from ParserOutput::getLimitReportData() + * @since 1.28 + */ + public function setLimitReportData( array $data ) { + $this->limitReportData = $data; + } }