Localisation updates from https://translatewiki.net.
[mediawiki.git] / includes / installer / WebInstallerPage.php
blobf37190466b83eb1e68591bf39b24d45ded4aeb8f
1 <?php
3 /**
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
19 * @file
20 * @ingroup Installer
23 namespace MediaWiki\Installer;
25 use MediaWiki\Html\Html;
26 use MediaWiki\Xml\Xml;
28 /**
29 * Abstract class to define pages for the web installer.
31 * @ingroup Installer
32 * @since 1.17
34 abstract class WebInstallerPage {
36 /**
37 * The WebInstaller object this WebInstallerPage belongs to.
39 * @var WebInstaller
41 public $parent;
43 /**
44 * @return string
46 abstract public function execute();
48 /**
49 * @param WebInstaller $parent
51 public function __construct( WebInstaller $parent ) {
52 $this->parent = $parent;
55 /**
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() {
63 return false;
66 /**
67 * @param string $html
69 public function addHTML( $html ) {
70 $this->parent->output->addHTML( $html );
73 public function startForm() {
74 $this->addHTML(
75 "<div class=\"config-section\">\n" .
76 Html::openElement(
77 'form',
79 'method' => 'post',
80 'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
82 ) . "\n"
86 /**
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";
92 $id = $this->getId();
94 if ( $id === false ) {
95 $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
98 if ( $continue ) {
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'
107 ) . "\n";
110 if ( $back ) {
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'
119 ) . "\n";
122 if ( $continue ) {
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'
131 ) . "\n";
134 $s .= "</div></form></div>\n";
135 $this->addHTML( $s );
139 * @return string
141 public function getName() {
142 return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class );
146 * @return string
148 protected function getId() {
149 return array_search( $this->getName(), $this->parent->pageSequence );
153 * @param string $var
154 * @param mixed|null $default
156 * @return mixed
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
175 * @return string
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.
185 * @return string
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() {
195 $this->addHTML(
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();