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
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-08-21 18:20:09 +00:00
|
|
|
*/
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2019-02-16 23:16:09 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
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.
|
|
|
|
|
*
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-07-29 18:36:39 +00:00
|
|
|
* @since 1.17
|
2020-06-26 12:14:23 +00:00
|
|
|
* @internal
|
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();
|
|
|
|
|
}
|
|
|
|
|
|
2018-09-21 16:25:26 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $text
|
2018-10-22 03:00:14 +00:00
|
|
|
* @since 1.32
|
2018-09-21 16:25:26 +00:00
|
|
|
*/
|
2018-10-22 03:00:14 +00:00
|
|
|
public function addWikiTextAsInterface( $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();
|
2016-05-13 19:27:06 +00:00
|
|
|
|
|
|
|
|
if ( !$this->redirectTarget ) {
|
|
|
|
|
$this->outputFooter();
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
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() {
|
2019-02-16 23:16:09 +00:00
|
|
|
$resourceLoader = MediaWikiServices::getInstance()->getResourceLoader();
|
2015-05-04 18:41:13 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$rlContext = new ResourceLoaderContext( $resourceLoader, new FauxRequest( [
|
2021-04-14 21:52:37 +00:00
|
|
|
'debug' => 'true',
|
|
|
|
|
'lang' => $this->getLanguage()->getCode(),
|
|
|
|
|
'only' => 'styles',
|
2016-02-17 09:09:32 +00:00
|
|
|
] ) );
|
2014-08-26 19:38:41 +00:00
|
|
|
|
2021-04-14 21:52:37 +00:00
|
|
|
$module = new ResourceLoaderSkinModule( [
|
|
|
|
|
'features' => [
|
|
|
|
|
'elements',
|
2021-04-14 22:03:44 +00:00
|
|
|
'interface-message-box'
|
2021-04-14 21:52:37 +00:00
|
|
|
],
|
|
|
|
|
'styles' => [
|
|
|
|
|
'mw-config/config.css',
|
|
|
|
|
],
|
|
|
|
|
] );
|
2021-06-11 15:11:37 +00:00
|
|
|
$module->setConfig( $resourceLoader->getConfig() );
|
2021-04-14 21:52:37 +00:00
|
|
|
|
|
|
|
|
// Based on: ResourceLoaderFileModule::getStyles (without the DB query)
|
|
|
|
|
$styles = ResourceLoader::makeCombinedStyles(
|
|
|
|
|
$module->readStyleFiles(
|
|
|
|
|
$module->getStyleFiles( $rlContext ),
|
|
|
|
|
$rlContext
|
|
|
|
|
) );
|
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() {
|
2018-10-29 06:18:50 +00:00
|
|
|
return Html::linkedStyle( $this->parent->getUrl( [ '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
|
|
|
/**
|
2018-10-23 15:48:31 +00:00
|
|
|
* @since 1.33
|
|
|
|
|
* @return Language
|
2011-05-02 16:58:29 +00:00
|
|
|
*/
|
2018-10-23 15:48:31 +00:00
|
|
|
private function getLanguage() {
|
2010-05-08 13:45:14 +00:00
|
|
|
global $wgLang;
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2019-08-26 12:24:37 +00:00
|
|
|
return is_object( $wgLang ) ? $wgLang
|
|
|
|
|
: MediaWikiServices::getInstance()->getLanguageFactory()->getLanguage( '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() {
|
2016-02-17 09:09:32 +00:00
|
|
|
return [
|
2018-10-23 15:48:31 +00:00
|
|
|
'dir' => $this->getLanguage()->getDir(),
|
|
|
|
|
'lang' => $this->getLanguage()->getHtmlCode(),
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
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;
|
|
|
|
|
}
|
2020-03-19 21:32:05 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
?>
|
2010-05-08 13:45:14 +00:00
|
|
|
<?php echo Html::htmlHeader( $this->getHeadAttribs() ); ?>
|
2016-07-21 19:55:04 +00:00
|
|
|
|
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>
|
|
|
|
|
|
2018-10-23 15:48:31 +00:00
|
|
|
<?php echo Html::openElement( 'body', [ 'class' => $this->getLanguage()->getDir() ] ) . "\n"; ?>
|
2010-11-17 11:43:57 +00:00
|
|
|
<div id="mw-page-base"></div>
|
|
|
|
|
<div id="mw-head-base"></div>
|
2019-06-18 00:23:13 +00:00
|
|
|
<div id="content" class="mw-body" role="main">
|
2014-08-29 20:40:47 +00:00
|
|
|
<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">
|
2019-06-14 08:46:40 +00:00
|
|
|
<a href="https://www.mediawiki.org/" title="Main Page"></a>
|
2010-05-07 12:25:01 +00:00
|
|
|
</div>
|
|
|
|
|
<?php
|
2014-12-01 19:23:43 +00:00
|
|
|
$message = wfMessage( 'config-sidebar' )->plain();
|
2019-07-04 22:00:48 +00:00
|
|
|
// Section 1: External links
|
|
|
|
|
// @todo FIXME: Migrate to plain link label messages (T227297).
|
2014-11-27 17:03:07 +00:00
|
|
|
foreach ( explode( '----', $message ) as $section ) {
|
2014-12-01 19:23:43 +00:00
|
|
|
echo '<div class="portal"><div class="body">';
|
|
|
|
|
echo $this->parent->parse( $section, true );
|
|
|
|
|
echo '</div></div>';
|
|
|
|
|
}
|
2019-07-04 22:00:48 +00:00
|
|
|
// Section 2: Installer pages
|
|
|
|
|
echo '<div class="portal"><div class="body"><ul>';
|
|
|
|
|
foreach ( [
|
|
|
|
|
'config-sidebar-relnotes' => 'ReleaseNotes',
|
|
|
|
|
'config-sidebar-license' => 'Copying',
|
|
|
|
|
'config-sidebar-upgrade' => 'UpgradeDoc',
|
|
|
|
|
] as $msgKey => $pageName ) {
|
|
|
|
|
echo $this->parent->makeLinkItem(
|
|
|
|
|
$this->parent->getDocUrl( $pageName ),
|
|
|
|
|
wfMessage( $msgKey )->text()
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
echo '</ul></div></div>';
|
2010-05-07 12:25:01 +00:00
|
|
|
?>
|
|
|
|
|
</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() ); ?>
|
2019-06-14 09:07:33 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
<head>
|
|
|
|
|
<meta name="robots" content="noindex, nofollow" />
|
2019-06-14 09:07:33 +00:00
|
|
|
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
|
2010-05-07 12:25:01 +00:00
|
|
|
<title><?php $this->outputTitle(); ?></title>
|
2011-07-07 16:52:47 +00:00
|
|
|
<?php echo $this->getCssUrl() . "\n"; ?>
|
2019-06-14 09:07:33 +00:00
|
|
|
<?php echo $this->getJQuery() . "\n"; ?>
|
|
|
|
|
<?php echo Html::linkedScript( 'config.js' ) . "\n"; ?>
|
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() {
|
2020-02-25 01:33:18 +00:00
|
|
|
echo wfMessage( 'config-title', MW_VERSION )->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
|
|
|
}
|