3 * Base code for web installer pages.
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 * http://www.gnu.org/copyleft/gpl.html
24 use MediaWiki\Html\Html
;
27 * Abstract class to define pages for the web installer.
32 abstract class WebInstallerPage
{
35 * The WebInstaller object this WebInstallerPage belongs to.
44 abstract public function execute();
47 * @param WebInstaller $parent
49 public function __construct( WebInstaller
$parent ) {
50 $this->parent
= $parent;
54 * Is this a slow-running page in the installer? If so, WebInstaller will
55 * set_time_limit(0) before calling execute(). Right now this only applies
56 * to Install and Upgrade pages
58 * @return bool Always false in this default implementation.
60 public function isSlow() {
67 public function addHTML( $html ) {
68 $this->parent
->output
->addHTML( $html );
71 public function startForm() {
73 "<div class=\"config-section\">\n" .
78 'action' => $this->parent
->getUrl( [ 'page' => $this->getName() ] )
85 * @param string|bool $continue
86 * @param string|bool $back
88 public function endForm( $continue = 'continue', $back = 'back' ) {
89 $s = "<div class=\"config-submit\">\n";
92 if ( $id === false ) {
93 $s .= Html
::hidden( 'lastPage', $this->parent
->request
->getVal( 'lastPage' ) );
97 // Fake submit button for enter keypress (T28267)
98 // Messages: config-continue, config-restart, config-regenerate
99 $s .= Xml
::submitButton(
100 wfMessage( "config-$continue" )->text(),
102 'name' => "enter-$continue",
103 'style' => 'width:0;border:0;height:0;padding:0'
109 // Message: config-back
110 $s .= Xml
::submitButton(
111 wfMessage( "config-$back" )->text(),
113 'name' => "submit-$back",
114 'tabindex' => $this->parent
->nextTabIndex()
120 // Messages: config-continue, config-restart, config-regenerate
121 $s .= Xml
::submitButton(
122 wfMessage( "config-$continue" )->text(),
124 'name' => "submit-$continue",
125 'tabindex' => $this->parent
->nextTabIndex(),
130 $s .= "</div></form></div>\n";
131 $this->addHTML( $s );
137 public function getName() {
138 return str_replace( 'WebInstaller', '', static::class );
144 protected function getId() {
145 return array_search( $this->getName(), $this->parent
->pageSequence
);
150 * @param mixed|null $default
154 public function getVar( $var, $default = null ) {
155 return $this->parent
->getVar( $var, $default );
159 * @param string $name
160 * @param mixed $value
162 public function setVar( $name, $value ) {
163 $this->parent
->setVar( $name, $value );
167 * Get the starting tags of a fieldset.
169 * @param string $legend Message name
173 protected function getFieldsetStart( $legend ) {
174 return "\n<fieldset><legend>" . wfMessage( $legend )->escaped() . "</legend>\n";
178 * Get the end tag of a fieldset.
182 protected function getFieldsetEnd() {
183 return "</fieldset>\n";
187 * Opens a textarea used to display the progress of a long operation
189 protected function startLiveBox() {
191 '<div id="config-spinner" style="display:none;">' .
192 '<img src="images/ajax-loader.gif" /></div>' .
193 '<script>jQuery( "#config-spinner" ).show();</script>' .
194 '<div id="config-live-log">' .
195 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
197 $this->parent
->output
->flush();
201 * Opposite to WebInstallerPage::startLiveBox
203 protected function endLiveBox() {
204 $this->addHTML( '</textarea></div>
205 <script>jQuery( "#config-spinner" ).hide()</script>' );
206 $this->parent
->output
->flush();