2010-07-19 04:05:44 +00:00
|
|
|
<?php
|
2024-01-05 18:27:39 +00:00
|
|
|
|
2010-08-21 18:20:09 +00:00
|
|
|
/**
|
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-07-19 04:05:44 +00:00
|
|
|
|
2024-01-05 18:27:39 +00:00
|
|
|
namespace MediaWiki\Installer;
|
|
|
|
|
|
2023-02-16 19:27:21 +00:00
|
|
|
use MediaWiki\Html\Html;
|
2024-05-16 10:52:03 +00:00
|
|
|
use MediaWiki\Xml\Xml;
|
2023-02-16 19:27:21 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
/**
|
|
|
|
|
* Abstract class to define pages for the web installer.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2019-11-25 23:24:49 +00:00
|
|
|
* @ingroup Installer
|
2010-07-29 18:36:39 +00:00
|
|
|
* @since 1.17
|
2010-07-19 04:05:44 +00:00
|
|
|
*/
|
|
|
|
|
abstract class WebInstallerPage {
|
2010-11-05 13:14:24 +00:00
|
|
|
|
2010-07-20 13:53:03 +00:00
|
|
|
/**
|
|
|
|
|
* The WebInstaller object this WebInstallerPage belongs to.
|
2010-12-06 20:04:28 +00:00
|
|
|
*
|
2010-07-20 13:53:03 +00:00
|
|
|
* @var WebInstaller
|
|
|
|
|
*/
|
|
|
|
|
public $parent;
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2013-01-26 19:00:09 +00:00
|
|
|
abstract public function execute();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-21 09:42:07 +00:00
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* @param WebInstaller $parent
|
2010-08-21 15:20:23 +00:00
|
|
|
*/
|
2010-07-20 13:53:03 +00:00
|
|
|
public function __construct( WebInstaller $parent ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$this->parent = $parent;
|
|
|
|
|
}
|
|
|
|
|
|
2011-06-21 01:13:45 +00:00
|
|
|
/**
|
|
|
|
|
* Is this a slow-running page in the installer? If so, WebInstaller will
|
|
|
|
|
* set_time_limit(0) before calling execute(). Right now this only applies
|
|
|
|
|
* to Install and Upgrade pages
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @return bool Always false in this default implementation.
|
2011-06-21 01:13:45 +00:00
|
|
|
*/
|
|
|
|
|
public function isSlow() {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $html
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function addHTML( $html ) {
|
|
|
|
|
$this->parent->output->addHTML( $html );
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function startForm() {
|
|
|
|
|
$this->addHTML(
|
|
|
|
|
"<div class=\"config-section\">\n" .
|
2010-11-04 23:21:24 +00:00
|
|
|
Html::openElement(
|
2010-07-19 04:05:44 +00:00
|
|
|
'form',
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2010-07-19 04:05:44 +00:00
|
|
|
'method' => 'post',
|
2016-02-17 09:09:32 +00:00
|
|
|
'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
|
|
|
|
|
]
|
2010-07-19 04:05:44 +00:00
|
|
|
) . "\n"
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
2013-08-28 00:38:27 +00:00
|
|
|
/**
|
|
|
|
|
* @param string|bool $continue
|
|
|
|
|
* @param string|bool $back
|
|
|
|
|
*/
|
2010-12-10 03:02:03 +00:00
|
|
|
public function endForm( $continue = 'continue', $back = 'back' ) {
|
2010-07-19 04:05:44 +00:00
|
|
|
$s = "<div class=\"config-submit\">\n";
|
|
|
|
|
$id = $this->getId();
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $id === false ) {
|
2010-10-31 16:20:48 +00:00
|
|
|
$s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $continue ) {
|
2017-02-20 22:44:19 +00:00
|
|
|
// Fake submit button for enter keypress (T28267)
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-continue, config-restart, config-regenerate
|
2013-10-08 11:43:42 +00:00
|
|
|
$s .= Xml::submitButton(
|
|
|
|
|
wfMessage( "config-$continue" )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2013-10-08 11:43:42 +00:00
|
|
|
'name' => "enter-$continue",
|
2016-05-07 17:37:07 +00:00
|
|
|
'style' => 'width:0;border:0;height:0;padding:0'
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2013-10-08 11:43:42 +00:00
|
|
|
) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-12-10 03:02:03 +00:00
|
|
|
if ( $back ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Message: config-back
|
2013-10-08 11:43:42 +00:00
|
|
|
$s .= Xml::submitButton(
|
|
|
|
|
wfMessage( "config-$back" )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2010-12-10 03:02:03 +00:00
|
|
|
'name' => "submit-$back",
|
2023-12-11 19:21:51 +00:00
|
|
|
'tabindex' => $this->parent->nextTabIndex(),
|
|
|
|
|
'class' => 'cdx-button cdx-button--action-destructive'
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2013-10-08 11:43:42 +00:00
|
|
|
) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
if ( $continue ) {
|
2013-08-28 00:38:27 +00:00
|
|
|
// Messages: config-continue, config-restart, config-regenerate
|
2013-10-08 11:43:42 +00:00
|
|
|
$s .= Xml::submitButton(
|
|
|
|
|
wfMessage( "config-$continue" )->text(),
|
2016-02-17 09:09:32 +00:00
|
|
|
[
|
2010-07-19 04:05:44 +00:00
|
|
|
'name' => "submit-$continue",
|
|
|
|
|
'tabindex' => $this->parent->nextTabIndex(),
|
2023-12-11 19:21:51 +00:00
|
|
|
'class' => 'cdx-button cdx-button--action-progressive'
|
2016-02-17 09:09:32 +00:00
|
|
|
]
|
2013-10-08 11:43:42 +00:00
|
|
|
) . "\n";
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
2010-12-16 11:20:39 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
$s .= "</div></form></div>\n";
|
|
|
|
|
$this->addHTML( $s );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function getName() {
|
2024-01-12 04:46:43 +00:00
|
|
|
return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @return string
|
|
|
|
|
*/
|
2010-11-10 12:58:22 +00:00
|
|
|
protected function getId() {
|
2010-07-19 04:05:44 +00:00
|
|
|
return array_search( $this->getName(), $this->parent->pageSequence );
|
|
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $var
|
2018-06-26 21:14:43 +00:00
|
|
|
* @param mixed|null $default
|
2014-04-08 10:22:43 +00:00
|
|
|
*
|
|
|
|
|
* @return mixed
|
|
|
|
|
*/
|
2014-06-10 11:41:29 +00:00
|
|
|
public function getVar( $var, $default = null ) {
|
|
|
|
|
return $this->parent->getVar( $var, $default );
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|
|
|
|
|
|
2014-04-08 10:22:43 +00:00
|
|
|
/**
|
|
|
|
|
* @param string $name
|
|
|
|
|
* @param mixed $value
|
|
|
|
|
*/
|
2010-07-19 04:05:44 +00:00
|
|
|
public function setVar( $name, $value ) {
|
|
|
|
|
$this->parent->setVar( $name, $value );
|
|
|
|
|
}
|
2010-10-26 12:05:57 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the starting tags of a fieldset.
|
|
|
|
|
*
|
2014-07-24 17:43:03 +00:00
|
|
|
* @param string $legend Message name
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
|
|
|
|
* @return string
|
2010-10-26 12:05:57 +00:00
|
|
|
*/
|
|
|
|
|
protected function getFieldsetStart( $legend ) {
|
2023-12-11 19:21:51 +00:00
|
|
|
return "\n<span class=\"cdx-card\"><span class=\"cdx-card__text\"><span class=\"cdx-card__text__title\">" .
|
|
|
|
|
wfMessage( $legend )->escaped() . "</span><span class=\"cdx-card__text__description\">\n";
|
2010-10-26 12:05:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Get the end tag of a fieldset.
|
2011-05-02 16:58:29 +00:00
|
|
|
*
|
2011-10-13 18:44:26 +00:00
|
|
|
* @return string
|
2010-10-26 12:05:57 +00:00
|
|
|
*/
|
|
|
|
|
protected function getFieldsetEnd() {
|
2023-12-11 19:21:51 +00:00
|
|
|
return "</span></span></span>\n";
|
2010-10-26 12:05:57 +00:00
|
|
|
}
|
2011-03-30 17:32:20 +00:00
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* Opens a textarea used to display the progress of a long operation
|
|
|
|
|
*/
|
|
|
|
|
protected function startLiveBox() {
|
|
|
|
|
$this->addHTML(
|
2011-11-06 21:31:52 +00:00
|
|
|
'<div id="config-spinner" style="display:none;">' .
|
2014-08-11 01:59:22 +00:00
|
|
|
'<img src="images/ajax-loader.gif" /></div>' .
|
2011-03-30 17:32:20 +00:00
|
|
|
'<script>jQuery( "#config-spinner" ).show();</script>' .
|
2011-11-06 21:31:52 +00:00
|
|
|
'<div id="config-live-log">' .
|
|
|
|
|
'<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
|
2011-03-30 17:32:20 +00:00
|
|
|
);
|
|
|
|
|
$this->parent->output->flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
2014-04-08 10:22:43 +00:00
|
|
|
* Opposite to WebInstallerPage::startLiveBox
|
2011-03-30 17:32:20 +00:00
|
|
|
*/
|
|
|
|
|
protected function endLiveBox() {
|
2011-06-10 20:16:42 +00:00
|
|
|
$this->addHTML( '</textarea></div>
|
2011-03-30 17:32:20 +00:00
|
|
|
<script>jQuery( "#config-spinner" ).hide()</script>' );
|
|
|
|
|
$this->parent->output->flush();
|
|
|
|
|
}
|
2014-04-08 10:22:43 +00:00
|
|
|
|
2010-07-19 04:05:44 +00:00
|
|
|
}
|