$result = $this->getBuffer();
$context = new DerivativeContext( $this->getMain() );
- $context->setUser( new User ); // anon to avoid caching issues
$context->setSkin( SkinFactory::getDefaultInstance()->makeSkin( 'apioutput' ) );
+ $context->setTitle( SpecialPage::getTitleFor( 'ApiHelp' ) );
$out = new OutputPage( $context );
+ $context->setOutput( $out );
+
$out->addModules( 'mediawiki.apipretty' );
$out->setPageTitle( $context->msg( 'api-format-title' ) );
- $context->setOutput( $out );
$header = $context->msg( 'api-format-prettyprint-header' )
- ->params( $format, strtolower( $format ) )
- ->parseAsBlock();
+ ->params( $format, strtolower( $format ) )
+ ->parseAsBlock();
$out->addHTML(
Html::rawElement( 'div', array( 'class' => 'api-pretty-header' ),
ApiHelp::fixHelpLinks( $header )
)
);
- if ( wfRunHooks( 'ApiFormatHighlight', array( $context, $result, $mime, $format ) ) ) {
+ if ( Hooks::run( 'ApiFormatHighlight', array( $context, $result, $mime, $format ) ) ) {
$out->addHTML(
Html::element( 'pre', array( 'class' => 'api-pretty-content' ), $result )
);
}
+ // API handles its own clickjacking protection.
+ // Note, that $wgBreakFrames will still override $wgApiFrameOptions for format mode.
+ $out->allowClickJacking();
$out->output();
} else {
// For non-HTML output, clear all errors that might have been
return $this->mBuffer;
}
- public function getExamplesMessages() {
+ protected function getExamplesMessages() {
return array(
'action=query&meta=siteinfo&siprop=namespaces&format=' . $this->getModuleName()
=> array( 'apihelp-format-example-generic', $this->getFormat() )