parent = $parent; } public function addHTML( $html ) { $this->contents .= $html; $this->flush(); } public function addWikiText( $text ) { $this->addHTML( $this->parent->parse( $text ) ); } public function addHTMLNoFlush( $html ) { $this->contents .= $html; } public function redirect( $url ) { if ( $this->headerDone ) { throw new MWException( __METHOD__ . ' called after sending headers' ); } $this->redirectTarget = $url; } public function output() { $this->flush(); $this->outputFooter(); } /** * Get the raw vector CSS, flipping if needed * * @todo Possibly get rid of this function and use ResourceLoader in the manner it was * designed to be used in, rather than just grabbing a list of filenames from it, * and not properly handling such details as media types in module definitions. * * @param string $dir 'ltr' or 'rtl' * @return String */ public function getCSS( $dir ) { // All CSS files these modules reference will be concatenated in sequence // and loaded as one file. $moduleNames = array( 'mediawiki.legacy.shared', 'skins.vector', 'mediawiki.legacy.config', ); $prepend = ''; $css = ''; $cssFileNames = array(); $resourceLoader = new ResourceLoader(); foreach ( $moduleNames as $moduleName ) { $module = $resourceLoader->getModule( $moduleName ); $cssFileNames = $module->getAllStyleFiles(); wfSuppressWarnings(); foreach ( $cssFileNames as $cssFileName ) { if ( !file_exists( $cssFileName ) ) { $prepend .= ResourceLoader::makeComment( "Unable to find $cssFileName." ); continue; } if ( !is_readable( $cssFileName ) ) { $prepend .= ResourceLoader::makeComment( "Unable to read $cssFileName. Please check file permissions." ); continue; } try { if ( preg_match( '/\.less$/', $cssFileName ) ) { // Run the LESS compiler for *.less files (bug 55589) $compiler = ResourceLoader::getLessCompiler(); $cssFileContents = $compiler->compileFile( $cssFileName ); } else { // Regular CSS file $cssFileContents = file_get_contents( $cssFileName ); } if ( $cssFileContents ) { // Rewrite URLs, though don't bother embedding images. While static image // files may be cached, CSS returned by this function is definitely not. $cssDirName = dirname( $cssFileName ); $css .= CSSMin::remap( /* source */ $cssFileContents, /* local */ $cssDirName, /* remote */ '..' . str_replace( array( $GLOBALS['IP'], DIRECTORY_SEPARATOR ), array( '', '/' ), $cssDirName ), /* embedData */ false ); } else { $prepend .= ResourceLoader::makeComment( "Unable to read $cssFileName." ); } } catch ( Exception $e ) { $prepend .= ResourceLoader::formatException( $e ); } $css .= "\n"; } wfRestoreWarnings(); } $css = $prepend . $css; if ( $dir == 'rtl' ) { $css = CSSJanus::transform( $css, true ); } return $css; } /** * "" to index.php?css=foobar for the "" * @return String */ private function getCssUrl() { return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=' . $this->getDir() ); } 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 array */ public function getHeadAttribs() { return array( 'dir' => $this->getDir(), 'lang' => $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 ) { ?>
parent->parse( wfMessage( 'config-sidebar' )->plain(), true ); ?>
getHeadAttribs() ); ?> <?php $this->outputTitle(); ?> getCssUrl() . "\n"; ?> getJQuery(); ?> escaped(); } public function getJQuery() { return Html::linkedScript( "../resources/jquery/jquery.js" ); } }