2010-05-07 12:25:01 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Output handler for the web installer.
|
|
|
|
|
*
|
2012-05-06 05:50:15 +00:00
|
|
|
* 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
|
|
|
|
|
*
|
2010-08-21 18:20:09 +00:00
|
|
|
* @file
|
|
|
|
|
* @ingroup Deployment
|
|
|
|
|
*/
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Output class modelled on OutputPage.
|
|
|
|
|
*
|
2010-12-06 20:04:28 +00:00
|
|
|
* I've opted to use a distinct class rather than derive from OutputPage here in
|
|
|
|
|
* the interests of separation of concerns: if we used a subclass, there would be
|
|
|
|
|
* quite a lot of things you could do in OutputPage that would break the installer,
|
|
|
|
|
* that wouldn't be immediately obvious.
|
|
|
|
|
*
|
2010-07-29 18:36:39 +00:00
|
|
|
* @ingroup Deployment
|
|
|
|
|
* @since 1.17
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
|
|
|
|
class WebInstallerOutput {
|
2010-07-21 09:42:07 +00:00
|
|
|
/**
|
|
|
|
|
* The WebInstaller object this WebInstallerOutput is used by.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-21 09:42:07 +00:00
|
|
|
* @var WebInstaller
|
2010-12-06 20:04:28 +00:00
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public $parent;
|
2010-11-05 12:48:13 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public $redirectTarget;
|
2010-11-05 12:48:13 +00:00
|
|
|
|
2011-03-27 20:13:30 +00:00
|
|
|
/**
|
|
|
|
|
* 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;
|
|
|
|
|
|
2010-11-05 12:48:13 +00:00
|
|
|
/**
|
|
|
|
|
* Whether to use the limited header (used during CC license callbacks)
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
private $useShortHeader = false;
|
2010-07-21 09:42:07 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Constructor.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-08-21 15:20:23 +00:00
|
|
|
* @param $parent WebInstaller
|
2010-07-21 09:42:07 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( WebInstaller $parent ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->parent = $parent;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function addHTML( $html ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->contents .= $html;
|
|
|
|
|
$this->flush();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function addWikiText( $text ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->addHTML( $this->parent->parse( $text ) );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function addHTMLNoFlush( $html ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->contents .= $html;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function redirect( $url ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->headerDone ) {
|
|
|
|
|
throw new MWException( __METHOD__ . ' called after sending headers' );
|
|
|
|
|
}
|
|
|
|
|
$this->redirectTarget = $url;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function output() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->flush();
|
|
|
|
|
$this->outputFooter();
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-05 13:14:24 +00:00
|
|
|
/**
|
|
|
|
|
* Get the raw vector CSS, flipping if needed
|
2013-03-11 17:15:01 +00:00
|
|
|
* @param string $dir 'ltr' or 'rtl'
|
2010-11-05 13:14:24 +00:00
|
|
|
* @return String
|
|
|
|
|
*/
|
|
|
|
|
public function getCSS( $dir ) {
|
2012-08-27 19:03:15 +00:00
|
|
|
$skinDir = dirname( dirname( __DIR__ ) ) . '/skins';
|
2012-03-28 14:18:38 +00:00
|
|
|
|
|
|
|
|
// 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(
|
2012-05-09 00:08:04 +00:00
|
|
|
|
|
|
|
|
// Basically the "skins.vector" ResourceLoader module styles
|
2012-09-14 19:27:35 +00:00
|
|
|
'common/shared.css',
|
2012-05-09 00:08:04 +00:00
|
|
|
'common/commonElements.css',
|
|
|
|
|
'common/commonContent.css',
|
|
|
|
|
'common/commonInterface.css',
|
|
|
|
|
'vector/screen.css',
|
|
|
|
|
|
|
|
|
|
// mw-config specific
|
|
|
|
|
'common/config.css',
|
2012-03-28 14:18:38 +00:00
|
|
|
);
|
|
|
|
|
|
2010-12-07 01:42:38 +00:00
|
|
|
$css = '';
|
2012-03-28 14:18:38 +00:00
|
|
|
|
2010-11-05 13:14:24 +00:00
|
|
|
wfSuppressWarnings();
|
2012-03-28 14:18:38 +00:00
|
|
|
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";
|
2010-12-03 13:46:21 +00:00
|
|
|
}
|
2012-03-28 14:18:38 +00:00
|
|
|
wfRestoreWarnings();
|
2010-12-03 13:46:21 +00:00
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $dir == 'rtl' ) {
|
2010-11-08 16:19:08 +00:00
|
|
|
$css = CSSJanus::transform( $css, true );
|
2010-11-05 13:14:24 +00:00
|
|
|
}
|
2012-03-28 14:18:38 +00:00
|
|
|
|
2010-11-20 20:24:48 +00:00
|
|
|
return $css;
|
2010-11-05 13:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2012-07-10 12:48:06 +00:00
|
|
|
* "<link>" to index.php?css=foobar for the "<head>"
|
2010-11-05 13:14:24 +00:00
|
|
|
* @return String
|
|
|
|
|
*/
|
2013-03-17 15:13:22 +00:00
|
|
|
private function getCssUrl() {
|
2011-07-07 16:52:47 +00:00
|
|
|
return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=' . $this->getDir() );
|
2010-11-05 13:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function useShortHeader( $use = true ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->useShortHeader = $use;
|
|
|
|
|
}
|
|
|
|
|
|
2011-03-27 20:13:30 +00:00
|
|
|
public function allowFrames( $allow = true ) {
|
|
|
|
|
$this->allowFrames = $allow;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function flush() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !$this->headerDone ) {
|
|
|
|
|
$this->outputHeader();
|
|
|
|
|
}
|
|
|
|
|
if ( !$this->redirectTarget && strlen( $this->contents ) ) {
|
|
|
|
|
echo $this->contents;
|
|
|
|
|
flush();
|
|
|
|
|
$this->contents = '';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2011-05-02 16:58:29 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public function getDir() {
|
2010-05-07 12:25:01 +00:00
|
|
|
global $wgLang;
|
2011-12-12 21:56:26 +00:00
|
|
|
return is_object( $wgLang ) ? $wgLang->getDir() : 'ltr';
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-02 16:58:29 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public function getLanguageCode() {
|
2010-05-08 13:45:14 +00:00
|
|
|
global $wgLang;
|
2011-12-12 21:56:26 +00:00
|
|
|
return is_object( $wgLang ) ? $wgLang->getCode() : 'en';
|
2010-05-08 13:45:14 +00:00
|
|
|
}
|
|
|
|
|
|
2011-05-02 16:58:29 +00:00
|
|
|
/**
|
|
|
|
|
* @return array
|
|
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public function getHeadAttribs() {
|
2010-05-08 13:45:14 +00:00
|
|
|
return array(
|
|
|
|
|
'dir' => $this->getDir(),
|
|
|
|
|
'lang' => $this->getLanguageCode(),
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-05 12:48:13 +00:00
|
|
|
/**
|
|
|
|
|
* Get whether the header has been output
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public function headerDone() {
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->headerDone;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function outputHeader() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->headerDone = true;
|
|
|
|
|
$dbTypes = $this->parent->getDBTypes();
|
|
|
|
|
|
2011-01-04 06:12:33 +00:00
|
|
|
$this->parent->request->response()->header( 'Content-Type: text/html; charset=utf-8' );
|
2013-02-03 19:28:43 +00:00
|
|
|
if ( !$this->allowFrames ) {
|
2011-03-27 20:13:30 +00:00
|
|
|
$this->parent->request->response()->header( 'X-Frame-Options: DENY' );
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->redirectTarget ) {
|
2013-04-13 11:36:24 +00:00
|
|
|
$this->parent->request->response()->header( 'Location: ' . $this->redirectTarget );
|
2010-05-07 12:25:01 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->useShortHeader ) {
|
|
|
|
|
$this->outputShortHeader();
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
?>
|
2010-05-08 13:45:14 +00:00
|
|
|
<?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
|
2010-05-07 12:25:01 +00:00
|
|
|
<head>
|
|
|
|
|
<meta name="robots" content="noindex, nofollow" />
|
|
|
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
|
|
|
|
<title><?php $this->outputTitle(); ?></title>
|
2011-07-07 16:52:47 +00:00
|
|
|
<?php echo $this->getCssUrl() . "\n"; ?>
|
2010-09-09 22:11:19 +00:00
|
|
|
<?php echo $this->getJQuery() . "\n"; ?>
|
2010-05-08 13:45:14 +00:00
|
|
|
<?php echo Html::linkedScript( '../skins/common/config.js' ) . "\n"; ?>
|
2010-05-07 12:25:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
2010-05-08 13:45:14 +00:00
|
|
|
<?php echo Html::openElement( 'body', array( 'class' => $this->getDir() ) ) . "\n"; ?>
|
2010-11-17 11:43:57 +00:00
|
|
|
<div id="mw-page-base"></div>
|
|
|
|
|
<div id="mw-head-base"></div>
|
2010-05-07 12:25:01 +00:00
|
|
|
<div id="content">
|
|
|
|
|
<div id="bodyContent">
|
|
|
|
|
|
|
|
|
|
<h1><?php $this->outputTitle(); ?></h1>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function outputFooter() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->useShortHeader ) {
|
|
|
|
|
?>
|
|
|
|
|
</body></html>
|
|
|
|
|
<?php
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
?>
|
|
|
|
|
|
2010-11-17 11:43:57 +00:00
|
|
|
</div></div>
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
|
2010-11-17 11:43:57 +00:00
|
|
|
<div id="mw-panel">
|
2010-11-20 21:07:34 +00:00
|
|
|
<div class="portal" id="p-logo">
|
2010-05-07 12:25:01 +00:00
|
|
|
<a style="background-image: url(../skins/common/images/mediawiki.png);"
|
2010-12-19 04:31:15 +00:00
|
|
|
href="http://www.mediawiki.org/"
|
|
|
|
|
title="Main Page"></a>
|
2010-05-07 12:25:01 +00:00
|
|
|
</div>
|
2010-11-20 21:07:34 +00:00
|
|
|
<div class="portal"><div class="body">
|
2010-05-07 12:25:01 +00:00
|
|
|
<?php
|
2012-08-21 19:58:47 +00:00
|
|
|
echo $this->parent->parse( wfMessage( 'config-sidebar' )->plain(), true );
|
2010-05-07 12:25:01 +00:00
|
|
|
?>
|
|
|
|
|
</div></div>
|
|
|
|
|
</div>
|
|
|
|
|
|
|
|
|
|
</body>
|
|
|
|
|
</html>
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function outputShortHeader() {
|
2010-05-07 12:25:01 +00:00
|
|
|
?>
|
2010-05-08 13:45:14 +00:00
|
|
|
<?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
|
2010-05-07 12:25:01 +00:00
|
|
|
<head>
|
|
|
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
|
|
|
|
<meta name="robots" content="noindex, nofollow" />
|
|
|
|
|
<title><?php $this->outputTitle(); ?></title>
|
2011-07-07 16:52:47 +00:00
|
|
|
<?php echo $this->getCssUrl() . "\n"; ?>
|
2010-09-09 22:11:19 +00:00
|
|
|
<?php echo $this->getJQuery(); ?>
|
2010-05-08 13:45:14 +00:00
|
|
|
<?php echo Html::linkedScript( '../skins/common/config.js' ); ?>
|
2010-05-07 12:25:01 +00:00
|
|
|
</head>
|
|
|
|
|
|
|
|
|
|
<body style="background-image: none">
|
|
|
|
|
<?php
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
public function outputTitle() {
|
2011-05-15 13:21:16 +00:00
|
|
|
global $wgVersion;
|
2012-08-21 19:58:47 +00:00
|
|
|
echo wfMessage( 'config-title', $wgVersion )->escaped();
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
2010-09-09 22:11:19 +00:00
|
|
|
public function getJQuery() {
|
|
|
|
|
return Html::linkedScript( "../resources/jquery/jquery.js" );
|
2010-05-07 13:28:29 +00:00
|
|
|
}
|
2010-11-05 12:48:13 +00:00
|
|
|
}
|