MediaWiki master
WebInstallerPage.php
Go to the documentation of this file.
1<?php
2
23namespace MediaWiki\Installer;
24
26
33abstract class WebInstallerPage {
34
40 public $parent;
41
45 abstract public function execute();
46
47 public function __construct( WebInstaller $parent ) {
48 $this->parent = $parent;
49 }
50
58 public function isSlow() {
59 return false;
60 }
61
65 public function addHTML( $html ) {
66 $this->parent->output->addHTML( $html );
67 }
68
69 public function startForm() {
70 $this->addHTML(
71 "<div class=\"config-section\">\n" .
72 Html::openElement(
73 'form',
74 [
75 'method' => 'post',
76 'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
77 ]
78 ) . "\n"
79 );
80 }
81
86 public function endForm( $continue = 'continue', $back = 'back' ) {
87 $s = "<div class=\"config-submit\">\n";
88 $id = $this->getId();
89
90 if ( $id === false ) {
91 $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
92 }
93
94 if ( $continue ) {
95 // Fake submit button for enter keypress (T28267)
96 // Messages: config-continue, config-restart, config-regenerate
97 $s .= Html::submitButton(
98 wfMessage( "config-$continue" )->text(),
99 [
100 'name' => "enter-$continue",
101 'style' => 'width:0;border:0;height:0;padding:0'
102 ]
103 ) . "\n";
104 }
105
106 if ( $back ) {
107 // Message: config-back
108 $s .= Html::submitButton(
109 wfMessage( "config-$back" )->text(),
110 [
111 'name' => "submit-$back",
112 'tabindex' => $this->parent->nextTabIndex(),
113 'class' => [ 'cdx-button', 'cdx-button--action-default' ]
114 ]
115 ) . "\n";
116 }
117
118 if ( $continue ) {
119 // Messages: config-continue, config-restart, config-regenerate
120 $s .= Html::submitButton(
121 wfMessage( "config-$continue" )->text(),
122 [
123 'name' => "submit-$continue",
124 'tabindex' => $this->parent->nextTabIndex(),
125 'class' => [ 'cdx-button', 'cdx-button--action-progressive' ]
126 ]
127 ) . "\n";
128 }
129
130 $s .= "</div></form></div>\n";
131 $this->addHTML( $s );
132 }
133
137 public function getName() {
138 return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class );
139 }
140
144 protected function getId() {
145 return array_search( $this->getName(), $this->parent->pageSequence );
146 }
147
154 public function getVar( $var, $default = null ) {
155 return $this->parent->getVar( $var, $default );
156 }
157
162 public function setVar( $name, $value ) {
163 $this->parent->setVar( $name, $value );
164 }
165
173 protected function getFieldsetStart( $legend ) {
174 return "\n<div class=\"cdx-card\"><div class=\"cdx-card__text\"><div class=\"cdx-card__text__title\">" .
175 wfMessage( $legend )->escaped() . "</div><div class=\"cdx-card__text__description\">\n";
176 }
177
183 protected function getFieldsetEnd() {
184 return "</div></div></div>\n";
185 }
186
190 protected function startLiveBox() {
191 $this->addHTML(
192 '<div id="config-spinner" style="display:none;">' .
193 '<img src="images/ajax-loader.gif" /></div>' .
194 '<script>jQuery( "#config-spinner" ).show();</script>' .
195 '<div id="config-live-log">' .
196 '<textarea name="LiveLog" rows="10" cols="30" readonly="readonly">'
197 );
198 $this->parent->output->flush();
199 }
200
204 protected function endLiveBox() {
205 $this->addHTML( '</textarea></div>
206<script>jQuery( "#config-spinner" ).hide()</script>' );
207 $this->parent->output->flush();
208 }
209
210}
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:57
Abstract class to define pages for the web installer.
getFieldsetStart( $legend)
Get the starting tags of a fieldset.
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.