MediaWiki master
WebInstallerPage.php
Go to the documentation of this file.
1<?php
2
9namespace MediaWiki\Installer;
10
12
19abstract class WebInstallerPage {
20
26 public $parent;
27
31 abstract public function execute();
32
33 public function __construct( WebInstaller $parent ) {
34 $this->parent = $parent;
35 }
36
44 public function isSlow() {
45 return false;
46 }
47
51 public function addHTML( $html ) {
52 $this->parent->output->addHTML( $html );
53 }
54
55 public function startForm() {
56 $this->addHTML(
57 "<div class=\"config-section\">\n" .
58 Html::openElement(
59 'form',
60 [
61 'method' => 'post',
62 'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
63 ]
64 ) . "\n"
65 );
66 }
67
72 public function endForm( $continue = 'continue', $back = 'back' ) {
73 $s = "<div class=\"config-submit\">\n";
74 $id = $this->getId();
75
76 if ( $id === false ) {
77 $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
78 }
79
80 if ( $continue ) {
81 // Fake submit button for enter keypress (T28267)
82 // Messages: config-continue, config-restart, config-regenerate
83 $s .= Html::submitButton(
84 wfMessage( "config-$continue" )->text(),
85 [
86 'name' => "enter-$continue",
87 'style' => 'width:0;border:0;height:0;padding:0'
88 ]
89 ) . "\n";
90 }
91
92 if ( $back ) {
93 // Message: config-back
94 $s .= Html::submitButton(
95 wfMessage( "config-$back" )->text(),
96 [
97 'name' => "submit-$back",
98 'tabindex' => $this->parent->nextTabIndex(),
99 'class' => [ 'cdx-button', 'cdx-button--action-default' ]
100 ]
101 ) . "\n";
102 }
103
104 if ( $continue ) {
105 // Messages: config-continue, config-restart, config-regenerate
106 $s .= Html::submitButton(
107 wfMessage( "config-$continue" )->text(),
108 [
109 'name' => "submit-$continue",
110 'tabindex' => $this->parent->nextTabIndex(),
111 'class' => [ 'cdx-button', 'cdx-button--action-progressive' ]
112 ]
113 ) . "\n";
114 }
115
116 $s .= "</div></form></div>\n";
117 $this->addHTML( $s );
118 }
119
123 public function getName() {
124 return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class );
125 }
126
130 protected function getId() {
131 return array_search( $this->getName(), $this->parent->pageSequence );
132 }
133
140 public function getVar( $var, $default = null ) {
141 return $this->parent->getVar( $var, $default );
142 }
143
148 public function setVar( $name, $value ) {
149 $this->parent->setVar( $name, $value );
150 }
151
159 protected function getFieldsetStart( $legend ) {
160 return "\n<div class=\"cdx-card\"><div class=\"cdx-card__text\"><div class=\"cdx-card__text__title\">" .
161 wfMessage( $legend )->escaped() . "</div><div class=\"cdx-card__text__description\">\n";
162 }
163
169 protected function getFieldsetEnd() {
170 return "</div></div></div>\n";
171 }
172
176 protected function startLiveBox() {
177 $this->addHTML(
178 '<div id="config-spinner" style="display:none;">' .
179 '<img src="images/ajax-loader.gif" /></div>' .
180 $this->inlineScript( 'jQuery( "#config-spinner" ).show();' ) .
181 '<div id="config-live-log">' .
182 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
183 );
184 $this->parent->output->flush();
185 }
186
190 protected function endLiveBox() {
191 $this->addHTML(
192 '</textarea></div>' .
193 $this->inlineScript( 'jQuery( "#config-spinner" ).hide()' )
194 );
195 $this->parent->output->flush();
196 }
197
205 protected function inlineScript( $script ) {
206 return Html::inlineScript( $script, $this->parent->output->getCSPNonce() );
207 }
208}
wfMessage( $key,... $params)
This is the function for getting translated interface messages.
This class is a collection of static functions that serve two purposes:
Definition Html.php:43
Abstract class to define pages for the web installer.
getFieldsetStart( $legend)
Get the starting tags of a fieldset.
inlineScript( $script)
Javascript to include inline.
endForm( $continue='continue', $back='back')
startLiveBox()
Opens a textarea used to display the progress of a long operation.
isSlow()
Is this a slow-running page in the installer? If so, WebInstaller will set_time_limit(0) before calli...
getFieldsetEnd()
Get the end tag of a fieldset.
WebInstaller $parent
The WebInstaller object this WebInstallerPage belongs to.
endLiveBox()
Opposite to WebInstallerPage::startLiveBox.
Class for the core installer web interface.