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 * @param $dir String 'ltr' or 'rtl' * @return String */ public function getCSS( $dir ) { $skinDir = dirname( dirname( dirname( __FILE__ ) ) ) . '/skins'; $vectorCssFile = "$skinDir/vector/screen.css"; $configCssFile = "$skinDir/common/config.css"; $css = ''; wfSuppressWarnings(); $vectorCss = file_get_contents( $vectorCssFile ); $configCss = file_get_contents( $configCssFile ); wfRestoreWarnings(); if( !$vectorCss || !$configCss ) { $css = "/** Your webserver cannot read $vectorCssFile or $configCssFile, please check file permissions */"; } $css .= str_replace( 'images/', '../skins/vector/images/', $vectorCss ) . "\n" . str_replace( 'images/', '../skins/common/images/', $configCss ); 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; if( !is_object( $wgLang ) || !$wgLang->isRtl() ) { return 'ltr'; } else { return 'rtl'; } } /** * @return string */ public function getLanguageCode() { global $wgLang; if( !is_object( $wgLang ) ) { return 'en'; } else { return $wgLang->getCode(); } } /** * @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; $dbTypes = $this->parent->getDBTypes(); $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() ); ?>