4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License along
15 * with this program; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 * http://www.gnu.org/copyleft/gpl.html
23 namespace MediaWiki\Installer
;
25 use MediaWiki\Html\Html
;
26 use MediaWiki\Xml\Xml
;
29 * Abstract class to define pages for the web installer.
34 abstract class WebInstallerPage
{
37 * The WebInstaller object this WebInstallerPage belongs to.
46 abstract public function execute();
49 * @param WebInstaller $parent
51 public function __construct( WebInstaller
$parent ) {
52 $this->parent
= $parent;
56 * Is this a slow-running page in the installer? If so, WebInstaller will
57 * set_time_limit(0) before calling execute(). Right now this only applies
58 * to Install and Upgrade pages
60 * @return bool Always false in this default implementation.
62 public function isSlow() {
69 public function addHTML( $html ) {
70 $this->parent
->output
->addHTML( $html );
73 public function startForm() {
75 "<div class=\"config-section\">\n" .
80 'action' => $this->parent
->getUrl( [ 'page' => $this->getName() ] )
87 * @param string|bool $continue
88 * @param string|bool $back
90 public function endForm( $continue = 'continue', $back = 'back' ) {
91 $s = "<div class=\"config-submit\">\n";
94 if ( $id === false ) {
95 $s .= Html
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
99 // Fake submit button for enter keypress (T28267)
100 // Messages: config-continue, config-restart, config-regenerate
101 $s .= Xml
::submitButton(
102 wfMessage( "config-$continue" )->text(),
104 'name' => "enter-$continue",
105 'style' => 'width:0;border:0;height:0;padding:0'
111 // Message: config-back
112 $s .= Xml
::submitButton(
113 wfMessage( "config-$back" )->text(),
115 'name' => "submit-$back",
116 'tabindex' => $this->parent
->nextTabIndex(),
117 'class' => 'cdx-button cdx-button--action-destructive'
123 // Messages: config-continue, config-restart, config-regenerate
124 $s .= Xml
::submitButton(
125 wfMessage( "config-$continue" )->text(),
127 'name' => "submit-$continue",
128 'tabindex' => $this->parent
->nextTabIndex(),
129 'class' => 'cdx-button cdx-button--action-progressive'
134 $s .= "</div></form></div>\n";
135 $this->addHTML( $s );
141 public function getName() {
142 return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class );
148 protected function getId() {
149 return array_search( $this->getName(), $this->parent
->pageSequence
);
154 * @param mixed|null $default
158 public function getVar( $var, $default = null ) {
159 return $this->parent
->getVar( $var, $default );
163 * @param string $name
164 * @param mixed $value
166 public function setVar( $name, $value ) {
167 $this->parent
->setVar( $name, $value );
171 * Get the starting tags of a fieldset.
173 * @param string $legend Message name
177 protected function getFieldsetStart( $legend ) {
178 return "\n<span class=\"cdx-card\"><span class=\"cdx-card__text\"><span class=\"cdx-card__text__title\">" .
179 wfMessage( $legend )->escaped() . "</span><span class=\"cdx-card__text__description\">\n";
183 * Get the end tag of a fieldset.
187 protected function getFieldsetEnd() {
188 return "</span></span></span>\n";
192 * Opens a textarea used to display the progress of a long operation
194 protected function startLiveBox() {
196 '<div id="config-spinner" style="display:none;">' .
197 '<img src="images/ajax-loader.gif" /></div>' .
198 '<script>jQuery( "#config-spinner" ).show();</script>' .
199 '<div id="config-live-log">' .
200 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
202 $this->parent
->output
->flush();
206 * Opposite to WebInstallerPage::startLiveBox
208 protected function endLiveBox() {
209 $this->addHTML( '</textarea></div>
210 <script>jQuery( "#config-spinner" ).hide()</script>' );
211 $this->parent
->output
->flush();