parent = $parent; } /** * @param string $html */ public function addHTML( $html ) { $this->contents .= $html; $this->flush(); } /** * @param string $text */ public function addWikiText( $text ) { $this->addHTML( $this->parent->parse( $text ) ); } /** * @param string $html */ public function addHTMLNoFlush( $html ) { $this->contents .= $html; } /** * @param string $url * * @throws MWException */ public function redirect( $url ) { if ( $this->headerDone ) { throw new MWException( __METHOD__ . ' called after sending headers' ); } $this->redirectTarget = $url; } public function output() { $this->flush(); if ( !$this->redirectTarget ) { $this->outputFooter(); } } /** * Get the stylesheet of the MediaWiki skin. * * @return string */ public function getCSS() { global $wgStyleDirectory; $moduleNames = [ // See SkinTemplate::setupSkinUserCss 'mediawiki.legacy.shared', // See Vector::setupSkinUserCss 'mediawiki.skinning.interface', ]; $resourceLoader = new ResourceLoader(); if ( file_exists( "$wgStyleDirectory/Vector/skin.json" ) ) { // Force loading Vector skin if available as a fallback skin // for whatever ResourceLoader wants to have as the default. $registry = new ExtensionRegistry(); $data = $registry->readFromQueue( [ "$wgStyleDirectory/Vector/skin.json" => 1, ] ); if ( isset( $data['globals']['wgResourceModules'] ) ) { $resourceLoader->register( $data['globals']['wgResourceModules'] ); } $moduleNames[] = 'skins.vector.styles'; } $moduleNames[] = 'mediawiki.legacy.config'; $rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( [ 'debug' => 'true', 'lang' => $this->getLanguageCode(), 'only' => 'styles', ] ) ); $styles = []; foreach ( $moduleNames as $moduleName ) { /** @var ResourceLoaderFileModule $module */ $module = $resourceLoader->getModule( $moduleName ); if ( !$module ) { // T98043: Don't fatal, but it won't look as pretty. continue; } // Based on: ResourceLoaderFileModule::getStyles (without the DB query) $styles = array_merge( $styles, ResourceLoader::makeCombinedStyles( $module->readStyleFiles( $module->getStyleFiles( $rlContext ), $module->getFlip( $rlContext ), $rlContext ) ) ); } return implode( "\n", $styles ); } /** * "" to index.php?css=1 for the "" * * @return string */ private function getCssUrl() { return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=1' ); } public function useShortHeader( $use = true ) { $this->useShortHeader = $use; } public function allowFrames( $allow = true ) { $this->allowFrames = $allow; } public function flush() { if ( !$this->headerDone ) { $this->outputHeader(); } if ( !$this->redirectTarget && strlen( $this->contents ) ) { echo $this->contents; flush(); $this->contents = ''; } } /** * @return string */ public function getDir() { global $wgLang; return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr'; } /** * @return string */ public function getLanguageCode() { global $wgLang; return is_object( $wgLang ) ? $wgLang->getCode() : 'en'; } /** * @return string[] */ public function getHeadAttribs() { return [ 'dir' => $this->getDir(), 'lang' => LanguageCode::bcp47( $this->getLanguageCode() ), ]; } /** * Get whether the header has been output * * @return bool */ public function headerDone() { return $this->headerDone; } public function outputHeader() { $this->headerDone = true; $this->parent->request->response()->header( 'Content-Type: text/html; charset=utf-8' ); if ( !$this->allowFrames ) { $this->parent->request->response()->header( 'X-Frame-Options: DENY' ); } if ( $this->redirectTarget ) { $this->parent->request->response()->header( 'Location: ' . $this->redirectTarget ); return; } if ( $this->useShortHeader ) { $this->outputShortHeader(); return; } ?> getHeadAttribs() ); ?> <?php $this->outputTitle(); ?> getCssUrl() . "\n"; ?> getJQuery() . "\n"; ?> $this->getDir() ] ) . "\n"; ?>

outputTitle(); ?>

useShortHeader ) { echo Html::closeElement( 'body' ) . Html::closeElement( 'html' ); return; } ?>
plain(); foreach ( explode( '----', $message ) as $section ) { echo '
'; echo $this->parent->parse( $section, true ); echo '
'; } ?>
getHeadAttribs() ); ?> <?php $this->outputTitle(); ?> getCssUrl() . "\n"; ?> getJQuery(); ?> escaped(); } /** * @return string */ public function getJQuery() { return Html::linkedScript( "../resources/lib/jquery/jquery.js" ); } }