X-Git-Url: https://git.heureux-cyclage.org/?a=blobdiff_plain;f=includes%2Finstaller%2FWebInstallerOutput.php;h=84d115b51de32d92db582813d6febd6eb7f77e2b;hb=cf69bb176b9fb39502454614e67750bba07d3d4c;hp=58bbac9d5bd29ee127699371bac01632577afc27;hpb=d00ddeef7fd54a22215289f1621ecb687e3e2c44;p=lhc%2Fweb%2Fwiklou.git diff --git a/includes/installer/WebInstallerOutput.php b/includes/installer/WebInstallerOutput.php index 58bbac9d5b..84d115b51d 100644 --- a/includes/installer/WebInstallerOutput.php +++ b/includes/installer/WebInstallerOutput.php @@ -2,6 +2,21 @@ /** * Output handler for the web installer. * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. + * http://www.gnu.org/copyleft/gpl.html + * * @file * @ingroup Deployment */ @@ -18,20 +33,40 @@ * @since 1.17 */ class WebInstallerOutput { - /** * The WebInstaller object this WebInstallerOutput is used by. * * @var WebInstaller */ public $parent; - - public $contents = ''; - public $warnings = ''; - public $headerDone = false; + + /** + * Buffered contents that haven't been output yet + * @var String + */ + private $contents = ''; + + /** + * Has the header (or short header) been output? + * @var bool + */ + private $headerDone = false; + public $redirectTarget; - public $debug = true; - public $useShortHeader = false; + + /** + * Does the current page need to allow being used as a frame? + * If not, X-Frame-Options will be output to forbid it. + * + * @var bool + */ + public $allowFrames = false; + + /** + * Whether to use the limited header (used during CC license callbacks) + * @var bool + */ + private $useShortHeader = false; /** * Constructor. @@ -55,16 +90,6 @@ class WebInstallerOutput { $this->contents .= $html; } - public function addWarning( $msg ) { - $this->warnings .= "

$msg

\n"; - } - - public function addWarningMsg( $msg /*, ... */ ) { - $params = func_get_args(); - array_shift( $params ); - $this->addWarning( wfMsg( $msg, $params ) ); - } - public function redirect( $url ) { if ( $this->headerDone ) { throw new MWException( __METHOD__ . ' called after sending headers' ); @@ -77,10 +102,72 @@ class WebInstallerOutput { $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'; + + // All these files will be concatenated in sequence and loaded + // as one file. + // The string 'images/' in the files' contents will be replaced + // by '../skins/$skinName/images/', where $skinName is what appears + // before the last '/' in each of the strings. + $cssFileNames = array( + + // Basically the "skins.vector" ResourceLoader module styles + 'common/commonElements.css', + 'common/commonContent.css', + 'common/commonInterface.css', + 'vector/screen.css', + + // mw-config specific + 'common/config.css', + ); + + $css = ''; + + wfSuppressWarnings(); + foreach ( $cssFileNames as $cssFileName ) { + $fullCssFileName = "$skinDir/$cssFileName"; + $cssFileContents = file_get_contents( $fullCssFileName ); + if ( $cssFileContents ) { + preg_match( "/^(\w+)\//", $cssFileName, $match ); + $skinName = $match[1]; + $css .= str_replace( 'images/', "../skins/$skinName/images/", $cssFileContents ); + } else { + $css .= "/** Your webserver cannot read $fullCssFileName. Please check file permissions. */"; + } + + $css .= "\n"; + } + wfRestoreWarnings(); + + 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(); @@ -92,22 +179,25 @@ class WebInstallerOutput { } } + /** + * @return string + */ public function getDir() { global $wgLang; - if( !is_object( $wgLang ) || !$wgLang->isRtl() ) - return 'ltr'; - else - return 'rtl'; + return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr'; } + /** + * @return string + */ public function getLanguageCode() { global $wgLang; - if( !is_object( $wgLang ) ) - return 'en'; - else - return $wgLang->getCode(); + return is_object( $wgLang ) ? $wgLang->getCode() : 'en'; } + /** + * @return array + */ public function getHeadAttribs() { return array( 'dir' => $this->getDir(), @@ -115,6 +205,10 @@ class WebInstallerOutput { ); } + /** + * Get whether the header has been output + * @return bool + */ public function headerDone() { return $this->headerDone; } @@ -123,7 +217,10 @@ class WebInstallerOutput { $this->headerDone = true; $dbTypes = $this->parent->getDBTypes(); - $this->parent->request->response()->header("Content-Type: text/html; charset=utf-8"); + $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; @@ -140,24 +237,15 @@ class WebInstallerOutput { <?php $this->outputTitle(); ?> - - - + getCssUrl() . "\n"; ?> getJQuery() . "\n"; ?> - getJQueryTipsy() . "\n"; ?> $this->getDir() ) ) . "\n"; ?> - -
-
+
+
@@ -166,8 +254,6 @@ class WebInstallerOutput { } public function outputFooter() { - $this->outputWarnings(); - if ( $this->useShortHeader ) { ?> @@ -176,25 +262,22 @@ class WebInstallerOutput { } ?> -
+
-
-