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 {
|
2014-04-08 10:22:43 +00:00
|
|
|
|
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
|
2014-04-19 11:55:27 +00:00
|
|
|
* @var string
|
2010-11-05 12:48:13 +00:00
|
|
|
*/
|
|
|
|
|
private $contents = '';
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Has the header (or short header) been output?
|
|
|
|
|
* @var bool
|
|
|
|
|
*/
|
|
|
|
|
private $headerDone = false;
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @var string
|
|
|
|
|
*/
|
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
|
|
|
|
|
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param WebInstaller $parent
|
2010-07-21 09:42:07 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( WebInstaller $parent ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->parent = $parent;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $html
|
|
|
|
|
*/
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $text
|
|
|
|
|
*/
|
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 ) );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $html
|
|
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public function addHTMLNoFlush( $html ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->contents .= $html;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $url
|
|
|
|
|
*
|
|
|
|
|
* @throws MWException
|
|
|
|
|
*/
|
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
|
|
|
/**
|
2014-06-04 19:30:14 +00:00
|
|
|
* Get the stylesheet of the MediaWiki skin.
|
2013-10-14 01:34:58 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2010-11-05 13:14:24 +00:00
|
|
|
*/
|
2014-06-04 19:25:55 +00:00
|
|
|
public function getCSS() {
|
2014-06-10 22:25:48 +00:00
|
|
|
global $wgStyleDirectory;
|
|
|
|
|
|
2013-10-14 01:34:58 +00:00
|
|
|
$moduleNames = array(
|
2014-06-04 19:30:14 +00:00
|
|
|
// See SkinTemplate::setupSkinUserCss
|
2013-10-14 01:34:58 +00:00
|
|
|
'mediawiki.legacy.shared',
|
2014-06-04 19:30:14 +00:00
|
|
|
// See Vector::setupSkinUserCss
|
2014-04-29 08:37:46 +00:00
|
|
|
'mediawiki.skinning.interface',
|
2012-03-28 14:18:38 +00:00
|
|
|
);
|
|
|
|
|
|
2014-08-26 19:38:41 +00:00
|
|
|
if ( file_exists( "$wgStyleDirectory/Vector/Vector.php" ) ) {
|
|
|
|
|
// Force loading Vector skin if available as a fallback skin
|
|
|
|
|
// for whatever ResourceLoader wants to have as the default.
|
|
|
|
|
|
|
|
|
|
// Include instead of require, as this will work without it, it will just look bad.
|
|
|
|
|
// We need the 'global' statement for $wgResourceModules because the Vector skin adds the
|
|
|
|
|
// definitions for its RL modules there that we use implicitly below.
|
|
|
|
|
|
|
|
|
|
// @codingStandardsIgnoreStart
|
|
|
|
|
global $wgResourceModules; // This is NOT UNUSED!
|
|
|
|
|
// @codingStandardsIgnoreEnd
|
|
|
|
|
|
|
|
|
|
include_once "$wgStyleDirectory/Vector/Vector.php";
|
|
|
|
|
|
|
|
|
|
$moduleNames[] = 'skins.vector.styles';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
$moduleNames[] = 'mediawiki.legacy.config';
|
2012-03-28 14:18:38 +00:00
|
|
|
|
2013-10-14 01:34:58 +00:00
|
|
|
$resourceLoader = new ResourceLoader();
|
2014-06-04 19:30:14 +00:00
|
|
|
$rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( array(
|
|
|
|
|
'debug' => 'true',
|
|
|
|
|
'lang' => $this->getLanguageCode(),
|
|
|
|
|
'only' => 'styles',
|
|
|
|
|
) ) );
|
2014-08-26 19:38:41 +00:00
|
|
|
|
|
|
|
|
$styles = array();
|
2013-10-14 01:34:58 +00:00
|
|
|
foreach ( $moduleNames as $moduleName ) {
|
2013-11-25 13:42:34 +00:00
|
|
|
/** @var ResourceLoaderFileModule $module */
|
2013-10-14 01:34:58 +00:00
|
|
|
$module = $resourceLoader->getModule( $moduleName );
|
|
|
|
|
|
2014-06-04 19:30:14 +00:00
|
|
|
// Based on: ResourceLoaderFileModule::getStyles (without the DB query)
|
2014-08-26 19:38:41 +00:00
|
|
|
$styles = array_merge( $styles, ResourceLoader::makeCombinedStyles(
|
|
|
|
|
$module->readStyleFiles(
|
|
|
|
|
$module->getStyleFiles( $rlContext ),
|
|
|
|
|
$module->getFlip( $rlContext )
|
|
|
|
|
) ) );
|
2010-11-05 13:14:24 +00:00
|
|
|
}
|
2012-03-28 14:18:38 +00:00
|
|
|
|
2014-08-26 19:38:41 +00:00
|
|
|
return implode( "\n", $styles );
|
2010-11-05 13:14:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-06-04 19:25:55 +00:00
|
|
|
* "<link>" to index.php?css=1 for the "<head>"
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2010-11-05 13:14:24 +00:00
|
|
|
*/
|
2013-03-17 15:13:22 +00:00
|
|
|
private function getCssUrl() {
|
2014-06-04 19:25:55 +00:00
|
|
|
return Html::linkedStyle( $_SERVER['PHP_SELF'] . '?css=1' );
|
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;
|
2013-10-08 11:43:42 +00:00
|
|
|
|
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;
|
2013-10-08 11:43:42 +00:00
|
|
|
|
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
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* @return string[]
|
2011-05-02 16:58:29 +00:00
|
|
|
*/
|
2010-07-21 09:42:07 +00:00
|
|
|
public function getHeadAttribs() {
|
2010-05-08 13:45:14 +00:00
|
|
|
return array(
|
|
|
|
|
'dir' => $this->getDir(),
|
2014-11-13 22:43:52 +00:00
|
|
|
'lang' => wfBCP47( $this->getLanguageCode() ),
|
2010-05-08 13:45:14 +00:00
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2010-11-05 12:48:13 +00:00
|
|
|
/**
|
|
|
|
|
* Get whether the header has been output
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2010-11-05 12:48:13 +00:00
|
|
|
* @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;
|
2011-01-04 06:12:33 +00:00
|
|
|
$this->parent->request->response()->header( 'Content-Type: text/html; charset=utf-8' );
|
2013-10-08 16:08:00 +00:00
|
|
|
|
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' );
|
|
|
|
|
}
|
2013-10-08 16:08:00 +00:00
|
|
|
|
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 );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( $this->useShortHeader ) {
|
|
|
|
|
$this->outputShortHeader();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
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"; ?>
|
2014-08-11 01:59:22 +00:00
|
|
|
<?php echo Html::linkedScript( '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>
|
2014-08-29 20:40:47 +00:00
|
|
|
<div id="content" class="mw-body">
|
|
|
|
|
<div id="bodyContent" class="mw-body-content">
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
<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 ) {
|
2013-10-08 16:33:06 +00:00
|
|
|
echo Html::closeElement( 'body' ) . Html::closeElement( 'html' );
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
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">
|
2014-08-11 01:59:22 +00:00
|
|
|
<a style="background-image: url(images/installer-logo.png);"
|
2014-03-12 22:30:35 +00:00
|
|
|
href="https://www.mediawiki.org/"
|
2010-12-19 04:31:15 +00:00
|
|
|
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>
|
|
|
|
|
|
|
|
|
|
<?php
|
2013-10-08 16:33:06 +00:00
|
|
|
echo Html::closeElement( 'body' ) . Html::closeElement( 'html' );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
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(); ?>
|
2014-08-11 01:59:22 +00:00
|
|
|
<?php echo Html::linkedScript( '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
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-09-09 22:11:19 +00:00
|
|
|
public function getJQuery() {
|
2014-04-18 14:39:37 +00:00
|
|
|
return Html::linkedScript( "../resources/lib/jquery/jquery.js" );
|
2010-05-07 13:28:29 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-11-05 12:48:13 +00:00
|
|
|
}
|