2010-05-07 12:25:01 +00:00
|
|
|
<?php
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
|
|
|
|
* Core installer web interface.
|
|
|
|
|
*
|
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
|
|
|
|
2021-12-05 20:03:21 +00:00
|
|
|
use MediaWiki\Languages\LanguageNameUtils;
|
2018-07-29 12:24:54 +00:00
|
|
|
use MediaWiki\MediaWikiServices;
|
|
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* Class for the core installer web interface.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-07-22 17:58:26 +00:00
|
|
|
* @since 1.17
|
|
|
|
|
*/
|
2011-11-23 00:03:42 +00:00
|
|
|
class WebInstaller extends Installer {
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-07-22 17:58:26 +00:00
|
|
|
/**
|
|
|
|
|
* @var WebInstallerOutput
|
|
|
|
|
*/
|
2010-10-02 07:40:54 +00:00
|
|
|
public $output;
|
|
|
|
|
|
2010-07-21 09:34:16 +00:00
|
|
|
/**
|
|
|
|
|
* WebRequest object.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2010-07-21 09:34:16 +00:00
|
|
|
* @var WebRequest
|
|
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public $request;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2010-07-21 09:34:16 +00:00
|
|
|
/**
|
|
|
|
|
* Cached session array.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @var array[]
|
2010-07-21 09:34:16 +00:00
|
|
|
*/
|
2011-01-28 15:00:18 +00:00
|
|
|
protected $session;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2010-10-02 07:40:54 +00:00
|
|
|
/**
|
2010-07-22 17:58:26 +00:00
|
|
|
* Captured PHP error text. Temporary.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @var string[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2011-01-28 15:00:18 +00:00
|
|
|
protected $phpErrors;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* The main sequence of page names. These will be displayed in turn.
|
2012-10-22 10:29:52 +00:00
|
|
|
*
|
|
|
|
|
* To add a new installer page:
|
|
|
|
|
* * Add it to this WebInstaller::$pageSequence property
|
|
|
|
|
* * Add a "config-page-<name>" message
|
2014-05-12 16:32:46 +00:00
|
|
|
* * Add a "WebInstaller<name>" class
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @var string[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
public $pageSequence = [
|
2010-05-07 12:25:01 +00:00
|
|
|
'Language',
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
'ExistingWiki',
|
2010-05-07 12:25:01 +00:00
|
|
|
'Welcome',
|
|
|
|
|
'DBConnect',
|
|
|
|
|
'Upgrade',
|
|
|
|
|
'DBSettings',
|
|
|
|
|
'Name',
|
|
|
|
|
'Options',
|
|
|
|
|
'Install',
|
|
|
|
|
'Complete',
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Out of sequence pages, selectable by the user at any time.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @var string[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
protected $otherPages = [
|
2010-05-07 12:25:01 +00:00
|
|
|
'Restart',
|
|
|
|
|
'ReleaseNotes',
|
|
|
|
|
'Copying',
|
|
|
|
|
'UpgradeDoc', // Can't use Upgrade due to Upgrade step
|
2016-02-17 09:09:32 +00:00
|
|
|
];
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Array of pages which have declared that they have been submitted, have validated
|
2010-07-19 03:16:54 +00:00
|
|
|
* their input, and need no further processing.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @var bool[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2011-01-28 15:00:18 +00:00
|
|
|
protected $happyPages;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* List of "skipped" pages. These are pages that will automatically continue
|
|
|
|
|
* to the next page on any GET request. To avoid breaking the "back" button,
|
|
|
|
|
* they need to be skipped during a back operation.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @var bool[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2011-01-28 15:00:18 +00:00
|
|
|
protected $skippedPages;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Flag indicating that session data may have been lost.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2011-01-28 15:00:18 +00:00
|
|
|
* @var bool
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public $showSessionWarning = false;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2011-01-28 15:00:18 +00:00
|
|
|
/**
|
|
|
|
|
* Numeric index of the page we're on
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2011-01-28 15:00:18 +00:00
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
protected $tabIndex = 1;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2018-11-08 19:18:27 +00:00
|
|
|
/**
|
|
|
|
|
* Numeric index of the help box
|
|
|
|
|
*
|
|
|
|
|
* @var int
|
|
|
|
|
*/
|
|
|
|
|
protected $helpBoxId = 1;
|
|
|
|
|
|
2011-01-28 15:00:18 +00:00
|
|
|
/**
|
|
|
|
|
* Name of the page we're on
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2011-01-28 15:00:18 +00:00
|
|
|
* @var string
|
|
|
|
|
*/
|
|
|
|
|
protected $currentPageName;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2010-10-02 07:40:54 +00:00
|
|
|
/**
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param WebRequest $request
|
2010-07-21 09:34:16 +00:00
|
|
|
*/
|
|
|
|
|
public function __construct( WebRequest $request ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
parent::__construct();
|
|
|
|
|
$this->output = new WebInstallerOutput( $this );
|
|
|
|
|
$this->request = $request;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Main entry point.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2014-07-24 17:43:03 +00:00
|
|
|
* @param array[] $session Initial session array
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @return array[] New session array
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-21 09:34:16 +00:00
|
|
|
public function execute( array $session ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->session = $session;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( isset( $session['settings'] ) ) {
|
|
|
|
|
$this->settings = $session['settings'] + $this->settings;
|
2018-03-20 01:35:43 +00:00
|
|
|
// T187586 MediaWikiServices works with globals
|
|
|
|
|
foreach ( $this->settings as $key => $val ) {
|
|
|
|
|
$GLOBALS[$key] = $val;
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setupLanguage();
|
|
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( ( $this->getVar( '_InstallDone' ) || $this->getVar( '_UpgradeDone' ) )
|
2013-10-08 11:43:42 +00:00
|
|
|
&& $this->request->getVal( 'localsettings' )
|
|
|
|
|
) {
|
2018-07-12 02:48:34 +00:00
|
|
|
$this->outputLS();
|
2010-07-14 01:18:14 +00:00
|
|
|
return $this->session;
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-04 19:25:55 +00:00
|
|
|
$isCSS = $this->request->getVal( 'css' );
|
|
|
|
|
if ( $isCSS ) {
|
|
|
|
|
$this->outputCss();
|
2010-11-05 13:14:24 +00:00
|
|
|
return $this->session;
|
|
|
|
|
}
|
|
|
|
|
|
2018-10-20 21:55:44 +00:00
|
|
|
$this->happyPages = $session['happyPages'] ?? [];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2018-10-20 21:55:44 +00:00
|
|
|
$this->skippedPages = $session['skippedPages'] ?? [];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$lowestUnhappy = $this->getLowestUnhappy();
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
# Special case for Creative Commons partner chooser box.
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->request->getVal( 'SubmitCC' ) ) {
|
2019-08-31 16:14:38 +00:00
|
|
|
/** @var WebInstallerOptions $page */
|
2010-05-07 12:25:01 +00:00
|
|
|
$page = $this->getPageByName( 'Options' );
|
2019-08-31 16:14:38 +00:00
|
|
|
'@phan-var WebInstallerOptions $page';
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->output->useShortHeader();
|
2011-03-27 20:13:30 +00:00
|
|
|
$this->output->allowFrames();
|
2010-05-07 12:25:01 +00:00
|
|
|
$page->submitCC();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->finish();
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->request->getVal( 'ShowCC' ) ) {
|
2019-08-31 16:14:38 +00:00
|
|
|
/** @var WebInstallerOptions $page */
|
2010-05-07 12:25:01 +00:00
|
|
|
$page = $this->getPageByName( 'Options' );
|
2019-08-31 16:14:38 +00:00
|
|
|
'@phan-var WebInstallerOptions $page';
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->output->useShortHeader();
|
2011-03-27 20:13:30 +00:00
|
|
|
$this->output->allowFrames();
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->output->addHTML( $page->getCCDoneBox() );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->finish();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
# Get the page name.
|
2022-03-09 19:15:36 +00:00
|
|
|
$pageName = $this->request->getVal( 'page', '' );
|
2010-05-07 12:25:01 +00:00
|
|
|
|
* Made the web upgrade process more friendly. Instead of saying "access denied, go away" when the user has a normal LocalSettings.php file, generate a random $wgUpgradeKey and instruct the user to insert it into their LocalSettings.php. The subsequent file modification then authenticates the session and allows the upgrade.
* When an upgrade key is entered, or a supplied upgrade key is edited into LocalSettings.php by the upgrader, fetch database settings from LocalSettings.php and AdminSettings.php for use during the upgrade. This allows the DBConnect page to be skipped, making web upgrade almost as easy to use as CLI upgrade.
* Made LocalSettingsGenerator add $wgUpgradeKey in non-commented form, for easier subsequent upgrades.
* Converted the $wgUpgradeKey check to a normal in-sequence page, called ExistingWiki. This allows the removal of related special cases from WebInstaller. The code for WebInstaller_ExistingWiki is loosely based on WebInstaller_Locked.
* Added Status::replaceMessage(), to support informative DB connection error messages from the ExistingWiki page.
* In WebInstaller::getInfoBox(), call parse() with $lineStart=true, so that line-start syntax like bullet points can work.
* Reduced the length of the generated $wgUpgradeKey from 64 to 16. This is ample for what it does, and makes it fit on the screen and not overlap with the right sidebar when when displayed by WebInstaller_ExistingWiki.
* Added $wgUpgradeKey to DefaultSettings.php.
2010-12-09 08:24:54 +00:00
|
|
|
if ( in_array( $pageName, $this->otherPages ) ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
# Out of sequence
|
|
|
|
|
$pageId = false;
|
|
|
|
|
$page = $this->getPageByName( $pageName );
|
|
|
|
|
} else {
|
|
|
|
|
# Main sequence
|
|
|
|
|
if ( !$pageName || !in_array( $pageName, $this->pageSequence ) ) {
|
|
|
|
|
$pageId = $lowestUnhappy;
|
|
|
|
|
} else {
|
|
|
|
|
$pageId = array_search( $pageName, $this->pageSequence );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
# If necessary, move back to the lowest-numbered unhappy page
|
|
|
|
|
if ( $pageId > $lowestUnhappy ) {
|
|
|
|
|
$pageId = $lowestUnhappy;
|
|
|
|
|
if ( $lowestUnhappy == 0 ) {
|
2010-07-21 09:42:07 +00:00
|
|
|
# Knocked back to start, possible loss of session data.
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->showSessionWarning = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$pageName = $this->pageSequence[$pageId];
|
|
|
|
|
$page = $this->getPageByName( $pageName );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
# If a back button was submitted, go back without submitting the form data.
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->request->wasPosted() && $this->request->getBool( 'submit-back' ) ) {
|
|
|
|
|
if ( $this->request->getVal( 'lastPage' ) ) {
|
|
|
|
|
$nextPage = $this->request->getVal( 'lastPage' );
|
|
|
|
|
} elseif ( $pageId !== false ) {
|
|
|
|
|
# Main sequence page
|
|
|
|
|
# Skip the skipped pages
|
|
|
|
|
$nextPageId = $pageId;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
do {
|
|
|
|
|
$nextPageId--;
|
|
|
|
|
$nextPage = $this->pageSequence[$nextPageId];
|
2013-04-20 21:11:46 +00:00
|
|
|
} while ( isset( $this->skippedPages[$nextPage] ) );
|
2010-05-07 12:25:01 +00:00
|
|
|
} else {
|
|
|
|
|
$nextPage = $this->pageSequence[$lowestUnhappy];
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->finish();
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
# Execute the page.
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->currentPageName = $page->getName();
|
|
|
|
|
$this->startPageWrapper( $pageName );
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( $page->isSlow() ) {
|
2011-06-21 01:13:45 +00:00
|
|
|
$this->disableTimeLimit();
|
|
|
|
|
}
|
|
|
|
|
|
2010-10-25 23:18:47 +00:00
|
|
|
$result = $page->execute();
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->endPageWrapper();
|
|
|
|
|
|
|
|
|
|
if ( $result == 'skip' ) {
|
2010-07-21 09:42:07 +00:00
|
|
|
# Page skipped without explicit submission.
|
|
|
|
|
# Skip it when we click "back" so that we don't just go forward again.
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->skippedPages[$pageName] = true;
|
|
|
|
|
$result = 'continue';
|
|
|
|
|
} else {
|
|
|
|
|
unset( $this->skippedPages[$pageName] );
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
# If it was posted, the page can request a continue to the next page.
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $result === 'continue' && !$this->output->headerDone() ) {
|
|
|
|
|
if ( $pageId !== false ) {
|
|
|
|
|
$this->happyPages[$pageId] = true;
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$lowestUnhappy = $this->getLowestUnhappy();
|
|
|
|
|
|
|
|
|
|
if ( $this->request->getVal( 'lastPage' ) ) {
|
|
|
|
|
$nextPage = $this->request->getVal( 'lastPage' );
|
|
|
|
|
} elseif ( $pageId !== false ) {
|
|
|
|
|
$nextPage = $this->pageSequence[$pageId + 1];
|
|
|
|
|
} else {
|
|
|
|
|
$nextPage = $this->pageSequence[$lowestUnhappy];
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( array_search( $nextPage, $this->pageSequence ) > $lowestUnhappy ) {
|
|
|
|
|
$nextPage = $this->pageSequence[$lowestUnhappy];
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->output->redirect( $this->getUrl( [ 'page' => $nextPage ] ) );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->finish();
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-28 15:00:18 +00:00
|
|
|
/**
|
|
|
|
|
* Find the next page in sequence that hasn't been completed
|
|
|
|
|
* @return int
|
|
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getLowestUnhappy() {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( count( $this->happyPages ) == 0 ) {
|
|
|
|
|
return 0;
|
|
|
|
|
} else {
|
|
|
|
|
return max( array_keys( $this->happyPages ) ) + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Start the PHP session. This may be called before execute() to start the PHP session.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2013-11-25 13:42:34 +00:00
|
|
|
* @throws Exception
|
2011-05-02 16:58:29 +00:00
|
|
|
* @return bool
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function startSession() {
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( wfIniGetBool( 'session.auto_start' ) || session_id() ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
// Done already
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2020-06-25 06:03:35 +00:00
|
|
|
// Use secure cookies if we are on HTTPS
|
|
|
|
|
$options = [];
|
|
|
|
|
if ( $this->request->getProtocol() === 'https' ) {
|
|
|
|
|
$options['cookie_secure'] = '1';
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->phpErrors = [];
|
|
|
|
|
set_error_handler( [ $this, 'errorHandler' ] );
|
2013-11-15 15:13:19 +00:00
|
|
|
try {
|
2015-10-09 21:25:36 +00:00
|
|
|
session_name( 'mw_installer_session' );
|
2020-06-25 06:03:35 +00:00
|
|
|
session_start( $options );
|
2013-11-15 15:13:19 +00:00
|
|
|
} catch ( Exception $e ) {
|
|
|
|
|
restore_error_handler();
|
|
|
|
|
throw $e;
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
restore_error_handler();
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->phpErrors ) {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:20:01 +00:00
|
|
|
/**
|
|
|
|
|
* Get a hash of data identifying this MW installation.
|
|
|
|
|
*
|
2011-02-26 12:35:23 +00:00
|
|
|
* This is used by mw-config/index.php to prevent multiple installations of MW
|
2010-12-06 23:13:35 +00:00
|
|
|
* on the same cookie domain from interfering with each other.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
2010-12-06 13:20:01 +00:00
|
|
|
*/
|
|
|
|
|
public function getFingerprint() {
|
|
|
|
|
// Get the base URL of the installation
|
|
|
|
|
$url = $this->request->getFullRequestURL();
|
2013-03-24 10:01:51 +00:00
|
|
|
if ( preg_match( '!^(.*\?)!', $url, $m ) ) {
|
2011-03-27 20:13:30 +00:00
|
|
|
// Trim query string
|
|
|
|
|
$url = $m[1];
|
|
|
|
|
}
|
2010-12-06 13:20:01 +00:00
|
|
|
if ( preg_match( '!^(.*)/[^/]*/[^/]*$!', $url, $m ) ) {
|
2011-03-27 20:13:30 +00:00
|
|
|
// This... seems to try to get the base path from
|
|
|
|
|
// the /mw-config/index.php. Kinda scary though?
|
2010-12-06 13:20:01 +00:00
|
|
|
$url = $m[1];
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return md5( serialize( [
|
2012-08-27 19:03:15 +00:00
|
|
|
'local path' => dirname( __DIR__ ),
|
2010-12-06 13:20:01 +00:00
|
|
|
'url' => $url,
|
2020-02-25 01:33:18 +00:00
|
|
|
'version' => MW_VERSION
|
2016-02-17 09:09:32 +00:00
|
|
|
] ) );
|
2010-12-06 13:20:01 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2015-10-29 12:24:40 +00:00
|
|
|
* Show an error message in a box. Parameters are like wfMessage(), or
|
|
|
|
|
* alternatively, pass a Message object in.
|
|
|
|
|
* @param string|Message $msg
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
* @param mixed ...$params
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
public function showError( $msg, ...$params ) {
|
2015-10-29 12:24:40 +00:00
|
|
|
if ( !( $msg instanceof Message ) ) {
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
$msg = wfMessage(
|
|
|
|
|
$msg,
|
|
|
|
|
array_map( 'htmlspecialchars', $params )
|
|
|
|
|
);
|
2015-10-29 12:24:40 +00:00
|
|
|
}
|
2020-02-08 18:54:41 +00:00
|
|
|
$text = $msg->useDatabase( false )->parse();
|
2019-09-17 04:39:49 +00:00
|
|
|
$box = Html::errorBox( $text, '', 'config-error-box' );
|
|
|
|
|
$this->output->addHTML( $box );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Temporary error handler for session start debugging.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @param int $errno Unused
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $errstr
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function errorHandler( $errno, $errstr ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->phpErrors[] = $errstr;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Clean up from execute()
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @return array[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-07 10:55:53 +00:00
|
|
|
public function finish() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->output->output();
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->session['happyPages'] = $this->happyPages;
|
|
|
|
|
$this->session['skippedPages'] = $this->skippedPages;
|
|
|
|
|
$this->session['settings'] = $this->settings;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->session;
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-28 15:00:18 +00:00
|
|
|
/**
|
|
|
|
|
* We're restarting the installation, reset the session, happyPages, etc
|
|
|
|
|
*/
|
|
|
|
|
public function reset() {
|
2016-02-17 09:09:32 +00:00
|
|
|
$this->session = [];
|
|
|
|
|
$this->happyPages = [];
|
|
|
|
|
$this->settings = [];
|
2011-01-28 15:00:18 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a URL for submission back to the same script.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param string[] $query
|
|
|
|
|
*
|
2011-01-28 15:00:18 +00:00
|
|
|
* @return string
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2016-02-17 09:09:32 +00:00
|
|
|
public function getUrl( $query = [] ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$url = $this->request->getRequestURL();
|
|
|
|
|
# Remove existing query
|
|
|
|
|
$url = preg_replace( '/\?.*$/', '', $url );
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $query ) {
|
2013-01-28 18:04:20 +00:00
|
|
|
$url .= '?' . wfArrayToCgi( $query );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $url;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a WebInstallerPage by name.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $pageName
|
2010-07-21 09:34:16 +00:00
|
|
|
* @return WebInstallerPage
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getPageByName( $pageName ) {
|
2014-05-12 16:32:46 +00:00
|
|
|
$pageClass = 'WebInstaller' . $pageName;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return new $pageClass( $this );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a session variable.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $name
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param array|null $default
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2022-02-26 07:54:16 +00:00
|
|
|
* @return array|null
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getSession( $name, $default = null ) {
|
2018-10-20 21:55:44 +00:00
|
|
|
return $this->session[$name] ?? $default;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Set a session variable.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $name Key for the variable
|
|
|
|
|
* @param mixed $value
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function setSession( $name, $value ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->session[$name] = $value;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get the next tabindex attribute value.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2011-01-28 15:00:18 +00:00
|
|
|
* @return int
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function nextTabIndex() {
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->tabIndex++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Initializes language-related variables.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function setupLanguage() {
|
2020-05-08 18:11:23 +00:00
|
|
|
global $wgLang, $wgLanguageCode;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $this->getSession( 'test' ) === null && !$this->request->wasPosted() ) {
|
|
|
|
|
$wgLanguageCode = $this->getAcceptLanguage();
|
2019-08-26 12:24:37 +00:00
|
|
|
$wgLang = MediaWikiServices::getInstance()->getLanguageFactory()
|
|
|
|
|
->getLanguage( $wgLanguageCode );
|
2016-03-01 21:50:26 +00:00
|
|
|
RequestContext::getMain()->setLanguage( $wgLang );
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->setVar( 'wgLanguageCode', $wgLanguageCode );
|
|
|
|
|
$this->setVar( '_UserLang', $wgLanguageCode );
|
|
|
|
|
} else {
|
|
|
|
|
$wgLanguageCode = $this->getVar( 'wgLanguageCode' );
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Retrieves MediaWiki language from Accept-Language HTTP header.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2010-07-21 09:34:16 +00:00
|
|
|
* @return string
|
2021-11-20 16:02:29 +00:00
|
|
|
* @return-taint none It can only return a known-good code.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getAcceptLanguage() {
|
2010-08-02 20:16:36 +00:00
|
|
|
global $wgLanguageCode, $wgRequest;
|
2010-05-07 12:25:01 +00:00
|
|
|
|
2020-01-03 23:03:14 +00:00
|
|
|
$mwLanguages = MediaWikiServices::getInstance()
|
|
|
|
|
->getLanguageNameUtils()
|
2021-12-05 20:03:21 +00:00
|
|
|
->getLanguageNames( LanguageNameUtils::AUTONYMS, LanguageNameUtils::SUPPORTED );
|
2010-08-02 20:16:36 +00:00
|
|
|
$headerLanguages = array_keys( $wgRequest->getAcceptLang() );
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-08-02 20:16:36 +00:00
|
|
|
foreach ( $headerLanguages as $lang ) {
|
|
|
|
|
if ( isset( $mwLanguages[$lang] ) ) {
|
|
|
|
|
return $lang;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $wgLanguageCode;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Called by execute() before page output starts, to show a page list.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $currentPageName
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-10-26 12:02:23 +00:00
|
|
|
private function startPageWrapper( $currentPageName ) {
|
2010-11-22 23:52:59 +00:00
|
|
|
$s = "<div class=\"config-page-wrapper\">\n";
|
|
|
|
|
$s .= "<div class=\"config-page\">\n";
|
|
|
|
|
$s .= "<div class=\"config-page-list\"><ul>\n";
|
2010-05-07 12:25:01 +00:00
|
|
|
$lastHappy = -1;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
foreach ( $this->pageSequence as $id => $pageName ) {
|
|
|
|
|
$happy = !empty( $this->happyPages[$id] );
|
2010-10-02 07:40:54 +00:00
|
|
|
$s .= $this->getPageListItem(
|
2010-07-22 17:58:26 +00:00
|
|
|
$pageName,
|
|
|
|
|
$happy || $lastHappy == $id - 1,
|
|
|
|
|
$currentPageName
|
|
|
|
|
);
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $happy ) {
|
|
|
|
|
$lastHappy = $id;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$s .= "</ul><br/><ul>\n";
|
2011-02-23 17:22:09 +00:00
|
|
|
$s .= $this->getPageListItem( 'Restart', true, $currentPageName );
|
2013-08-28 00:38:27 +00:00
|
|
|
// End list pane
|
|
|
|
|
$s .= "</ul></div>\n";
|
|
|
|
|
|
|
|
|
|
// Messages:
|
2013-08-16 12:58:07 +00:00
|
|
|
// config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
|
|
|
|
|
// config-page-dbsettings, config-page-name, config-page-options, config-page-install,
|
2020-06-22 20:51:04 +00:00
|
|
|
// config-page-complete, config-page-restart, config-page-releasenotes,
|
2013-08-16 12:58:07 +00:00
|
|
|
// config-page-copying, config-page-upgradedoc, config-page-existingwiki
|
2016-02-17 09:09:32 +00:00
|
|
|
$s .= Html::element( 'h2', [],
|
2012-08-21 19:58:47 +00:00
|
|
|
wfMessage( 'config-page-' . strtolower( $currentPageName ) )->text() );
|
2010-05-07 12:25:01 +00:00
|
|
|
|
|
|
|
|
$this->output->addHTMLNoFlush( $s );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a list item for the page list.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $pageName
|
|
|
|
|
* @param bool $enabled
|
|
|
|
|
* @param string $currentPageName
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2010-07-21 09:34:16 +00:00
|
|
|
* @return string
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-10-26 12:02:23 +00:00
|
|
|
private function getPageListItem( $pageName, $enabled, $currentPageName ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$s = "<li class=\"config-page-list-item\">";
|
2013-08-28 00:38:27 +00:00
|
|
|
|
|
|
|
|
// Messages:
|
2013-08-16 12:58:07 +00:00
|
|
|
// config-page-language, config-page-welcome, config-page-dbconnect, config-page-upgrade,
|
|
|
|
|
// config-page-dbsettings, config-page-name, config-page-options, config-page-install,
|
2020-06-22 20:51:04 +00:00
|
|
|
// config-page-complete, config-page-restart, config-page-releasenotes,
|
2013-08-16 12:58:07 +00:00
|
|
|
// config-page-copying, config-page-upgradedoc, config-page-existingwiki
|
2012-08-21 19:58:47 +00:00
|
|
|
$name = wfMessage( 'config-page-' . strtolower( $pageName ) )->text();
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $enabled ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$query = [ 'page' => $pageName ];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !in_array( $pageName, $this->pageSequence ) ) {
|
|
|
|
|
if ( in_array( $currentPageName, $this->pageSequence ) ) {
|
|
|
|
|
$query['lastPage'] = $currentPageName;
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-11-04 23:23:34 +00:00
|
|
|
$link = Html::element( 'a',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2010-05-07 12:25:01 +00:00
|
|
|
'href' => $this->getUrl( $query )
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2010-05-07 12:25:01 +00:00
|
|
|
$name
|
|
|
|
|
);
|
|
|
|
|
} else {
|
|
|
|
|
$link = htmlspecialchars( $name );
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $pageName == $currentPageName ) {
|
|
|
|
|
$s .= "<span class=\"config-page-current\">$link</span>";
|
|
|
|
|
} else {
|
|
|
|
|
$s .= $link;
|
|
|
|
|
}
|
|
|
|
|
} else {
|
2010-11-04 23:23:34 +00:00
|
|
|
$s .= Html::element( 'span',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2010-05-07 12:25:01 +00:00
|
|
|
'class' => 'config-page-disabled'
|
2016-02-17 09:09:32 +00:00
|
|
|
],
|
2010-05-07 12:25:01 +00:00
|
|
|
$name
|
|
|
|
|
);
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$s .= "</li>\n";
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $s;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Output some stuff after a page is finished.
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-10-26 12:02:23 +00:00
|
|
|
private function endPageWrapper() {
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->output->addHTMLNoFlush(
|
2013-10-08 11:43:42 +00:00
|
|
|
"<div class=\"visualClear\"></div>\n" .
|
|
|
|
|
"</div>\n" .
|
|
|
|
|
"<div class=\"visualClear\"></div>\n" .
|
2010-05-07 12:25:01 +00:00
|
|
|
"</div>" );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-04 21:13:18 +00:00
|
|
|
* Get HTML for an information message box with an icon.
|
2010-05-08 20:04:48 +00:00
|
|
|
*
|
2019-07-04 21:23:11 +00:00
|
|
|
* @param string|HtmlArmor $text Wikitext to be parsed (from Message::plain) or raw HTML.
|
2022-02-26 08:12:42 +00:00
|
|
|
* @param string|false $icon Icon name, file in mw-config/images. Default: false
|
|
|
|
|
* @param string $class Additional class name to add to the wrapper div. Default: Empty string.
|
2019-07-04 21:13:18 +00:00
|
|
|
* @return string HTML
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2022-02-26 08:12:42 +00:00
|
|
|
public function getInfoBox( $text, $icon = false, $class = '' ) {
|
2019-07-04 21:23:11 +00:00
|
|
|
$html = ( $text instanceof HtmlArmor ) ?
|
|
|
|
|
HtmlArmor::getHtml( $text ) :
|
|
|
|
|
$this->parse( $text, true );
|
2021-08-17 19:52:34 +00:00
|
|
|
$icon = ( !$icon ) ?
|
2014-08-11 01:59:22 +00:00
|
|
|
'images/info-32.png' :
|
|
|
|
|
'images/' . $icon;
|
2012-08-21 19:58:47 +00:00
|
|
|
$alt = wfMessage( 'config-information' )->text();
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2020-11-19 08:00:41 +00:00
|
|
|
return self::infoBox( $html, $icon, $alt, $class );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get small text indented help for a preceding form field.
|
2012-08-21 19:58:47 +00:00
|
|
|
* Parameters like wfMessage().
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $msg
|
2019-11-08 19:58:41 +00:00
|
|
|
* @param mixed ...$args
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
public function getHelpBox( $msg, ...$args ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$args = array_map( 'htmlspecialchars', $args );
|
2012-09-03 08:03:42 +00:00
|
|
|
$text = wfMessage( $msg, $args )->useDatabase( false )->plain();
|
2011-11-05 14:22:58 +00:00
|
|
|
$html = $this->parse( $text, true );
|
2018-11-08 19:18:27 +00:00
|
|
|
$id = 'helpBox-' . $this->helpBoxId++;
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2015-08-15 04:24:26 +00:00
|
|
|
return "<div class=\"config-help-field-container\">\n" .
|
2018-11-08 19:18:27 +00:00
|
|
|
"<input type=\"checkbox\" class=\"config-help-field-checkbox\" id=\"$id\" />" .
|
|
|
|
|
"<label class=\"config-help-field-hint\" for=\"$id\" title=\"" .
|
2014-05-15 15:38:28 +00:00
|
|
|
wfMessage( 'config-help-tooltip' )->escaped() . "\">" .
|
2018-11-08 19:18:27 +00:00
|
|
|
wfMessage( 'config-help' )->escaped() . "</label>\n" .
|
2017-07-24 05:28:57 +00:00
|
|
|
"<div class=\"config-help-field-data\">" . $html . "</div>\n" .
|
2011-11-05 14:22:58 +00:00
|
|
|
"</div>\n";
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-11-22 23:55:37 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Output a help box.
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $msg Key for wfMessage()
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
* @param mixed ...$params
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
public function showHelpBox( $msg, ...$params ) {
|
|
|
|
|
$html = $this->getHelpBox( $msg, ...$params );
|
2010-05-07 12:25:01 +00:00
|
|
|
$this->output->addHTML( $html );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Show a short informational message.
|
2010-05-07 12:25:01 +00:00
|
|
|
* Output looks like a list.
|
2010-10-02 07:40:54 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $msg
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
* @param mixed ...$params
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
public function showMessage( $msg, ...$params ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
$html = '<div class="config-message">' .
|
Get rid of unnecessary func_get_args() and friends
HHVM does not support variadic arguments with type hints. This is
mostly not a big problem, because we can just drop the type hint, but
for some reason PHPUnit adds a type hint of "array" when it creates
mocks, so a class with a variadic method can't be mocked (at least in
some cases). As such, I left alone all the classes that seem like
someone might like to mock them, like Title and User. If anyone wants
to mock them in the future, they'll have to switch back to
func_get_args(). Some of the changes are definitely safe, like
functions and test classes.
In most cases, func_get_args() (and/or func_get_arg(), func_num_args() )
were only present because the code was written before we required PHP
5.6, and writing them as variadic functions is strictly superior. In
some cases I left them alone, aside from HHVM compatibility:
* Forwarding all arguments to another function. It's useful to keep
func_get_args() here where we want to keep the list of expected
arguments and their meanings in the function signature line for
documentation purposes, but don't want to copy-paste a long line of
argument names.
* Handling deprecated calling conventions.
* One or two miscellaneous cases where we're basically using the
arguments individually but want to use them as an array as well for
some reason.
Change-Id: I066ec95a7beb7c0665146195a08e7cce1222c788
2018-10-08 14:10:45 +00:00
|
|
|
$this->parse( wfMessage( $msg, $params )->useDatabase( false )->plain() ) .
|
2010-05-07 12:25:01 +00:00
|
|
|
"</div>\n";
|
|
|
|
|
$this->output->addHTML( $html );
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2014-07-21 08:31:09 +00:00
|
|
|
/**
|
|
|
|
|
* @param Status $status
|
|
|
|
|
*/
|
|
|
|
|
public function showStatusMessage( Status $status ) {
|
|
|
|
|
$errors = array_merge( $status->getErrorsArray(), $status->getWarningsArray() );
|
|
|
|
|
foreach ( $errors as $error ) {
|
2018-06-08 02:58:35 +00:00
|
|
|
$this->showMessage( ...$error );
|
2014-07-21 08:31:09 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
|
|
|
|
* Label a control by wrapping a config-input div around it and putting a
|
2010-07-19 03:16:54 +00:00
|
|
|
* label before it.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2014-04-19 11:55:27 +00:00
|
|
|
* @param string $msg
|
2022-02-26 08:12:42 +00:00
|
|
|
* @param string|false $forId
|
2020-11-29 11:37:44 +00:00
|
|
|
* @param string $contents HTML
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $helpData
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-12-06 20:04:28 +00:00
|
|
|
public function label( $msg, $forId, $contents, $helpData = "" ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( strval( $msg ) == '' ) {
|
2018-07-09 02:27:52 +00:00
|
|
|
$labelText = "\u{00A0}";
|
2010-05-07 12:25:01 +00:00
|
|
|
} else {
|
2012-08-21 19:58:47 +00:00
|
|
|
$labelText = wfMessage( $msg )->escaped();
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$attributes = [ 'class' => 'config-label' ];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $forId ) {
|
|
|
|
|
$attributes['for'] = $forId;
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
return "<div class=\"config-block\">\n" .
|
2010-12-19 04:31:15 +00:00
|
|
|
" <div class=\"config-block-label\">\n" .
|
2010-05-07 12:25:01 +00:00
|
|
|
Xml::tags( 'label',
|
|
|
|
|
$attributes,
|
2013-10-08 11:43:42 +00:00
|
|
|
$labelText
|
|
|
|
|
) . "\n" .
|
|
|
|
|
$helpData .
|
2010-12-06 20:04:28 +00:00
|
|
|
" </div>\n" .
|
2010-12-19 04:31:15 +00:00
|
|
|
" <div class=\"config-block-elements\">\n" .
|
2013-10-08 11:43:42 +00:00
|
|
|
$contents .
|
2010-12-06 20:04:28 +00:00
|
|
|
" </div>\n" .
|
2010-05-07 12:25:01 +00:00
|
|
|
"</div>\n";
|
|
|
|
|
}
|
2010-11-22 23:55:37 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a labelled text box to configure a variable.
|
2010-05-08 20:04:48 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param mixed[] $params
|
2010-05-07 12:25:01 +00:00
|
|
|
* Parameters are:
|
2013-10-08 11:43:42 +00:00
|
|
|
* var: The variable to be configured (required)
|
|
|
|
|
* label: The message name for the label (required)
|
|
|
|
|
* attribs: Additional attributes for the input element (optional)
|
2010-05-07 12:25:01 +00:00
|
|
|
* controlName: The name for the input element (optional)
|
2013-10-08 11:43:42 +00:00
|
|
|
* value: The current value of the variable (optional)
|
|
|
|
|
* help: The html for the help text (optional)
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getTextBox( $params ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['controlName'] ) ) {
|
|
|
|
|
$params['controlName'] = 'config_' . $params['var'];
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['value'] ) ) {
|
|
|
|
|
$params['value'] = $this->getVar( $params['var'] );
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['attribs'] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$params['attribs'] = [];
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-12-06 20:04:28 +00:00
|
|
|
if ( !isset( $params['help'] ) ) {
|
|
|
|
|
$params['help'] = "";
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
return $this->label(
|
2013-10-08 11:43:42 +00:00
|
|
|
$params['label'],
|
|
|
|
|
$params['controlName'],
|
|
|
|
|
Xml::input(
|
2010-05-07 12:25:01 +00:00
|
|
|
$params['controlName'],
|
2013-10-08 11:43:42 +00:00
|
|
|
30, // intended to be overridden by CSS
|
|
|
|
|
$params['value'],
|
2016-02-17 09:09:32 +00:00
|
|
|
$params['attribs'] + [
|
2013-10-08 11:43:42 +00:00
|
|
|
'id' => $params['controlName'],
|
|
|
|
|
'class' => 'config-input-text',
|
|
|
|
|
'tabindex' => $this->nextTabIndex()
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2013-10-08 11:43:42 +00:00
|
|
|
),
|
|
|
|
|
$params['help']
|
|
|
|
|
);
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-11-22 23:55:37 +00:00
|
|
|
|
2011-02-23 17:54:45 +00:00
|
|
|
/**
|
|
|
|
|
* Get a labelled textarea to configure a variable
|
|
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param mixed[] $params
|
2011-02-23 17:54:45 +00:00
|
|
|
* Parameters are:
|
2013-10-08 11:43:42 +00:00
|
|
|
* var: The variable to be configured (required)
|
|
|
|
|
* label: The message name for the label (required)
|
|
|
|
|
* attribs: Additional attributes for the input element (optional)
|
2011-02-23 17:54:45 +00:00
|
|
|
* controlName: The name for the input element (optional)
|
2013-10-08 11:43:42 +00:00
|
|
|
* value: The current value of the variable (optional)
|
|
|
|
|
* help: The html for the help text (optional)
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
2011-02-23 17:54:45 +00:00
|
|
|
*/
|
|
|
|
|
public function getTextArea( $params ) {
|
|
|
|
|
if ( !isset( $params['controlName'] ) ) {
|
|
|
|
|
$params['controlName'] = 'config_' . $params['var'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !isset( $params['value'] ) ) {
|
|
|
|
|
$params['value'] = $this->getVar( $params['var'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !isset( $params['attribs'] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$params['attribs'] = [];
|
2011-02-23 17:54:45 +00:00
|
|
|
}
|
|
|
|
|
if ( !isset( $params['help'] ) ) {
|
|
|
|
|
$params['help'] = "";
|
|
|
|
|
}
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
return $this->label(
|
2013-10-08 11:43:42 +00:00
|
|
|
$params['label'],
|
|
|
|
|
$params['controlName'],
|
|
|
|
|
Xml::textarea(
|
2011-02-23 17:54:45 +00:00
|
|
|
$params['controlName'],
|
2013-10-08 11:43:42 +00:00
|
|
|
$params['value'],
|
|
|
|
|
30,
|
|
|
|
|
5,
|
2016-02-17 09:09:32 +00:00
|
|
|
$params['attribs'] + [
|
2013-10-08 11:43:42 +00:00
|
|
|
'id' => $params['controlName'],
|
|
|
|
|
'class' => 'config-input-text',
|
|
|
|
|
'tabindex' => $this->nextTabIndex()
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2013-10-08 11:43:42 +00:00
|
|
|
),
|
|
|
|
|
$params['help']
|
|
|
|
|
);
|
2011-02-23 17:54:45 +00:00
|
|
|
}
|
|
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a labelled password box to configure a variable.
|
2010-05-08 20:04:48 +00:00
|
|
|
*
|
2010-05-07 12:25:01 +00:00
|
|
|
* Implements password hiding
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param mixed[] $params
|
2010-05-07 12:25:01 +00:00
|
|
|
* Parameters are:
|
2013-10-08 11:43:42 +00:00
|
|
|
* var: The variable to be configured (required)
|
|
|
|
|
* label: The message name for the label (required)
|
|
|
|
|
* attribs: Additional attributes for the input element (optional)
|
2010-05-07 12:25:01 +00:00
|
|
|
* controlName: The name for the input element (optional)
|
2013-10-08 11:43:42 +00:00
|
|
|
* value: The current value of the variable (optional)
|
|
|
|
|
* help: The html for the help text (optional)
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getPasswordBox( $params ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['value'] ) ) {
|
|
|
|
|
$params['value'] = $this->getVar( $params['var'] );
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['attribs'] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$params['attribs'] = [];
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$params['value'] = $this->getFakePassword( $params['value'] );
|
|
|
|
|
$params['attribs']['type'] = 'password';
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $this->getTextBox( $params );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a labelled checkbox to configure a boolean variable.
|
2010-05-08 20:04:48 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param mixed[] $params
|
2010-05-07 12:25:01 +00:00
|
|
|
* Parameters are:
|
2013-10-08 11:43:42 +00:00
|
|
|
* var: The variable to be configured (required)
|
|
|
|
|
* label: The message name for the label (required)
|
2018-04-08 23:26:01 +00:00
|
|
|
* labelAttribs:Additional attributes for the label element (optional)
|
2013-10-08 11:43:42 +00:00
|
|
|
* attribs: Additional attributes for the input element (optional)
|
2010-05-07 12:25:01 +00:00
|
|
|
* controlName: The name for the input element (optional)
|
2013-10-08 11:43:42 +00:00
|
|
|
* value: The current value of the variable (optional)
|
|
|
|
|
* help: The html for the help text (optional)
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getCheckBox( $params ) {
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['controlName'] ) ) {
|
|
|
|
|
$params['controlName'] = 'config_' . $params['var'];
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['value'] ) ) {
|
|
|
|
|
$params['value'] = $this->getVar( $params['var'] );
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( !isset( $params['attribs'] ) ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$params['attribs'] = [];
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-12-06 20:04:28 +00:00
|
|
|
if ( !isset( $params['help'] ) ) {
|
|
|
|
|
$params['help'] = "";
|
|
|
|
|
}
|
2018-04-08 23:26:01 +00:00
|
|
|
if ( !isset( $params['labelAttribs'] ) ) {
|
|
|
|
|
$params['labelAttribs'] = [];
|
|
|
|
|
}
|
2018-10-26 16:59:01 +00:00
|
|
|
$labelText = $params['rawtext'] ?? $this->parse( wfMessage( $params['label'] )->plain() );
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2013-03-24 10:01:51 +00:00
|
|
|
return "<div class=\"config-input-check\">\n" .
|
2010-12-06 20:04:28 +00:00
|
|
|
$params['help'] .
|
2018-04-08 23:26:01 +00:00
|
|
|
Html::rawElement(
|
|
|
|
|
'label',
|
|
|
|
|
$params['labelAttribs'],
|
|
|
|
|
Xml::check(
|
|
|
|
|
$params['controlName'],
|
|
|
|
|
$params['value'],
|
|
|
|
|
$params['attribs'] + [
|
|
|
|
|
'id' => $params['controlName'],
|
|
|
|
|
'tabindex' => $this->nextTabIndex(),
|
|
|
|
|
]
|
|
|
|
|
) .
|
|
|
|
|
$labelText . "\n"
|
|
|
|
|
) .
|
2010-05-07 12:25:01 +00:00
|
|
|
"</div>\n";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Get a set of labelled radio buttons.
|
2010-05-07 12:25:01 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param mixed[] $params
|
2010-05-07 12:25:01 +00:00
|
|
|
* Parameters are:
|
2013-10-08 11:43:42 +00:00
|
|
|
* var: The variable to be configured (required)
|
|
|
|
|
* label: The message name for the label (required)
|
2010-05-07 12:25:01 +00:00
|
|
|
* itemLabelPrefix: The message name prefix for the item labels (required)
|
2015-09-28 11:40:27 +00:00
|
|
|
* itemLabels: List of message names to use for the item labels instead
|
|
|
|
|
* of itemLabelPrefix, keyed by values
|
2013-10-08 11:43:42 +00:00
|
|
|
* values: List of allowed values (required)
|
|
|
|
|
* itemAttribs: Array of attribute arrays, outer key is the value name (optional)
|
|
|
|
|
* commonAttribs: Attribute array applied to all items
|
|
|
|
|
* controlName: The name for the input element (optional)
|
|
|
|
|
* value: The current value of the variable (optional)
|
|
|
|
|
* help: The html for the help text (optional)
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string HTML
|
|
|
|
|
* @return-taint escaped
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function getRadioSet( $params ) {
|
2014-06-10 11:41:29 +00:00
|
|
|
$items = $this->getRadioElements( $params );
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2018-10-20 21:55:44 +00:00
|
|
|
$label = $params['label'] ?? '';
|
2014-06-10 11:41:29 +00:00
|
|
|
|
|
|
|
|
if ( !isset( $params['controlName'] ) ) {
|
|
|
|
|
$params['controlName'] = 'config_' . $params['var'];
|
|
|
|
|
}
|
|
|
|
|
|
2010-12-06 20:04:28 +00:00
|
|
|
if ( !isset( $params['help'] ) ) {
|
|
|
|
|
$params['help'] = "";
|
|
|
|
|
}
|
2014-06-10 11:41:29 +00:00
|
|
|
|
2010-12-06 20:04:28 +00:00
|
|
|
$s = "<ul>\n";
|
2022-09-21 19:05:03 +00:00
|
|
|
foreach ( $items as $item ) {
|
2014-06-10 11:41:29 +00:00
|
|
|
$s .= "<li>$item</li>\n";
|
|
|
|
|
}
|
|
|
|
|
$s .= "</ul>\n";
|
|
|
|
|
|
|
|
|
|
return $this->label( $label, $params['controlName'], $s, $params['help'] );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get a set of labelled radio buttons. You probably want to use getRadioSet(), not this.
|
|
|
|
|
*
|
|
|
|
|
* @see getRadioSet
|
|
|
|
|
*
|
2017-09-09 20:47:04 +00:00
|
|
|
* @param mixed[] $params
|
2020-11-29 11:37:44 +00:00
|
|
|
* @return string[] HTML
|
|
|
|
|
* @return-taint escaped
|
2014-06-10 11:41:29 +00:00
|
|
|
*/
|
|
|
|
|
public function getRadioElements( $params ) {
|
|
|
|
|
if ( !isset( $params['controlName'] ) ) {
|
|
|
|
|
$params['controlName'] = 'config_' . $params['var'];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if ( !isset( $params['value'] ) ) {
|
|
|
|
|
$params['value'] = $this->getVar( $params['var'] );
|
|
|
|
|
}
|
|
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
$items = [];
|
2014-06-10 11:41:29 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
foreach ( $params['values'] as $value ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$itemAttribs = [];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( isset( $params['commonAttribs'] ) ) {
|
|
|
|
|
$itemAttribs = $params['commonAttribs'];
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( isset( $params['itemAttribs'][$value] ) ) {
|
|
|
|
|
$itemAttribs = $params['itemAttribs'][$value] + $itemAttribs;
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
$checked = $value == $params['value'];
|
|
|
|
|
$id = $params['controlName'] . '_' . $value;
|
|
|
|
|
$itemAttribs['id'] = $id;
|
|
|
|
|
$itemAttribs['tabindex'] = $this->nextTabIndex();
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2014-06-10 11:41:29 +00:00
|
|
|
$items[$value] =
|
2010-05-07 12:25:01 +00:00
|
|
|
Xml::radio( $params['controlName'], $value, $checked, $itemAttribs ) .
|
2018-07-09 02:27:52 +00:00
|
|
|
"\u{00A0}" .
|
2016-02-17 09:09:32 +00:00
|
|
|
Xml::tags( 'label', [ 'for' => $id ], $this->parse(
|
2014-06-10 11:41:29 +00:00
|
|
|
isset( $params['itemLabels'] ) ?
|
|
|
|
|
wfMessage( $params['itemLabels'][$value] )->plain() :
|
|
|
|
|
wfMessage( $params['itemLabelPrefix'] . strtolower( $value ) )->plain()
|
|
|
|
|
) );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2014-06-10 11:41:29 +00:00
|
|
|
return $items;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2010-07-19 03:16:54 +00:00
|
|
|
* Output an error or warning box using a Status object.
|
2011-05-28 14:52:55 +00:00
|
|
|
*
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param Status $status
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function showStatusBox( $status ) {
|
2013-04-20 21:11:46 +00:00
|
|
|
if ( !$status->isGood() ) {
|
2021-08-29 10:53:15 +00:00
|
|
|
$html = $status->getHTML();
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2016-03-19 00:08:06 +00:00
|
|
|
if ( $status->isOK() ) {
|
2021-08-29 10:53:15 +00:00
|
|
|
$box = Html::warningBox( $html, 'config-warning-box' );
|
2010-07-06 14:41:15 +00:00
|
|
|
} else {
|
2021-08-29 10:53:15 +00:00
|
|
|
$box = Html::errorBox( $html, '', 'config-error-box' );
|
2010-07-06 14:41:15 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-07-06 14:41:15 +00:00
|
|
|
$this->output->addHTML( $box );
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Convenience function to set variables based on form data.
|
|
|
|
|
* Assumes that variables containing "password" in the name are (potentially
|
|
|
|
|
* fake) passwords.
|
2010-05-08 20:04:48 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param string[] $varNames
|
2013-10-08 16:20:08 +00:00
|
|
|
* @param string $prefix The prefix added to variables to obtain form names
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2014-04-08 10:22:43 +00:00
|
|
|
* @return string[]
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2010-07-19 03:16:54 +00:00
|
|
|
public function setVarsFromRequest( $varNames, $prefix = 'config_' ) {
|
2016-02-17 09:09:32 +00:00
|
|
|
$newValues = [];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
foreach ( $varNames as $name ) {
|
2014-07-12 22:12:21 +00:00
|
|
|
$value = $this->request->getVal( $prefix . $name );
|
2017-02-20 22:44:19 +00:00
|
|
|
// T32524, do not trim passwords
|
2022-10-04 23:31:41 +00:00
|
|
|
if ( $value !== null && stripos( $name, 'password' ) === false ) {
|
2014-07-12 22:12:21 +00:00
|
|
|
$value = trim( $value );
|
|
|
|
|
}
|
2010-05-07 12:25:01 +00:00
|
|
|
$newValues[$name] = $value;
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( $value === null ) {
|
|
|
|
|
// Checkbox?
|
|
|
|
|
$this->setVar( $name, false );
|
2019-03-29 20:12:24 +00:00
|
|
|
} elseif ( stripos( $name, 'password' ) !== false ) {
|
|
|
|
|
$this->setPassword( $name, $value );
|
2010-05-07 12:25:01 +00:00
|
|
|
} else {
|
2019-03-29 20:12:24 +00:00
|
|
|
$this->setVar( $name, $value );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
|
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
return $newValues;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2019-07-18 00:29:12 +00:00
|
|
|
* Helper for WebInstallerOutput
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2019-07-04 22:00:48 +00:00
|
|
|
* @internal For use by WebInstallerOutput
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param string $page
|
2011-05-02 16:58:29 +00:00
|
|
|
* @return string
|
2010-05-07 12:25:01 +00:00
|
|
|
*/
|
2019-07-04 22:00:48 +00:00
|
|
|
public function getDocUrl( $page ) {
|
2018-06-07 08:07:15 +00:00
|
|
|
$query = [ 'page' => $page ];
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2010-05-07 12:25:01 +00:00
|
|
|
if ( in_array( $this->currentPageName, $this->pageSequence ) ) {
|
2018-06-07 08:07:15 +00:00
|
|
|
$query['lastPage'] = $this->currentPageName;
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2018-06-07 08:07:15 +00:00
|
|
|
return $this->getUrl( $query );
|
2010-05-07 12:25:01 +00:00
|
|
|
}
|
2010-10-02 07:40:54 +00:00
|
|
|
|
2019-07-04 22:00:48 +00:00
|
|
|
/**
|
|
|
|
|
* Helper for sidebar links.
|
|
|
|
|
*
|
|
|
|
|
* @internal For use in WebInstallerOutput class
|
|
|
|
|
* @param string $url
|
|
|
|
|
* @param string $linkText
|
|
|
|
|
* @return string HTML
|
|
|
|
|
*/
|
|
|
|
|
public function makeLinkItem( $url, $linkText ) {
|
|
|
|
|
return Html::rawElement( 'li', [],
|
|
|
|
|
Html::element( 'a', [ 'href' => $url ], $linkText )
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2011-01-28 15:00:18 +00:00
|
|
|
/**
|
2019-07-04 21:23:11 +00:00
|
|
|
* Helper for "Download LocalSettings" link.
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
2019-07-04 21:23:11 +00:00
|
|
|
* @internal For use in WebInstallerComplete class
|
2013-10-08 16:20:08 +00:00
|
|
|
* @return string Html for download link
|
2011-01-28 15:00:18 +00:00
|
|
|
*/
|
2019-07-04 21:23:11 +00:00
|
|
|
public function makeDownloadLinkHtml() {
|
2010-12-16 11:20:39 +00:00
|
|
|
$anchor = Html::rawElement( 'a',
|
2016-03-19 00:08:06 +00:00
|
|
|
[ 'href' => $this->getUrl( [ 'localsettings' => 1 ] ) ],
|
2013-05-03 15:46:49 +00:00
|
|
|
wfMessage( 'config-download-localsettings' )->parse()
|
|
|
|
|
);
|
2013-10-08 11:43:42 +00:00
|
|
|
|
2016-02-17 09:09:32 +00:00
|
|
|
return Html::rawElement( 'div', [ 'class' => 'config-download-link' ], $anchor );
|
2010-12-07 03:15:51 +00:00
|
|
|
}
|
2011-08-03 15:46:06 +00:00
|
|
|
|
2016-06-20 17:22:51 +00:00
|
|
|
/**
|
|
|
|
|
* If the software package wants the LocalSettings.php file
|
|
|
|
|
* to be placed in a specific location, override this function
|
|
|
|
|
* (see mw-config/overrides/README) to return the path of
|
|
|
|
|
* where the file should be saved, or false for a generic
|
|
|
|
|
* "in the base of your install"
|
|
|
|
|
*
|
|
|
|
|
* @since 1.27
|
|
|
|
|
* @return string|bool
|
|
|
|
|
*/
|
|
|
|
|
public function getLocalSettingsLocation() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2011-11-22 16:31:33 +00:00
|
|
|
/**
|
|
|
|
|
* @return bool
|
|
|
|
|
*/
|
2013-03-17 15:13:22 +00:00
|
|
|
public function envCheckPath() {
|
2015-05-24 13:06:54 +00:00
|
|
|
// PHP_SELF isn't available sometimes, such as when PHP is CGI but
|
|
|
|
|
// cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
|
|
|
|
|
// to get the path to the current script... hopefully it's reliable. SIGH
|
|
|
|
|
$path = false;
|
|
|
|
|
if ( !empty( $_SERVER['PHP_SELF'] ) ) {
|
|
|
|
|
$path = $_SERVER['PHP_SELF'];
|
|
|
|
|
} elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
|
|
|
|
|
$path = $_SERVER['SCRIPT_NAME'];
|
|
|
|
|
}
|
|
|
|
|
if ( $path === false ) {
|
|
|
|
|
$this->showError( 'config-no-uri' );
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return parent::envCheckPath();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function envPrepPath() {
|
|
|
|
|
parent::envPrepPath();
|
2011-08-03 15:46:06 +00:00
|
|
|
// PHP_SELF isn't available sometimes, such as when PHP is CGI but
|
|
|
|
|
// cgi.fix_pathinfo is disabled. In that case, fall back to SCRIPT_NAME
|
|
|
|
|
// to get the path to the current script... hopefully it's reliable. SIGH
|
|
|
|
|
$path = false;
|
|
|
|
|
if ( !empty( $_SERVER['PHP_SELF'] ) ) {
|
|
|
|
|
$path = $_SERVER['PHP_SELF'];
|
|
|
|
|
} elseif ( !empty( $_SERVER['SCRIPT_NAME'] ) ) {
|
|
|
|
|
$path = $_SERVER['SCRIPT_NAME'];
|
|
|
|
|
}
|
2013-02-03 19:28:43 +00:00
|
|
|
if ( $path !== false ) {
|
2014-07-10 16:27:11 +00:00
|
|
|
$scriptPath = preg_replace( '{^(.*)/(mw-)?config.*$}', '$1', $path );
|
2014-07-10 16:32:52 +00:00
|
|
|
|
2014-07-10 16:27:11 +00:00
|
|
|
$this->setVar( 'wgScriptPath', "$scriptPath" );
|
2014-07-10 16:32:52 +00:00
|
|
|
// Update variables set from Setup.php that are derived from wgScriptPath
|
2015-06-02 15:38:57 +00:00
|
|
|
$this->setVar( 'wgScript', "$scriptPath/index.php" );
|
|
|
|
|
$this->setVar( 'wgLoadScript', "$scriptPath/load.php" );
|
2014-07-10 16:32:52 +00:00
|
|
|
$this->setVar( 'wgStylePath', "$scriptPath/skins" );
|
|
|
|
|
$this->setVar( 'wgLocalStylePath', "$scriptPath/skins" );
|
|
|
|
|
$this->setVar( 'wgExtensionAssetsPath', "$scriptPath/extensions" );
|
|
|
|
|
$this->setVar( 'wgUploadPath', "$scriptPath/images" );
|
2015-05-24 13:06:54 +00:00
|
|
|
$this->setVar( 'wgResourceBasePath', "$scriptPath" );
|
2011-08-03 15:46:06 +00:00
|
|
|
}
|
|
|
|
|
}
|
2011-12-12 15:11:08 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
2014-04-19 11:55:27 +00:00
|
|
|
* @return string
|
2014-04-08 10:22:43 +00:00
|
|
|
*/
|
2011-12-12 15:11:08 +00:00
|
|
|
protected function envGetDefaultServer() {
|
2021-12-12 21:20:17 +00:00
|
|
|
$assumeProxiesUseDefaultProtocolPorts =
|
|
|
|
|
$this->getVar( 'wgAssumeProxiesUseDefaultProtocolPorts' );
|
|
|
|
|
|
|
|
|
|
return WebRequest::detectServer( $assumeProxiesUseDefaultProtocolPorts );
|
2011-12-12 15:11:08 +00:00
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2018-07-12 02:48:34 +00:00
|
|
|
/**
|
|
|
|
|
* Actually output LocalSettings.php for download
|
|
|
|
|
*/
|
|
|
|
|
private function outputLS() {
|
|
|
|
|
$this->request->response()->header( 'Content-type: application/x-httpd-php' );
|
|
|
|
|
$this->request->response()->header(
|
|
|
|
|
'Content-Disposition: attachment; filename="LocalSettings.php"'
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
$ls = InstallerOverrides::getLocalSettingsGenerator( $this );
|
|
|
|
|
$rightsProfile = $this->rightsProfiles[$this->getVar( '_RightsProfile' )];
|
|
|
|
|
foreach ( $rightsProfile as $group => $rightsArr ) {
|
|
|
|
|
$ls->setGroupRights( $group, $rightsArr );
|
|
|
|
|
}
|
|
|
|
|
echo $ls->getText();
|
|
|
|
|
}
|
|
|
|
|
|
2014-05-04 10:43:28 +00:00
|
|
|
/**
|
2014-06-04 19:25:55 +00:00
|
|
|
* Output stylesheet for web installer pages
|
2014-05-04 10:43:28 +00:00
|
|
|
*/
|
2014-06-04 19:25:55 +00:00
|
|
|
public function outputCss() {
|
2014-05-04 10:43:28 +00:00
|
|
|
$this->request->response()->header( 'Content-type: text/css' );
|
2014-06-04 19:25:55 +00:00
|
|
|
echo $this->output->getCSS();
|
2014-05-04 10:43:28 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @return string[]
|
|
|
|
|
*/
|
|
|
|
|
public function getPhpErrors() {
|
|
|
|
|
return $this->phpErrors;
|
|
|
|
|
}
|
|
|
|
|
|
2020-11-19 08:00:41 +00:00
|
|
|
/**
|
|
|
|
|
* Get HTML for an information message box with an icon.
|
|
|
|
|
*
|
|
|
|
|
* @since 1.36
|
|
|
|
|
* @param string $rawHtml HTML
|
|
|
|
|
* @param string $icon Path to icon file (used as 'src' attribute)
|
|
|
|
|
* @param string $alt Alternate text for the icon
|
|
|
|
|
* @param string $class Additional class name to add to the wrapper div
|
|
|
|
|
* @return string HTML
|
|
|
|
|
*/
|
|
|
|
|
protected static function infoBox( $rawHtml, $icon, $alt, $class = '' ) {
|
2021-04-14 22:01:55 +00:00
|
|
|
$s = Html::openElement( 'div', [ 'class' => 'mw-installer-box-left' ] ) .
|
2022-10-04 23:39:39 +00:00
|
|
|
Html::element( 'img',
|
|
|
|
|
[
|
|
|
|
|
'src' => $icon,
|
|
|
|
|
'alt' => $alt,
|
|
|
|
|
]
|
|
|
|
|
) .
|
|
|
|
|
Html::closeElement( 'div' ) .
|
|
|
|
|
Html::openElement( 'div', [ 'class' => 'mw-installer-box-right' ] ) .
|
|
|
|
|
$rawHtml .
|
|
|
|
|
Html::closeElement( 'div' ) .
|
|
|
|
|
Html::element( 'div', [ 'style' => 'clear: left;' ], ' ' );
|
2020-11-19 08:00:41 +00:00
|
|
|
|
2021-04-14 22:01:55 +00:00
|
|
|
return Html::warningBox( $s, $class )
|
|
|
|
|
. Html::element( 'div', [ 'style' => 'clear: left;' ], ' ' );
|
2020-11-19 08:00:41 +00:00
|
|
|
}
|
|
|
|
|
|
2010-12-06 13:20:01 +00:00
|
|
|
}
|