MediaWiki master
WebInstallerPage.php
Go to the documentation of this file.
1<?php
2
23namespace MediaWiki\Installer;
24
26use Xml;
27
34abstract class WebInstallerPage {
35
41 public $parent;
42
46 abstract public function execute();
47
51 public function __construct( WebInstaller $parent ) {
52 $this->parent = $parent;
53 }
54
62 public function isSlow() {
63 return false;
64 }
65
69 public function addHTML( $html ) {
70 $this->parent->output->addHTML( $html );
71 }
72
73 public function startForm() {
74 $this->addHTML(
75 "<div class=\"config-section\">\n" .
76 Html::openElement(
77 'form',
78 [
79 'method' => 'post',
80 'action' => $this->parent->getUrl( [ 'page' => $this->getName() ] )
81 ]
82 ) . "\n"
83 );
84 }
85
90 public function endForm( $continue = 'continue', $back = 'back' ) {
91 $s = "<div class=\"config-submit\">\n";
92 $id = $this->getId();
93
94 if ( $id === false ) {
95 $s .= Html::hidden( 'lastPage', $this->parent->request->getVal( 'lastPage' ) );
96 }
97
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(),
103 [
104 'name' => "enter-$continue",
105 'style' => 'width:0;border:0;height:0;padding:0'
106 ]
107 ) . "\n";
108 }
109
110 if ( $back ) {
111 // Message: config-back
112 $s .= Xml::submitButton(
113 wfMessage( "config-$back" )->text(),
114 [
115 'name' => "submit-$back",
116 'tabindex' => $this->parent->nextTabIndex(),
117 'class' => 'cdx-button cdx-button--action-destructive'
118 ]
119 ) . "\n";
120 }
121
122 if ( $continue ) {
123 // Messages: config-continue, config-restart, config-regenerate
124 $s .= Xml::submitButton(
125 wfMessage( "config-$continue" )->text(),
126 [
127 'name' => "submit-$continue",
128 'tabindex' => $this->parent->nextTabIndex(),
129 'class' => 'cdx-button cdx-button--action-progressive'
130 ]
131 ) . "\n";
132 }
133
134 $s .= "</div></form></div>\n";
135 $this->addHTML( $s );
136 }
137
141 public function getName() {
142 return str_replace( 'MediaWiki\\Installer\\WebInstaller', '', static::class );
143 }
144
148 protected function getId() {
149 return array_search( $this->getName(), $this->parent->pageSequence );
150 }
151
158 public function getVar( $var, $default = null ) {
159 return $this->parent->getVar( $var, $default );
160 }
161
166 public function setVar( $name, $value ) {
167 $this->parent->setVar( $name, $value );
168 }
169
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";
180 }
181
187 protected function getFieldsetEnd() {
188 return "</span></span></span>\n";
189 }
190
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">'
201 );
202 $this->parent->output->flush();
203 }
204
208 protected function endLiveBox() {
209 $this->addHTML( '</textarea></div>
210<script>jQuery( "#config-spinner" ).hide()</script>' );
211 $this->parent->output->flush();
212 }
213
214}
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:56
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.
Module of static functions for generating XML.
Definition Xml.php:33